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

Shared modules should inherit file extension (e.g. .mjs) #557

Closed
amannn opened this issue Jun 26, 2024 · 2 comments · Fixed by #570
Closed

Shared modules should inherit file extension (e.g. .mjs) #557

amannn opened this issue Jun 26, 2024 · 2 comments · Fixed by #570

Comments

@amannn
Copy link

amannn commented Jun 26, 2024

Another week, another bug report :).

I noticed when you have a build that generates .mjs files (since the package uses type: 'commonjs'), then shared modules of the entry points will use the .js extension. This results in consumer errors if the shared module has further imports since all modules that use ESM in this graph should use the .mjs extension.

Reproduction: ./dist/esm/core.mjs

In the linked example this works, but if utils-shared-BdVwpBM3.js would have another import (e.g. import Link from 'next/link') then this would break:

Module parse failed: 'import' and 'export' may appear only with 'sourceType: module' (1:0)
@amannn
Copy link
Author

amannn commented Jun 26, 2024

Hmm, same seems to be true also for separate chunks that are created via the 'use client' split: react.mjs.

@huozhi
Copy link
Owner

huozhi commented Jun 29, 2024

I changed the feature to experimental, probably still need to use a separate entry to achieve it for now 😢 The spit chunks feature is quite limited for do this automatically with rollup. I'm still exploring the other ways to do it

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

Successfully merging a pull request may close this issue.

2 participants