Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to esm #157

Open
Tracked by #169
cloverich opened this issue Feb 17, 2024 · 1 comment
Open
Tracked by #169

Migrate to esm #157

cloverich opened this issue Feb 17, 2024 · 1 comment

Comments

@cloverich
Copy link
Owner

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:

@cloverich
Copy link
Owner Author

cloverich commented Jun 26, 2024

@cloverich cloverich mentioned this issue Jul 1, 2024
23 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant