+
Skip to content

Invalid ESM builds #40

@antonio-ivanovski

Description

@antonio-ivanovski

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.

Reproduction steps:

  1. Create new project
  2. Set the "type": "module" property in project.json
  3. Import @iden3/js-iden3-core in index.js

Repository: https://github.com/toteto/iden3-invalid-build

➜  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:

Workaround:
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/f071db1a0495b426efbd2390a34790cf

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载