[@rollup/plugin-commonjs]: dynamically requiring a built-in node.js module in an esm script will always throw #1677
Unanswered
perrin4869
asked this question in
Q&A
Replies: 1 comment
-
@lukastaegert I think adding support for dynamically importing builtin node modules would be the solution here?
This doesn't work right, because all |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
http
andhttps
modules due to bundler limitations nock/nock#2586Expected 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
andhttps
, but this require will always throw if the target is an esm module run in node.js.If
ignoreDynamicRequire
isfalse
, it'll throw withCould not dynamically require \"http\". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.
. IfignoreDynamicRequire
istrue
, it will throw due torequire
not being defined inside theesm
module.It should be relatively easy to fix it so this behavior is supported, but probably best done by someone familiar with the codebase 😅
Beta Was this translation helpful? Give feedback.
All reactions