question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Convert everything to ESM

See original GitHub issue

Modules are now fully supported in Node, except in Node 10 which will fall out of LTS very soon (the current ‘active’ LTS version is 14).

It makes sense, I think, for SvelteKit to fully embrace ESM, by which I mean that the CLI should be distributed as ESM, and that svelte.config.js and snowpack.config.js should be ESM.

There is a practical benefit to this, aside from making everything new and shiny and futureproof: it means that you can trivially share modules between the app you’re building and e.g. npm run scripts. (We’ve encountered this at the NYT — we have a decompress module that is primarily used in the client to calculate things like rolling averages, which don’t need to come over the wire, but which are also needed script-side to generate some summary data files.)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
babichjacobcommented, Mar 22, 2021

It says it’s currently on Node 12.18.3, is that not compatible with ESM?

If I remember correctly, only with the --experimental-modules flag.

1reaction
Rich-Harriscommented, Jan 30, 2021

The interop is fine — you can import foo from './foo.cjs' in an ESM project and it will Do The Right Thing. So that seems viable

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to convert a CJS module to an ESM | by Mario Kandut
To convert it to an ESM module, the only we have to do change the file extension from .js to .mjs . If...
Read more >
CommonJS to ESM in Node.js - Aral Balkan
First off, I started by running the following regular expression to quickly convert CommonJS require syntax to ESM import syntax: ...
Read more >
to-esm - npm
Tool to convert Commonjs files into ESM. Latest version: 2.26.3, last published: 2 months ago. Start using to-esm in your project by running ......
Read more >
Migrate a Node.js project to ESM - Ludovico Fischer
First, use at least Node.js 12.17 so that ESM modules are available without the --experimental flag. Next, get your own code to run...
Read more >
GECK Tutorial - Converting an .esp to .esm - YouTube
In this tutorial I use FNVEdit to convert an .esp to an . esm, you can download FNVEdit from the New Vegas NexusCheck...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found