Skip to content

fix: allow dynamicImportInCjs in rollup v3 #28

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

Merged
merged 1 commit into from
Jan 2, 2023

Conversation

stipsan
Copy link
Member

@stipsan stipsan commented Dec 24, 2022

Rollup v3 introduces a great new option called dynamicImportInCjs.
Since we target Node 14 as our baseline we can safely use code like this:

const pkg = await import('pkg')

And if pkg is ESM-only (no CJS exports) it'll work the same in both ESM and CJS in NodeJS environments.

However since we use @babel/preset-env this new option doesn't work as babel is transforming the dynamic import() calls to require().

This PR fixes that by turning module transformation off in babel.

@stipsan stipsan marked this pull request as ready for review December 24, 2022 00:47
@stipsan stipsan force-pushed the fix-allow-dynamicImportInCjs-in-rollup-v3 branch from aaaedd8 to df674d6 Compare December 24, 2022 01:46

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
@stipsan stipsan force-pushed the fix-allow-dynamicImportInCjs-in-rollup-v3 branch from df674d6 to ebedbea Compare December 30, 2022 22:55
Copy link
Member

@mariuslundgard mariuslundgard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👀

@stipsan stipsan merged commit a0d73d6 into main Jan 2, 2023
@stipsan stipsan deleted the fix-allow-dynamicImportInCjs-in-rollup-v3 branch January 2, 2023 09:48
@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2023

🎉 This PR is included in version 2.0.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

None yet

2 participants