Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Automatically set module: true for the esm format #22

Merged
merged 1 commit into from
Jan 1, 2019
Merged

Automatically set module: true for the esm format #22

merged 1 commit into from
Jan 1, 2019

Conversation

NotWoods
Copy link
Contributor

@NotWoods NotWoods commented Jan 1, 2019

Terser has a special option module for minifying ES modules:

  • module (default false) — Use when minifying an ES6 module. "use strict"
    is implied and names can be mangled on the top scope. If compress or
    mangle is enabled then the toplevel option will be enabled.

This change updates the plugin so that if the "esm" output format is detected, the module flag is turned on by default.

Since multiple output formats can be set, the serialized minifierOptions has been split into two separate variables - one for format: 'es' and one for other formats. The serialized versions are created lazily so that if only 1 format is used, only 1 variable will be set.

Thanks to this change, the "works with code splitting" test now creates smaller code since the strings can be inlined.

@TrySound
Copy link
Owner

TrySound commented Jan 1, 2019

Could you rebase from master and update tests?

@TrySound TrySound merged commit 35f96b3 into TrySound:master Jan 1, 2019
@TrySound
Copy link
Owner

TrySound commented Jan 1, 2019

Thanks! Nice feature

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

Successfully merging this pull request may close these issues.

None yet

2 participants