Navigation Menu

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

Add presets to the tree-shaking options #4131

Merged
merged 7 commits into from Jun 16, 2021
Merged

Conversation

lukastaegert
Copy link
Member

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers:

Description

As the number of tree shaking options is growing, this will provide the user to additionally choose from three presets: safest, smallest and recommended.

The differences are that while smallest uses the most aggressive setting everywhere and safest uses the most conservative, recommended will be conservative on most settings but may swallow some syntactic errors. At the moment, it will swallow errors from accessing unknown global variables, but in the future this may extend to accessing const/let variables before they are initialized.

You can use if like this:

export default {
  treeshake: 'safest',
  // ...
} 

There is also an object form that allows using a preset while overriding some values:

export default {
  treeshake: {
    preset: 'smallest',
    propertyReadSideEffects: true
  },
  // ...
} 

From the CLI, you use it like this

rollup -c --treeshake smallest

Using a preset from the CLI will of course override any values in the config file.

@github-actions
Copy link

github-actions bot commented Jun 7, 2021

Thank you for your contribution! ❤️

You can try out this pull request locally by installing Rollup via

npm install rollup/rollup#treeshake-presets

or load it into the REPL:
https://rollupjs.org/repl/?pr=4131

@codecov
Copy link

codecov bot commented Jun 11, 2021

Codecov Report

Merging #4131 (d8ad9ac) into master (7212516) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4131   +/-   ##
=======================================
  Coverage   98.12%   98.13%           
=======================================
  Files         201      201           
  Lines        7090     7114   +24     
  Branches     2074     2081    +7     
=======================================
+ Hits         6957     6981   +24     
  Misses         64       64           
  Partials       69       69           
Impacted Files Coverage Δ
src/rollup/rollup.ts 100.00% <ø> (ø)
src/utils/options/mergeOptions.ts 100.00% <100.00%> (ø)
src/utils/options/normalizeInputOptions.ts 100.00% <100.00%> (ø)
src/utils/options/normalizeOutputOptions.ts 100.00% <100.00%> (ø)
src/utils/options/options.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7212516...d8ad9ac. Read the comment docs.

@lukastaegert lukastaegert merged commit 86e8510 into master Jun 16, 2021
@lukastaegert lukastaegert deleted the treeshake-presets branch June 16, 2021 05:07
alicewriteswrongs added a commit to ionic-team/stencil that referenced this pull request Dec 7, 2022
alicewriteswrongs added a commit to ionic-team/stencil that referenced this pull request Jan 12, 2023
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

Successfully merging this pull request may close these issues.

None yet

1 participant