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
While trying to use the @iden3 set of packages, core, crypto and merkletree, faced an issue with their ESM deliveries while trying to use in my ESM module.
➜ iden3-invalid-build node .
(node:73502) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/Users/antonioivanovski/dev/iden3-invalid-build/node_modules/@iden3/js-iden3-core/dist/node/esm/index.js:1
export * from './claim';
^^^^^^
SyntaxError: Unexpected token 'export'
at internalCompileFunction (node:internal/vm:77:18)
at wrapSafe (node:internal/modules/cjs/loader:1288:20)
at Module._compile (node:internal/modules/cjs/loader:1340:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at cjsLoader (node:internal/modules/esm/translators:356:17)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:305:7)
at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
Node.js v20.11.0
Issues:
The package.json is not marked as ESM module ("type": "module"), causing the file resolution to require .mjs extension of JS files. This is documented at: https://nodejs.org/api/esm.html#enabling
The import/export statements require mandatory file extensions, instead of export * from './claim'; it needs to be export * from './claim.js';. This is documented at: https://nodejs.org/api/esm.html#import-specifiers
While trying to use the
@iden3
set of packages,core
,crypto
andmerkletree
, faced an issue with their ESM deliveries while trying to use in my ESM module.Reproduction steps:
"type": "module"
property inproject.json
@iden3/js-iden3-core
inindex.js
Repository: https://github.com/toteto/iden3-invalid-build
Issues:
package.json
is not marked as ESM module ("type": "module"
), causing the file resolution to require.mjs
extension of JS files. This is documented at: https://nodejs.org/api/esm.html#enablingexport * from './claim';
it needs to beexport * from './claim.js';
. This is documented at: https://nodejs.org/api/esm.html#import-specifiersjson
document requires specifying import attributes ofwith { type: 'json' }
. Documented at: https://nodejs.org/api/esm.html#import-attributesWorkaround:
Currently using
pnpm patch
to patch the builds with fixes for the above mentioned issues. I have put all patches at: https://gist.github.com/toteto/f071db1a0495b426efbd2390a34790cfThe text was updated successfully, but these errors were encountered: