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

options of minifyJs should to be reviewed #8905

Closed
simonjoom opened this issue Oct 8, 2018 · 6 comments
Closed

options of minifyJs should to be reviewed #8905

simonjoom opened this issue Oct 8, 2018 · 6 comments
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby

Comments

@simonjoom
Copy link

use correct option of minifyJs
related to
facebook/create-react-app#4234
to get the "why" Please read this thread upper

specify ecma: 5 like described in create-react-app to support ie11 and to avoid some bug on some browser.

@pieh
Copy link
Contributor

pieh commented Oct 8, 2018

This is interesting. Will need to some research

@jquense do You have any thoughts on that?

@jquense
Copy link
Contributor

jquense commented Oct 8, 2018

seems reasonable tho i'm not sure what it means in terms of output. at the point to which uglify is run the code is already compiled to the desired ecma, i'm not sure if uglify will go out of it's way to upscale syntax unless it's told not too?

in other word's i can see uglify turning multiple let declarations into let foo, bar, baz but i don't think it will decide to use let in the output if the input is already var.

@simonjoom
Copy link
Author

simonjoom commented Oct 8, 2018

i think that just take and copy things without think a lot of investigation from create-react-app is reasonable as it's a very used and debugged repo from Facebook! :)

like explained in facebook/create-react-app#4234 (comment) put down ecma to version 5 in the compression just disable some undesirable optimisation that uglify can create so it's not actually change the version output of the code created. you can still have some ecma2016 code inside

@KyleAMathews
Copy link
Contributor

@jquense perhaps it generates different syntax for newer versions? E.g. some new JS syntax produces smaller output so they opt into that if they can 🤷‍♂️

@kakadiadarpan kakadiadarpan added the type: question or discussion Issue discussing or asking a question about Gatsby label Oct 9, 2018
@kakadiadarpan kakadiadarpan added type: bug An issue or pull request relating to a bug in Gatsby status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. status: inkteam to review and removed type: question or discussion Issue discussing or asking a question about Gatsby labels Oct 12, 2018
@shanekenney
Copy link
Contributor

@KyleAMathews correct. Terser does take opportunities to use more compact syntax if the ecma version allows it. E.g. Shorthand object properties raised in issue #9034

Here's the test documenting it:
https://github.com/terser-js/terser/blob/master/test/compress/object.js#L111

use_shorthand_opportunity: {
    beautify = {
        ecma: 6
    }
    input: {
        var foo = 123;
        var obj = {foo: foo};
    }
    expect_exact: "var foo=123;var obj={foo};"
}

@KyleAMathews
Copy link
Contributor

Cool! Great to know. Could someone PR a fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

6 participants