You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I implemented #117 I ran into some issues w/ esm. I attempted to migrate the project, but failed. I suspect it may have partially been mis-configuring. At any rate, here's a quick summary of what I learned...
ESM was designed for browsers; node adoption came later, but is the future
There are at least four relevant tsocnfig.json settings
Esbuild also plays a role: When bundles target node (my preload and main script), it emits commonjs
For tsconfig:
target: this just controls things like polyfills, i.e. "if I use fancy syntax, its valid / browser will provide it"
module: Whether to emit as commonjs or esm (+ a ilttle more nuance). What THIS app will be.
esModuleInterop: Helpers to handle imports that may be one or the other. What the DEPENDENCIES are.
moduleResolution: Yup, I've already forgotten
Further once compiled (typescript), and bundled (esbuild), there's an additional factor of Node (or the browser) being able to run the thing; the file extensions must be .mjs for the prebuild script (I think); package.json having type: "module" tells the node process to run as esm.
ANYWAYS, lots of moving parts. I may have to upgrade some of my dependencies; because of that I think it makes more sense to knock out the gonna-happy-anyway-dependency changes, likely as part of:
As I implemented #117 I ran into some issues w/ esm. I attempted to migrate the project, but failed. I suspect it may have partially been mis-configuring. At any rate, here's a quick summary of what I learned...
For tsconfig:
target
: this just controls things like polyfills, i.e. "if I use fancy syntax, its valid / browser will provide it"module
: Whether to emit as commonjs or esm (+ a ilttle more nuance). What THIS app will be.esModuleInterop
: Helpers to handle imports that may be one or the other. What the DEPENDENCIES are.moduleResolution
: Yup, I've already forgottenFurther once compiled (typescript), and bundled (esbuild), there's an additional factor of Node (or the browser) being able to run the thing; the file extensions must be
.mjs
for the prebuild script (I think); package.json havingtype: "module"
tells the node process to run as esm.ANYWAYS, lots of moving parts. I may have to upgrade some of my dependencies; because of that I think it makes more sense to knock out the gonna-happy-anyway-dependency changes, likely as part of:
The text was updated successfully, but these errors were encountered: