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
The CommonJS files of the build are treated as ES module files resulting in an error when importing this package in a CommonJS module.
I believe this is due to the way this package has set up its dual CJS/ESM builds and exports. There is a helpful tool called publint that highlights why this is happening for this project: https://publint.dev/@cortex-js/[email protected]
Steps to Reproduce
Have a CommonJS file that imports @cortex-js/compute-engine (v0.28.0)
An error like this is thrown at runtime when trying to import the package:
Error [ERR_REQUIRE_ESM]: require() of ES Module /project/sandbox/node_modules/@cortex-js/compute-engine/dist/compute-engine.min.js from /project/sandbox/index.js not supported.
compute-engine.min.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead either rename compute-engine.min.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /project/sandbox/node_modules/@cortex-js/compute-engine/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
Expected Result
No error when importing the package in a CommonJS module
Environment
This is the first time I'm using this package, so I'm not sure if this used to work differently in previous version. I've tested this in an isolated node environment running v21.7.3 (the code sandbox above) and in the browser as well within my application.
Compute Engine version 0.28.0
The text was updated successfully, but these errors were encountered:
Description
The CommonJS files of the build are treated as ES module files resulting in an error when importing this package in a CommonJS module.
I believe this is due to the way this package has set up its dual CJS/ESM builds and exports. There is a helpful tool called publint that highlights why this is happening for this project: https://publint.dev/@cortex-js/[email protected]
Steps to Reproduce
@cortex-js/compute-engine
(v0.28.0)I've also created a basic sandbox showcasing the error: https://codesandbox.io/p/devbox/compute-engine-in-commonjs-mkpsl5
Actual Result
An error like this is thrown at runtime when trying to import the package:
Expected Result
No error when importing the package in a CommonJS module
Environment
This is the first time I'm using this package, so I'm not sure if this used to work differently in previous version. I've tested this in an isolated node environment running v21.7.3 (the code sandbox above) and in the browser as well within my application.
Compute Engine version 0.28.0
The text was updated successfully, but these errors were encountered: