[X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
Bug Category
Other
Describe the bug
The wasm npm package is missing a import statement in its package.json file, specifically within the exports object. Therefore, ESM modules within nodejs cannot import the nodejs subpackage without error.
package.json:
"exports": {
".": {
"import": "./esm/cedar_wasm.js",
"types": "./esm/cedar_wasm.d.ts"
},
"./nodejs": {
"require": "./nodejs/cedar_wasm.js",
"import": "./nodejs/cedar_wasm.js", <--- this statement is missing and must be added.
"types": "./nodejs/cedar_wasm.d.ts"
},
"./web": {
"import": "./web/cedar_wasm.js",
"types": "./web/cedar_wasm.d.ts"
}
}
Without this fix you get the error:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './nodejs' is not defined by "exports" in PATH/node_modules/@cedar-policy/cedar-wasm/package.json imported from ESMODULE
Expected behavior
No NodeJS error.
Reproduction steps
Create an index.mjs file containing the following lines:
const cedar = await import('@cedar-policy/cedar-wasm/nodejs');
console.log(cedar.getCedarVersion())
Having the most basic package.json within the same directory containing the @cedar-policy/cedar-wasm dependency.
Run yarn/npm install within that directory to install the cedar-wasm lib.
Run node index.mjs. Get the error
Now add within the node_modules/@cedar-policy/cedar-wasm/package.json file the fix as described within the description ( "import": "./nodejs/cedar_wasm.js",)
Run node index.mjs again and get the version number.
Before opening, please confirm:
Bug Category
Other
Describe the bug
The wasm npm package is missing a
import
statement in its package.json file, specifically within theexports
object. Therefore, ESM modules within nodejs cannot import thenodejs
subpackage without error.package.json:
Without this fix you get the error:
Expected behavior
No NodeJS error.
Reproduction steps
index.mjs
file containing the following lines:@cedar-policy/cedar-wasm
dependency.node index.mjs
. Get the error"import": "./nodejs/cedar_wasm.js",
)node index.mjs
again and get the version number.Code Snippet
See reproduction steps
Log output
Additional configuration
NodeJS v20
Operating System
Windows WSLv2 on Fedora Remix
Additional information and screenshots
No response