Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while importing .mjs file. #31

Closed
devpedroleitao opened this issue Oct 18, 2023 · 2 comments
Closed

Error while importing .mjs file. #31

devpedroleitao opened this issue Oct 18, 2023 · 2 comments

Comments

@devpedroleitao
Copy link

If you try to use the built index.mjs file from the lib it will not work.
The reason is that it tries to import the default from index.js

default-import
A simple solution is adding at the end of the file index.ts the following:

export default codec;

This problem is also related and causes to: storybookjs/storybook#22542

@swansontec
Copy link
Owner

swansontec commented Oct 25, 2023

I have created a PR to resolve this issue: #32

I've noticed that the rollup-plugin-mjs-entry approach (which is also the official Node.js suggested approach) doesn't actually work well with other tools outside the Node.js ecosystem.

What does work is simply producing a plain CJS build for legacy Node.js setups, and then producing a separate MJS build for the rest of the world. This gets rid of all the confusion.

I will try to get a coworker to review the PR, but if you want to take a look and maybe try it out, that would be fine too.

@swansontec
Copy link
Owner

This should be fixed in v1.5.3

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

No branches or pull requests

2 participants