Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

[@rollup/plugin-commonjs]: dynamically requiring a built-in node.js module in an esm script will always throw #1676

Closed
perrin4869 opened this issue Feb 8, 2024 · 0 comments

Comments

@perrin4869
Copy link
Contributor

Expected Behavior

Doing a dynamic require of a bulit-in node module should succeed, regardless of the settings of dynamicRequireTargets, ignoreDynamicRequire.

Actual Behavior

The dynamic require will throw in all possible configurations of these settings.

Additional Information

I encountered this issue while bundling the latest version of nock (13.5.1).
It does a dynamic require of http and https, but this require will always throw if the target is an esm module run in node.js.
If ignoreDynamicRequire is false, it'll throw with Could not dynamically require \"http\". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.. If ignoreDynamicRequire is true, it will throw due to require not being defined inside the esm module.
It should be relatively easy to fix it so this behavior is supported, but probably best done by someone familiar with the codebase 😅

@rollup rollup locked and limited conversation to collaborators Feb 8, 2024
@shellscape shellscape converted this issue into discussion #1677 Feb 8, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant