Discuss: Time to go ESM only? (for NPM `highlight.js` package)
See original GitHub issueThis is on the v12 possibilities list: #3219. Some were pushing us to do that last year but it felt very premature at the time. Come this May it will be one year later… and I’m thinking of perhaps a summer release for v12.
Related: #2600
To be clear: this is only discussing highlight.js
NPM package, not the highlightjs/cdn-release
which will continue (for now) to include our default web build (CJS monolith, CJS modules, ES modules).
If we decided to do this I wonder what the “so you’re stuck on CJS” story would look like other than “tough luck”?
- Keep using v11 (for 6 months) and then “tough luck” is one potential story…
- It would be fairly easy to add a web build that adds
global.hljs = hljs // etc
to the end of the build, allowing v12 users to (as a hack) use the v12 web/CDN build and modules if they must stay on CJS.
Opening up for discussion.. CC @highlightjs/core
Proposed changes if we go ESM only:
For the node
build:
- We no longer build the
lib
CJS folder - We rename the
es
folder tolib
- the
-ne
(don’t build ESM) build flag goes away - simplify
package.json
to remove all ESM + CJS stuff - the
es
files become the actual built source, rather than merely stubs as they are now
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:17 (9 by maintainers)
Top Results From Across the Web
highlight.js
Start using highlight.js in your project by running `npm i ... TypeScript icon, indicating that this package has built-in type declarations.
Read more >highlight.js demo
Go. package main import "fmt" func main() { ch := make(chan float64) ch <- 1.0e10 ... Println(`exitting now\`) go println(len("hello world!
Read more >Using ES modules in Node.js
Learn about the state of ES modules in Node today, including concerns realted to transitioning from and interoperability with CommonJS.
Read more >Mocha - the fun, simple, flexible JavaScript test framework
browser support · simple async support, including promises · run Node.js tests in parallel · test coverage reporting · string diff support ·...
Read more >Could not find a declaration file for module 'module-name'. ...
For the situation where you are installing your own npm package ... After this just go to your tsconfig.json file and add "typeRoots":...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I seem to hear absolutely zero people saying “we still really need CJS”… 💯
It’s a “façade” on purpose. I did quite a bit of reading at the time and from what I could determine this is/was the recommended way to publish a dual NPM package for Node.JS. If you make the ESM module truly stand alone then it becomes possible for someone to accidentally import the CJS library AND the ESM library (via different peer-dependencies). Then you have two different instances of the library when you only expect one.
The “facade” solves that problem. When CJS support is dropped the facade goes with it.
If I recall correctly our web ESM build is fully standalone as it does not have to deal with this Node.js ecosystem drama.