Skip to content

Commit

Permalink
Update tree-shaking.mdx
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoxiaojx authored Jan 11, 2024
1 parent c93667b commit d82ef52
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/content/guides/tree-shaking.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ What we've learned is that in order to take advantage of _tree shaking_, you mus
- Use ES2015 module syntax (i.e. `import` and `export`).
- Ensure no compilers transform your ES2015 module syntax into CommonJS modules (this is the default behavior of the popular Babel preset @babel/preset-env - see the [documentation](https://babeljs.io/docs/en/babel-preset-env#modules) for more details).
- Add a `"sideEffects"` property to your project's `package.json` file.
- Use the [`production`](/configuration/mode/#mode-production) `mode` configuration option to enable tree shaking (This is required when webpack version is less than 5.3.0).
- Use the [`production`](/configuration/mode/#mode-production) `mode` configuration option to enable [various optimizations](/configuration/mode/#usage) including minification and tree shaking (side effects optimization is enabled in development mode using the flag value).
- Make sure you set a correct value for [`devtool`](/configuration/devtool/#devtool) as some of them can't be used in `production` mode.

You can imagine your application as a tree. The source code and libraries you actually use represent the green, living leaves of the tree. Dead code represents the brown, dead leaves of the tree that are consumed by autumn. In order to get rid of the dead leaves, you have to shake the tree, causing them to fall.
Expand Down

0 comments on commit d82ef52

Please sign in to comment.