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

Deprecate hasModuleSideEffects in favor of moduleSideEffects and ensure it is mutable on ModuleInfo #4379

Merged
merged 2 commits into from Feb 2, 2022

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

This fixes an inconsistency in the naming i.e. we are using the moduleSideEffects option in the resolveId, load and transform hooks, but on ModuleInfo it is called hasModuleSideEffects. This becomes more problematic if you want to change this property explicitly on ModuleInfo.

This PR does several things:

  • Add a new property moduleSideEffects on ModuleInfo (e.g. via this.getModuleInfo()) that takes the role of hasModuleSideEffects
  • Add a deprecation warning when explicitly accessing hasModuleSideEffects and strictDeprecations is true
  • Make hasModuleSideEffects non-enumerable to avoid accidentally triggering the warning and basically hide the old option (though it still works to prevent breaking changes)
  • Ensure that moduleSideEffects can be written during build time, which is important if you write e.g. an entry point proxy plugin that needs to set this flag to true for the original entry point (I also updated the inject-polyfill example in the docs to reflects this)

@github-actions
Copy link

github-actions bot commented Feb 1, 2022

Thank you for your contribution! ❤️

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

npm install rollup/rollup#mutable-module-side-effects

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

@codecov
Copy link

codecov bot commented Feb 1, 2022

Codecov Report

Merging #4379 (62abf0e) into master (d57cfa0) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4379   +/-   ##
=======================================
  Coverage   98.72%   98.72%           
=======================================
  Files         205      205           
  Lines        7311     7318    +7     
  Branches     2083     2083           
=======================================
+ Hits         7218     7225    +7     
  Misses         34       34           
  Partials       59       59           
Impacted Files Coverage Δ
src/Chunk.ts 100.00% <ø> (ø)
src/utils/traverseStaticDependencies.ts 100.00% <ø> (ø)
src/ExternalModule.ts 100.00% <100.00%> (ø)
src/Graph.ts 100.00% <100.00%> (ø)
src/Module.ts 100.00% <100.00%> (ø)
src/ModuleLoader.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 d57cfa0...62abf0e. Read the comment docs.

@lukastaegert lukastaegert merged commit e0b1060 into master Feb 2, 2022
@lukastaegert lukastaegert deleted the mutable-module-side-effects branch February 2, 2022 05:54
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