babel / minify

:scissors: An ES6+ aware minifier based on the Babel toolchain (beta)
https://babeljs.io/repl
MIT License
4.4k stars 225 forks source link

latest babel 7.7.0 is causing babel-plugin-minify-simplify to fail #968

Open jchip opened 5 years ago

jchip commented 5 years ago

Describe the bug

After updating to the babel modules version 7.7.0 published on 11/05/19, babel-plugin-minify-simplify/lib/index.js:549:40 is now failing with Cannot set property inList of [object Object] which has only a getter.

This is pulled in by babel-preset-minify 0.4.3. It's used to minify React code.

To Reproduce

Minimal code to reproduce the bug package.json

{
  "name": "m1",
  "dependencies": {
    "@babel/cli": "^7.7.0",
    "@babel/core": "^7.7.0",
    "@babel/preset-env": "^7.7.1",
    "@babel/preset-react": "^7.7.0",
    "babel-preset-minify": "^0.5.1"
  }
}

.babelrc.js:

module.exports = {
  presets: [["@babel/env", { modules: "auto" }], "@babel/react", "minify"].filter(x => x)
};

test.js

function test(b) {
  if (b.foo) {
    return b.foo;
  }
}

command: npx babel test.js

Actual Output

Error thrown

Expected Output

No error thrown

Stack Trace

{ TypeError: ./test.js: Cannot set property inList of [object Object] which has only a getter
    at PluginPass.exit (./node_modules/babel-plugin-minify-simplify/lib/index.js:549:40)
    at newFn (./node_modules/@babel/traverse/lib/visitors.js:179:21)
    at NodePath._call (./node_modules/@babel/traverse/lib/path/context.js:55:20)
    at NodePath.call (./node_modules/@babel/traverse/lib/path/context.js:42:17)
    at NodePath.visit (./node_modules/@babel/traverse/lib/path/context.js:99:8)
    at TraversalContext.visitQueue (./node_modules/@babel/traverse/lib/context.js:112:16)
    at TraversalContext.visitSingle (./node_modules/@babel/traverse/lib/context.js:84:19)
    at TraversalContext.visit (./node_modules/@babel/traverse/lib/context.js:140:19)
    at Function.traverse.node (./node_modules/@babel/traverse/lib/index.js:84:17)
    at NodePath.visit (./node_modules/@babel/traverse/lib/path/context.js:97:18) code: 'BABEL_TRANSFORM_ERROR' }

Configuration

How are you using babel-minify?

babel-minify CLI

babel-minify version: 0.4.3

babel version : @babel/core@7.7.0

babel-minify-config:

{
  removeConsole: true,
  keepFnNames: true
}

babelrc:

{
  plugins: [],
  presets: []
}

Possible solution

Additional context

jchip commented 5 years ago

oops, already reported https://github.com/babel/minify/issues/967