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
package.json - has issues regarding ESM and CJS support.
This problem usually happens when a library that includes both a CJS and ESM implementation attempts to use a single .d.ts types file to represent both, where the package.json has "type": "module", most often in a structure like:
If they use import or export at the top level—they must represent exactly one JavaScript file. They especially cannot represent JavaScript files of two different module formats. The example above needs to add a .d.cts file to represent the .cjs file, at which point the package.json can be rewritten as:
The qrcode package is using rollup to build both CJS and EMS modules, there is a known issue with rollup regarding this and possible workaround: rollup/plugins#1782
package.json
- has issues regarding ESM and CJS support.This problem usually happens when a library that includes both a CJS and ESM implementation attempts to use a single .d.ts types file to represent both, where the package.json has "type": "module", most often in a structure like:
If they use import or export at the top level—they must represent exactly one JavaScript file. They especially cannot represent JavaScript files of two different module formats. The example above needs to add a .d.cts file to represent the .cjs file, at which point the package.json can be rewritten as:
{
"name": "pkg",
"type": "module",
"exports": {
".": {
"import": {
"types": "./index.d.ts",
"default": "./index.js"
},
"require": {
"types": "./index.d.cts",
"default": "./index.cjs"
}
}
}
}
The
qrcode
package is usingrollup
to build bothCJS
andEMS
modules, there is a known issue with rollup regarding this and possible workaround:rollup/plugins#1782
Reference to cause and the potential fix:
https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseESM.md
The text was updated successfully, but these errors were encountered: