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

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

@dchambers

Description

@dchambers

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/@meshsdk+mesh-csl@0.0.5/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 🙏

Metadata

Metadata

Assignees

No one assigned

    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