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

[docs] Adding tree shaking guide for SWC compiler #36456

Closed
wants to merge 4 commits into from

Conversation

nereuseng
Copy link

@nereuseng nereuseng commented Mar 7, 2023

Context

Basically inspired by this PR: #35457.

Signed-off-by: nereuseng <nereuseng@gmail.com>
Signed-off-by: nereuseng <nereuseng@gmail.com>
Signed-off-by: nereuseng <nereuseng@gmail.com>
@mui-bot
Copy link

mui-bot commented Mar 7, 2023

Netlify deploy preview

Bundle size report

No bundle size changes

Generated by 🚫 dangerJS against 679da3c

@nereuseng nereuseng marked this pull request as draft March 8, 2023 02:02
@nereuseng nereuseng marked this pull request as ready for review March 8, 2023 02:03
@zannager zannager added the docs Improvements or additions to the documentation label Mar 8, 2023
@zannager zannager requested a review from mnajdova March 8, 2023 07:05
…ndle-size.md

Signed-off-by: nereuseng <nereuseng@gmail.com>
@mnajdova mnajdova requested review from michaldudak and removed request for mnajdova April 12, 2023 08:12
Copy link
Member

@ZeeshanTamboli ZeeshanTamboli left a 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:
Copy link
Member

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.

Suggested change
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`
Copy link
Member

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?

Comment on lines +225 to +226
test: /\.tsx?$/,
use: [
Copy link
Member

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?

Suggested change
test: /\.tsx?$/,
use: [
test: /\.tsx?$/,
exclude: /(node_modules)/,
use: [

module: {
rules: [
...{
test: /\.tsx?$/,
Copy link
Member

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:

Suggested change
test: /\.tsx?$/,
test: /\.(tsx?|jsx?)$/,

@ZeeshanTamboli
Copy link
Member

Since the PR is inactive from a long time, I am closing this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants