babel
babel copied to clipboard
[Bug]: Bundling @babel/standalone by webpack emits warnings
💻
- [ ] Would you like to work on a fix?
How are you using Babel?
Programmatic API (babel.transform
, babel.parse
)
Input code
import '@babel/standalone';
Configuration file name
No response
Configuration
N/A
Current and expected behavior
Current behavior: When bundling a project with Webpack which includes code that imports '@babel/standalone', Webpack reports:
WARNING in ./node_modules/@babel/standalone/babel.js 308:11-32 Critical dependency: the request of a dependency is an expression @ ./src/index.js 9:0-27
WARNING in ./node_modules/@babel/standalone/babel.js 346:11-24 Critical dependency: the request of a dependency is an expression @ ./src/index.js 9:0-27
I think this is due to commonjsRequire
's use of require(path)
.
Environment
Tested in a fresh create-react-app
environment, as well as a more minimal Webpack environment.
Possible solution
Given that @babel/standalone is intended for use in a browser environment, I wonder why it includes bare require()
calls. Perhaps these parts could be excluded from this build?
Additional context
Please let me know if there's anything else I can do to help. Thanks a bunch!
Hey @joshuahhh! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.
If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.
This is https://github.com/rollup/plugins/issues/1085.
Update: it is not. The require
in commonjsRequire
is the fallback in case we fail to bundle the dynamic required libraries used in @babel/standalone
, which should be a bug. commonjsRequire
is in rollup commonjs helper so we can't simply remove it. For now you may ignore such warnings.
@JLHwung hello, is this bug has been fixed yet? I find the same question at version @babel/[email protected]
@SxxPorsche I simply searched in the file content and didn't find anything similar to require(path)
, can you provide a reproducible repo?
Still facing this issue in 7.21.2
.
@radhasatam Can you provide a reproducible repo?
Still facing this issue in 7.21.4.
See: https://github.com/Mity1299/babel-standalone-webpack-bug
run npm run build
will see the error:
Critical dependency: the request of a dependency is an expression
Thanks, I can reproduce the problem. Opened an issue https://github.com/rollup/plugins/issues/1472.
That issue https://github.com/rollup/plugins/issues/1472 was closed due to inactivity ;( Is there another way out?
It would be awesome if someone could work on a rollup PR to fix that issue :)
I'll try to do it in a few days. :) (previously I wasn't sure if this should open a rollup PR)