Skip to content
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

[Bug]: Bundling @babel/standalone by webpack emits warnings #14301

Open
1 task
joshuahhh opened this issue Feb 23, 2022 · 11 comments
Open
1 task

[Bug]: Bundling @babel/standalone by webpack emits warnings #14301

joshuahhh opened this issue Feb 23, 2022 · 11 comments

Comments

@joshuahhh
Copy link

💻

  • 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!

@babel-bot
Copy link
Collaborator

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.

@JLHwung JLHwung changed the title [Bug]: [Bug]: @babel/standalone can't be bundled by webpack Feb 28, 2022
@JLHwung
Copy link
Contributor

JLHwung commented Feb 28, 2022

This is rollup/plugins#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 JLHwung changed the title [Bug]: @babel/standalone can't be bundled by webpack [Bug]: Bundling @babel/standalone by webpack emits warnings Feb 28, 2022
@SxxPorsche
Copy link

SxxPorsche commented Jul 22, 2022

@JLHwung hello, is this bug has been fixed yet? I find the same question at version @babel/standalone@7.18.9

@liuxingbaoyu
Copy link
Member

@SxxPorsche I simply searched in the file content and didn't find anything similar to require(path), can you provide a reproducible repo?

@radhasatam
Copy link

Still facing this issue in 7.21.2.

@liuxingbaoyu
Copy link
Member

@radhasatam Can you provide a reproducible repo?

@superoery
Copy link

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

@liuxingbaoyu
Copy link
Member

Thanks, I can reproduce the problem.
Opened an issue rollup/plugins#1472.

@tomitrescak
Copy link

That issue rollup/plugins#1472 was closed due to inactivity ;( Is there another way out?

@nicolo-ribaudo
Copy link
Member

It would be awesome if someone could work on a rollup PR to fix that issue :)

@liuxingbaoyu
Copy link
Member

I'll try to do it in a few days. :) (previously I wasn't sure if this should open a rollup PR)

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

Successfully merging a pull request may close this issue.

9 participants