You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to use @rollup/plugin-babel for older browsers support and @rollup/plugin-commonjs for my dependencies. One of my dependencies uses dynamic requrie calls, so enabled the dynamicRequireTargets option.
However, I couldn't come up with a working configuration:
doesn't work, because @rollup/plugin-commonjs injects require() calls for the dynamically imported files in the entrypoint, so I cannot only include /node_modules/ and not my source files.
I also tried duplicating the commonjs plugin like this:
I was hoping that it would have converted CJS dependencies to ESM for Babel, and then injected and converted require() calls after transpiling everything so that the CJS plugin doesn't see unknown syntax. However, for some reason this consumes too much memory and makes every Node.js version I tried segfault.
Feature Proposal
I am actually asking for two features:
rollupCommonJs should throw an error and make the build file if it cannot inject the require() calls. When we found out that our bundle didn't include the dynamically imported files we added the dynamicRequireTargets option thinking that it would have fixed it, and I only accidentally discovered that it was still not including those modules (all our tests where passing because when dynamicRequireTargets is enabled Rollup delegates to Node's native require()).
It should be possible to inject the preload code in a file that is different from the entrypoint.
To fix our build, I created an empty dynamic-require-entrypoint.cjs file, imported that file in our app, and hacked @rollup/plugin-commonjs so that it injects require() calls in that file rather than in the entrypoint: Make sure that Rollup's dynamicRequireTargets are included babel/babel#12839. I think that @rollup/plugin-commonjs should provide an option for this.
The text was updated successfully, but these errors were encountered:
Hey folks. This issue hasn't received any traction for 60 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it. ⓘ
Feature Use Case
I need to use
@rollup/plugin-babel
for older browsers support and@rollup/plugin-commonjs
for my dependencies. One of my dependencies uses dynamic requrie calls, so enabled thedynamicRequireTargets
option.However, I couldn't come up with a working configuration:
@rollup/plugin-commonjs
doesn't understand the experimental syntax before that it's compiled by Babel@rollup/plugin-babel
expects all its input to be ESM and not CJS (and it's clearly documented)@rollup/plugin-commonjs
injectsrequire()
calls for the dynamically imported files in the entrypoint, so I cannot only include/node_modules/
and not my source files.commonjs
plugin like this:require()
calls after transpiling everything so that the CJS plugin doesn't see unknown syntax. However, for some reason this consumes too much memory and makes every Node.js version I tried segfault.Feature Proposal
I am actually asking for two features:
rollupCommonJs
should throw an error and make the build file if it cannot inject therequire()
calls. When we found out that our bundle didn't include the dynamically imported files we added thedynamicRequireTargets
option thinking that it would have fixed it, and I only accidentally discovered that it was still not including those modules (all our tests where passing because whendynamicRequireTargets
is enabled Rollup delegates to Node's nativerequire()
).It should be possible to inject the preload code in a file that is different from the entrypoint.
To fix our build, I created an empty
dynamic-require-entrypoint.cjs
file, imported that file in our app, and hacked@rollup/plugin-commonjs
so that it injectsrequire()
calls in that file rather than in the entrypoint: Make sure that Rollup'sdynamicRequireTargets
are included babel/babel#12839. I think that@rollup/plugin-commonjs
should provide an option for this.The text was updated successfully, but these errors were encountered: