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
[docs] Adding tree shaking guide for SWC compiler #36456
Conversation
Signed-off-by: nereuseng <nereuseng@gmail.com>
Signed-off-by: nereuseng <nereuseng@gmail.com>
Signed-off-by: nereuseng <nereuseng@gmail.com>
Netlify deploy previewBundle size report |
docs/data/material/guides/minimizing-bundle-size/minimizing-bundle-size.md
Outdated
Show resolved
Hide resolved
…ndle-size.md Signed-off-by: nereuseng <nereuseng@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please create a minimal repository to demonstrate that the configurations work effectively with tree shaking enabled?
|
||
`yarn add -D @swc/plugin-transform-imports` | ||
|
||
Modify your .swcrc or Webpack configuration: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Below we are showing the config for Webpack, so mentioning .swcrc
here may confuse devs. It would be better to show a separate config for .swcrc
.
Modify your .swcrc or Webpack configuration: | |
Modify your webpack configuration as shown below: |
|
||
This option pretty much similar to the option two, except for the developer who is using [SWC Compiler](https://swc.rs/). Use this [plugin](https://github.com/swc-project/plugins/blob/main/packages/transform-imports/README.md): | ||
|
||
`yarn add -D @swc/plugin-transform-imports` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we also need @swc/core
and swc-loader
dependencies?
test: /\.tsx?$/, | ||
use: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we exclude node_modules
?
test: /\.tsx?$/, | |
use: [ | |
test: /\.tsx?$/, | |
exclude: /(node_modules)/, | |
use: [ |
module: { | ||
rules: [ | ||
...{ | ||
test: /\.tsx?$/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include Javascript files as well:
test: /\.tsx?$/, | |
test: /\.(tsx?|jsx?)$/, |
Since the PR is inactive from a long time, I am closing this PR. |
Context
Basically inspired by this PR: #35457.