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

Closure compiler artifacts left in the minified bundle #56

Closed
Andarist opened this issue Sep 11, 2018 · 10 comments
Closed

Closure compiler artifacts left in the minified bundle #56

Andarist opened this issue Sep 11, 2018 · 10 comments
Assignees

Comments

@Andarist
Copy link
Contributor

Andarist commented Sep 11, 2018

Repro can be found in this PR, you can check out complete output in my comment here.

Basically what I see are things like some kind of scope object gathering properties like

  • ASSUME_ES5
  • ASSUME_NO_NATIVE_MAP
  • ASSUME_NO_NATIVE_SET
  • getGlobal
  • SYMBOL_PREFIX
  • initSymbol
  • Symbol
  • ... and others.

I understand that this can be disabled with language_out: 'ECMASCRIPT_2015', but I'm wondering why this is not added in CJS case but is added for ESM? Could this be prevented altogether in the plugin itself? Without adding extra config like the mentioned language_out?

cc @TrySound

@kristoferbaxter kristoferbaxter self-assigned this Sep 17, 2018
@kristoferbaxter
Copy link
Contributor

Taking a look at this. Will respond back by EOD tomorrow with changes or a clarification.

@kristoferbaxter
Copy link
Contributor

@Andarist Is it possible to get a smaller reproduction? Perhaps something with just the input that is expected to be minified with the options used?

@Andarist
Copy link
Contributor Author

I'll try to extract one in following days.

@Andarist
Copy link
Contributor Author

Andarist commented Sep 19, 2018

Here you go - https://github.com/Andarist/rollup-closure-symbol-repro

Couldn't repro it for a while because changing a function declaration to an arrow function expression causes the "polyfill bloat" to be added to both, keeping it as function declaration doesn't add the bloat to cjs output but adds it to esm.

EDIT:// some options passed to the closure plugin are irrelevant, dont have time to slim it down further now, those are exact options used by react

@kristoferbaxter
Copy link
Contributor

Taking a look. Thank you so much!

@kristoferbaxter
Copy link
Contributor

kristoferbaxter commented Sep 19, 2018

The issue for this particular example appears to be in transpilation of the export, which isn't removed (but we do add a statement to ensure the name isn't mangled so the export can be repaired after Closure Compiler is finished).

Transpilation is triggered in this example because the source is indicated to be exported as ES5.

Going to remove the export statements, and try to resolve.

@kristoferbaxter
Copy link
Contributor

Released 0.7.0 with the change. However, NPM went down right afterwards.

@kristoferbaxter
Copy link
Contributor

kristoferbaxter commented Sep 20, 2018

@Andarist – Confirmed fixed with 0.7.1.

@TrySound
Copy link
Contributor

Great job! Thanks

@Andarist
Copy link
Contributor Author

Cool! Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants