Skip to content

[Bug]: Unable to use pako in create-react-app 5 with latest babel v7.20.x #15132

@cmdcolin

Description

@cmdcolin

💻

  • 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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions