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

Update Babel to fix issue with @babel/generator #975

Closed
MrDWilson opened this issue Nov 7, 2022 · 3 comments
Closed

Update Babel to fix issue with @babel/generator #975

MrDWilson opened this issue Nov 7, 2022 · 3 comments

Comments

@MrDWilson
Copy link

Webpack Version:
5.72.1

Babel Core Version:
7.19.3

Babel Loader Version:
9.1.0

Please tell us about your environment:
Windows 10

Current behavior:

When using babel-loader, some comments in JavaScript are converted incorrectly. E.g.,

// Single line comment /* with block comment inside */

is translated to

/* Single line comment /* with block comment inside */ */

This is invalid JS as the first comment end terminates the whole thing, and the second */ is treated as code (producing an error).

The actual error when building using webpack (coming from Pako in this instance, but isn't limited to this package):

ERROR in ./node_modules/@progress/pako-esm/dist/pako-esm2015.js 3476:106
Module parse failed: Unexpected token (3476:106)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|  *     not null.
|  */
> function gen_bitlen(s, desc) /*    deflate_state *s;*/ /*    tree_desc *desc;    /* the tree descriptor */*/{
|   var tree = desc.dyn_tree;
|   var max_code = desc.max_code;

Expected/desired behavior:

It should not convert these comments.

Suggested fix:

This problem has been corrected in @babel/generator version 7.20.3 (released on the day I am posting this). Upgrading babel-loader to use this new version of the package will fix the issue.

Suggested workaround for people experiencing this issue in the meantime:

Adding an override section in your package.json with @babel/generator force updated fixes the issue for now.

"overrides": {
    "@babel/generator": "7.20.3"
}
@MrDWilson
Copy link
Author

@JLHwung
Copy link
Contributor

JLHwung commented Nov 7, 2022

The overrides section is supported in npm 8.3+, and more importantly, it is meant to be used by end users, not package authors.

Currently @babel/generator is not a direct dependency of babel-loader, instead it requires a peerDependency @babel/core: ^7.12.0, which depends on @babel/generator: ^7.12.0, which covers @babel/generator: 7.20.3 per semver specification.

There is no action item for babel-loader now.

@JLHwung JLHwung closed this as completed Nov 7, 2022
@nicolo-ribaudo
Copy link
Member

You can just delete @babel/generator from your lockfile and run npm install to update it.

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

No branches or pull requests

3 participants