Categories
JavaScript npm modules

Import JSON in Node in ESM Modules

Node 16.15 added support for importing JSON modules using the new assert { type: 'json' } syntax.

This is great news if you develop npm modules that need to be consumed both client and server side (or even just server side).

There’s a catch though… As of this writing it is a bit tricky to get working in Jest, and RollupJS just flat-out doesn’t support it (and the import assertions plugin also doesn’t work consistently).

Categories
Patents

Patent: Discrepancy Resolution Processor and Methods for Implementing the Same

This is a patent I was issued for a system I wrote while on the prototyping team at Salesforce.

While we were creating prototypes, Sketch would often export SVGs that (once loaded in the browser) had invalid html with weird artifacts and didn’t quite match up with what the designer was seeing in Sketch. The PNG files that Sketch exported would match. So what I did was created a Sketch plugin that would export both an SVG and a PNG, and then load the SVG inside of a browser (Puppeteer), clean up the HTML, take a screenshot, and compare the screenshot to the PNG (using ImageMagick). Depending on what it saw, it would make further modifications to the code within the SVG file (then Puppeteer, screenshot) and compare the modified SVG file to the PNG file, and notify the designer about the outcome.