babel: [Bug]: Unable to use pako in create-react-app 5 with latest babel v7.20.x
💻
- Would you like to work on a fix?
How are you using Babel?
Other (Next.js, Gatsby, vue-cli, …)
Input code
The file from pako is node_modules/pako/dist/pako.esm.mjs
const gen_bitlen = (s, desc) =>
// hello_deflate_state *s;
// tree_desc *desc; /* the tree descriptor */
{
const tree = desc.dyn_tree;
const max_code = desc.max_code;
The error from a build is
$ yarn build
yarn run v1.22.18
$ react-scripts build
Creating an optimized production build...
Failed to compile.
Module parse failed: Unexpected token (255:129)
File was processed with these loaders:
* ./node_modules/babel-loader/lib/index.js
* ./node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
| * not null.
| */
> var gen_bitlen = function gen_bitlen(s, desc) /* hello_deflate_state *s;*/ /* tree_desc *desc; /* the tree descriptor */*/{
| var tree = desc.dyn_tree;
| var max_code = desc.max_code;
Configuration file name
package.json
Configuration
I use a default version of installing create-react-app with yarn.lock in https://github.com/cmdcolin/pako_error_in_cra5
Can eject the cra config to see details
Current and expected behavior
This I believe is a fairly recently change, and I’m not certain it’s babel that does this type of conversion of comment formats. If this is not true I can redirect this issue elsewhere!
The code worked when my yarn.lock has e.g. ~7.19.x versions of babel packages, but started failing now at ~7.20.x. there are many babel packages so I’m not sure which but a diff between working and non-working is at this pastebin https://pastebin.com/xe3HSAgW
Environment
- babel 7.20.x (failing) babel 7.19.x (working)
- node 18.20
- yarn 1.22.18
- ubuntu 22.10
- not a monorepo but testing in a create react app
reproducible repo here https://github.com/cmdcolin/pako_error_in_cra5
Possible solution
No response
Additional context
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (6 by maintainers)
Commits related to this issue
- build: patch pako comments that caused babel to fail https://github.com/nodeca/pako/issues/262 https://github.com/babel/babel/issues/15132 — committed to TalismanSociety/talisman-web by tien 2 years ago
- build: patch pako comments that caused babel to fail https://github.com/nodeca/pako/issues/262 https://github.com/babel/babel/issues/15132 — committed to TalismanSociety/talisman-web by tien 2 years ago
- build: patch pako comments that caused babel to fail https://github.com/nodeca/pako/issues/262 https://github.com/babel/babel/issues/15132 — committed to TalismanSociety/talisman-web by tien 2 years ago
- build: patch pako comments that caused babel to fail https://github.com/nodeca/pako/issues/262 https://github.com/babel/babel/issues/15132 — committed to TalismanSociety/talisman-web by tien 2 years ago
- build: patch pako comments that caused babel to fail https://github.com/nodeca/pako/issues/262 https://github.com/babel/babel/issues/15132 — committed to TalismanSociety/talisman-web by tien 2 years ago
Same error with React JS.
This is happening to me in angular as well. `./node_modules/pako/lib/zlib/trees.js:257:106 - Error: Module parse failed: Unexpected token (257:106) File was processed with these loaders:
@JLHwung Any eta on when the fix will be published?
I think https://github.com/cmdcolin/pako_error_in_cra5 is using 7.20.2 of @babel/core
can see in yarn.lock for details
and it does still produce the error. do you think this issue should re-open?