question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Minify throws TypeError when minifying if with return statement in it.

See original GitHub issue

Describe the bug

Hi everyone, i’m using @babel/core 7.6.0 and babel-minify 0.5.1 and i got TypeError, trying minifying code provided below:

To Reproduce

Minimal code to reproduce the bug

function foo(bar) {
    if (bar) {
        return 'baz';
    }
}

Actual Output

TypeError: unknown: Cannot set property inList of [object Object] which has only a getter
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ring-react-components@1.12.2 test-minify: `minify ./src/components/ActionsBox.js --outFile mActionBox.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ring-react-components@1.12.2 test-minify script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

How are you using babel-minify

minify ./src/components/ActionsBox.js --outFile mActionBox.js

Also, can be reproduced in babljs.io: https://babeljs.io/repl/#?babili=true&browsers=&build=&builtIns=false&spec=false&loose=false&code_lz=GYVwdgxgLglg9mABMOcAUAjAhgJwJSIDeAUAJAzCKa4EmL2Kk4CmUIOS2AXgNzEOIAvsUFA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=false&presets=babili&prettier=false&targets=&version=7.7.1&externalPlugins=

{
  plugins: [],
  presets: []
}

Possible solution

Error is somewhere in babel-plugin-minify-simplify, when i disable this plugin minifying works, but i cant do that for every dependency and i think that minifying should just work for that case.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:8
  • Comments:14

github_iconTop GitHub Comments

4reactions
GrimaceOfDespaircommented, Nov 6, 2019

This started happening to us since yesterday noon. Still digging into any library dependency update that might cause this.

2reactions
GrimaceOfDespaircommented, Nov 7, 2019

Looks like we got a fix!

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

When reading minified Javascript, how am I supposed to read ...
I understand how the comma operator 'runs a series of expressions, in order, and then returns the result of the last of them'...
Read more >
Terser vs. Uglify vs. babel-minify: Comparing JavaScript ...
Terser is one of the most popular and efficient libraries for minifying ES6 code. See how Terser compares to UglifyJS and babel-minify.
Read more >
eval() - JavaScript - MDN Web Docs - Mozilla
Throws any exception that occurs during evaluation of the code, including SyntaxError if script fails to be parsed as a script. Description.
Read more >
CoffeeScript
ast , boolean: if true, return an abstract syntax tree of the input CoffeeScript source code. Transpilation. CoffeeScript 2 generates JavaScript that uses...
Read more >
uglify-js - npm
UglifyJS is a JavaScript parser, minifier, compressor and beautifier toolkit. ... `bare_returns` Allow return outside of functions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found