[Bug] shipped `.mjs` bundle includes reference to `__dirname`
See original GitHub issue__dirname
is not available in ES modules.
Had to switch my project to ESM for another dependency and this came up as an error.
I’m not clear on how files are handled, but maybe it’s not respecting the
"exports": {
".": {
"import": "./index.mjs",
"require": "./index.cjs"
},
"./*": "./*"
},
from the package.json
of auto-imported modules
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
javascript - __dirname is not defined in Node 14 version
According to this issue, the problem arises if you load it as an ECMAScript module which do not contain __dirname.
Read more >ESM builds should substitute `__filename` and `__dirname ...
When building an ESM build in Webpack, free __filename and __dirname references in CommonJS files should be supported. What is motivation or use...
Read more >Publish ESM and CJS in a single package - Anthony Fu
A short tutorial of shipping both ESM and CJS dual formats in a single NPM package.
Read more >ECMAScript modules | Node.js v19.3.0 Documentation
Introduction#. ECMAScript modules are the official standard format to package JavaScript code for reuse. Modules are defined using a variety of import and ......
Read more >What does it take to support Node.js ESM? – The Guild
For the reason just mentioned, the standard package.json#exports should look ... like filedirname that does a trick inspecting error stacks, ...
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
Issue created on
vite-plugin-inspect
I had to uninstall and reinstall. Now it works. Thanks!