Is this an ESM-first module now?
See original GitHub issueWhen bumping from 10.3.0 to 10.4.4 I encountered the following issue when building my project:
> Build error occurred
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/runner/work/monorepo/monorepo/website/node_modules/d3-array/src/index.js
require() of ES modules is not supported.
require() of /home/runner/work/monorepo/monorepo/website/node_modules/d3-array/src/index.js from /home/runner/work/monorepo/monorepo/website/node_modules/reaviz/dist/index.cjs.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/runner/work/monorepo/monorepo/website/node_modules/d3-array/package.json.
Is this an ESM-first module now?
In my opinion, this should be clearly stated in the documentation.
Also, since this breaks backward compatibility (given the current JS ecosystem), I think this should warrant a major version change; not a minor one.
Issue Analytics
- State:
- Created 2 years ago
- Comments:22 (10 by maintainers)
Top Results From Across the Web
Meet the Orion Service Module, the European-built brain of ...
The first service module is now integrated with the Orion vehicle for the first Artemis mission. The second service module is ready for ......
Read more >ESM Loader with Node VM Module - Mauve's Blog
I've been wanting a browser-first / ESM-first environment for a while, and was excited when deno came out, but was disappointed that it...
Read more >Publish ESM and CJS in a single package
A short tutorial of shipping both ESM and CJS dual formats in a single NPM package.
Read more >Is it possible to use ES6 modules in Mocha tests?
Yes, as of Mocha version 9: Mocha is going ESM-first! This means that it will now use ESM import(test_file) to load the test...
Read more >Dependency Pre-Bundling
Performance: Vite converts ESM dependencies with many internal modules into a ... By pre-bundling lodash-es into a single module, we now only need...
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 FreeTop 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
Top GitHub Comments
I don’t wanna get too far ahead of myself, but d3 might have solved the problem for us.
The specific dep that’s throwing the error for me is d3-array, and according to your package.json, you have v3.0.4, and there is a new version, 3.1.1 available as of 1 month ago. According to the changelog, they have updated it to es6, so import should actually work now.
I’ll report back after some testing.
@amcdnl
yeah buddy. i’ll give it a shot.