8000 add FAQ · coder-xiaotian/swc-useclient@3e9ec21 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3e9ec21

Browse files
add FAQ
1 parent ba4f1fa commit 3e9ec21

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

README-ZH.md

Expand all lines: README-ZH.md
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,31 @@ swc配置:
5454
}
5555
}
5656
```
57+
58+
## 常见问题
59+
60+
+ swc 插件打断了tree shaking
61+
62+
目前这是一个意料之中的行为,[next团队会在未来改进它](https://github.com/vercel/next.js/issues/52679#issuecomment-1636807256)。可以通过配置modularizeImports暂时解决这个问题:
63+
```javascript
64+
const nextConfig = {
65+
modularizeImports: {
66+
"@mui/material": {
67+
transform: "@mui/material/{{member}}"
68+
},
69+
},
70+
experimental: {
71+
swcPlugins: [
72+
[
73+
"use-client",
74+
{
75+
include: ["@mui/material"],
76+
},
77+
],
78+
],
79+
},
80+
};
81+
```
82+
注意有些函数是不遵循`@mui/material/{{member}}`规则的,比如:createTheme、ThemeProvider,需要单独处理成这样`import { createTheme, ThemeProvider } from "@mui/material/styles`
83+
84+
🌟🌟🌟🌟如果这个插件对您有用的话,就给作者一个star吧。🙏🙏🙏🌟🌟🌟🌟

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,31 @@ swc configuration:
6666
}
6767
}
6868
```
69+
70+
## FAQ
71+
72+
+ The swc plugin interrupts tree shaking
73+
74+
At present, this is an expected behavior, [The Next.js team will improve it in the future](https://github.com/vercel/next.js/issues/52679#issuecomment-1636807256)。You can temporarily solve this problem by configuring modularizeImports:
75+
```javascript
76+
const nextConfig = {
77+
modularizeImports: {
78+
"@mui/material": {
79+
transform: "@mui/material/{{member}}"
80+
},
81+
},
82+
experimental: {
83+
swcPlugins: [
84+
[
85+
"use-client",
86+
{
87+
include: ["@mui/material"],
88+
},
89+
],
90+
],
91+
},
92+
};
93+
```
94+
Note that some functions do not follow the '@ mui/material/{{member}}' rule, such as createTheme and ThemeProvider, which need to be processed separately as' import {createTheme, ThemeProvider} from '@ mui/material/styles'`
95+
96+
🌟🌟🌟🌟 If this plugin is helpful to you, give the author a star.🙏🙏🙏🌟🌟🌟🌟

0 commit comments

Comments
 (0)
0