Node Modules at War: Why CommonJS and ES Modules Can’t Get Along
redfin.engineering
Node Modules at War: Why CommonJS and ES Modules Can’t Get Along
1–10 of 152 posts
Re: Node Modules at War: Why CommonJS and ES Modules Can’t Get Along
#2Re: Node Modules at War: Why CommonJS and ES Modules Can’t Get Along
#3I find it fascinating watching our understanding of async computation mature over the years.
[1] http://journal.stuffwithstuff.com/2015/02/01/what-color-is-y...
Re: Node Modules at War: Why CommonJS and ES Modules Can’t Get Along
#4It's time we all published standard JS modules and only standard JS modules to npm.
Re: Node Modules at War: Why CommonJS and ES Modules Can’t Get Along
#5> You can’t require() ESM scripts
That’s one way to put it! Another would be to say that you don’t have to. require() came about because we didn’t have the import keyword.
Re: Node Modules at War: Why CommonJS and ES Modules Can’t Get Along
#6In two-and-a-half months the last 5 stable releases on Node, the last 2 LTS releases of Node, and all current major browsers will support standard JS modules. It's time we all published standard JS modules and only standard JS modules to npm.
(Author here.)
Node 14 supports ESM, but Node 12 only supports ESM behind the --experimental-modules flag, and its error handling for incorrectly importing CJS is not good.
In 2020, I think it's a bit early to go ESM only, especially since it's straightforward for CJS libraries to support both CJS and ESM clients. (I document how to do this in the article.)
Re: Node Modules at War: Why CommonJS and ES Modules Can’t Get Along
#7Thank you.
Re: Node Modules at War: Why CommonJS and ES Modules Can’t Get Along
#8Or if you prefer this Hessian article:
https://www.faz.net/podcasts/wie-erklaere-ich-s-meinem-kind/...
Re: Node Modules at War: Why CommonJS and ES Modules Can’t Get Along
#9Re: Node Modules at War: Why CommonJS and ES Modules Can’t Get Along
#10 import x from "library";
import {x} from "library";
import * as x from "library";
import {x as y} from "library";
Just to compare Java uses this: import java.lang.Double;
import java.lang.*;
No renaming, not a gazillion options during in- and export, but one statement. If you want to rename something, assign it to a variable.I don't understand why ES-module authors made it that complicated, when they had the chance to introduce a proper module system.
Why did they not just copy Java's system and be done with it.