You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think this could be solved by using modern exports: {} conditions instead of main and module? But even this is not recommended so as to avoid the dual package hazard https://nodejs.org/api/packages.html#packages_dual_package_hazard where you can get two copies of the package code in your webpack/vite/rollup/parcel/whatever bundle.js file.
The idealized solution is to either a) only export an ESM version or b) export an ESM wrapper that just export {} from "./module.cjs" so that there's only one canonical source of code or c) only export a CJS version.
Funnily enough, in the package's current state it doesn't suffer from the dual package hazard since it currently only exports CommonJS 🤣
The text was updated successfully, but these errors were encountered:
jcbhmr
changed the title
Node.js doesn't pick up ESM export
Always resolves to CJS, not ESM export
Jun 7, 2023
jcbhmr
changed the title
Always resolves to CJS, not ESM export
Always resolves to CJS even when using ESM
Jun 7, 2023
When using the usual ESM stuff, I still resolve to
index.js
instead ofindex.esm.js
.(Using is-what as an example of it done OK-ly)
I think this could be solved by using modern
exports: {}
conditions instead ofmain
andmodule
? But even this is not recommended so as to avoid the dual package hazard https://nodejs.org/api/packages.html#packages_dual_package_hazard where you can get two copies of the package code in your webpack/vite/rollup/parcel/whatever bundle.js file.The idealized solution is to either a) only export an ESM version or b) export an ESM wrapper that just
export {} from "./module.cjs"
so that there's only one canonical source of code or c) only export a CJS version.Funnily enough, in the package's current state it doesn't suffer from the dual package hazard since it currently only exports CommonJS 🤣
The text was updated successfully, but these errors were encountered: