Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

@meshsdk/mesh-csl's ESM export doesn't work #21

Open
dchambers opened this issue May 29, 2024 · 0 comments
Open

@meshsdk/mesh-csl's ESM export doesn't work #21

dchambers opened this issue May 29, 2024 · 0 comments

Comments

@dchambers
Copy link

This is the error I get when trying to import applyObjParamsToScript from @meshsdk/mesh-csl:

(node:127061) 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)
/home/dominicc/Development/serpentine/node_modules/.pnpm/@[email protected]/node_modules/@meshsdk/mesh-csl/dist/mjs/index.js:1
export * from './csl';

The current hybrid module support can't work because both the CJS and ESM modules import external modules with .js suffixes, yet additional imports with .js suffixes can only be either CJS ("type": "commonjs") or ESM ("type": "module").

The most common way I see people doing hybrid modules is to bundle the CJS export down to a single file and set "type": "module" within package.json so that the ESM can be left unbundled (and potentially able to support tree shaking?).

Alternatively, you could:

  1. Bundle the ESM export.
  2. Find some tooling which will rename all the .js files used within dist/mjs to have .mjs extensions and set "type": "commonjs", in which case both export types can be left unbundled.

Thanks for making this library BTW 🙏

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant