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

chore(package.json): Add sideEffects: false field in package.json #8099

Merged
merged 1 commit into from
May 2, 2018

Conversation

TheLarkInn
Copy link
Contributor

@TheLarkInn TheLarkInn commented Apr 28, 2018

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe: package.json field addition

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

This PR adds the "sideEffects": false property in vue's package.json file. This allow's webpack (for those who want to opt-in to requiring vue's original source files (instead of the flattened esm bundles) and want to remove flow type through a babel-transform, then this will allow webpack to aggressively ignore and treeshake unused exports throughout the module system.

In many cases this can yield hidden and surprising build time improvements and size reductions in the case that modules flattened from rollup aren't actually needed when webpack performs a scope analysis.

The angular team has adopted this approach for the CLI yielding some strong build time speed for webpack (since unused exports are also not resolved, parsed, etc.). From my assessment of the module graph created, it looks that there are no sideEffects created against existing re-exports throughout the codebase, therefore even if a user did opt in on their own will, and remove flow types, there should be no danger of removing code that is needed and causing breakages.

Overall, this already will not be a breaking change in any way but just provides extra benefits to those (and for the cli (if realized) when using webpack 4 and mode: production).

Happy to answer any other questions.
~Sean + webpack team

Other information:

This PR adds the sideEffects: false property in vue's package.json file. This allow's webpack (for
those who want to opt in to requiring vue's original source files (instead of the flattened
@lukepolo
Copy link

This is awesome thanks for this!

@silltho
Copy link

silltho commented Jun 18, 2018

Hy Sean!

Could you please specify what you mean by "vue's original source files"?

I looked at the index.js file in the src/core folder and to my knowledge there are plenty sideeffects that would be prune away by tree shaking. (e.g Object.defineProperty)

I hope you can help me understand how this works.
Thomas

@TheLarkInn
Copy link
Contributor Author

Everything can be answered here for you. side effects doesn't mean the same as it does exactly in functional programming. https://stackoverflow.com/questions/49160752/what-does-webpack-4-expect-from-a-package-with-sideeffects-false

awamwang added a commit to awamwang/vue that referenced this pull request Jul 8, 2018
* vuejs-dev: (558 commits)
  chore: sponsors
  chore: update sponsors
  chore: update sponsors
  chore: sponsor cleanup
  chore: update sponsors
  chore(package.json): Add sideEffects: false field in package.json (vuejs#8099)
  chore: new sponsor
  chore(typo): no dots at the end of the comments (vuejs#8087)
  chore: new sponsor
  chore: update sponsors
  chore: update sponsors
  chore: use reactive components count in benchmark (vuejs#7996)
  feat(weex): support object syntax of class (vuejs#7930)
  feat(server, webpack-plugin): webpack 4 support (vuejs#7839)
  fix(ssr): render initial and used async css chunks (vuejs#7902)
  fix(ssr): remove trailing hash in webpack module identifier when generating client manifest
  chore: new sponsor
  chore: update sponsor
  build: release 2.5.17-beta.0
  build: build 2.5.17-beta.0
  ...
@pdufour
Copy link

pdufour commented Oct 22, 2018

I've noticed this still isn't in the latest release. https://github.com/vuejs/vue/blob/v2.5.17/package.json. When is this merge expected to be released in Vue.js?

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.

5 participants