@modern-js/main-doc 2.62.0 → 2.63.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,10 +8,12 @@ configName: output.sourceMap
8
8
  - **Type:**
9
9
 
10
10
  ```ts
11
- type SourceMap = {
12
- js?: Rspack.Configuration['devtool'];
13
- css?: boolean;
14
- };
11
+ type SourceMap =
12
+ | boolean
13
+ | {
14
+ js?: Rspack.Configuration['devtool'];
15
+ css?: boolean;
16
+ };
15
17
  ```
16
18
 
17
19
  - **Default:**
@@ -11,6 +11,7 @@ Transform the import path, which can be used to modularly import the subpath of
11
11
 
12
12
  ```ts
13
13
  type TransformImport =
14
+ | false
14
15
  | Array<{
15
16
  libraryName: string;
16
17
  libraryDirectory?: string;
@@ -61,3 +62,29 @@ When you add configurations for `antd` or `@arco-design/web-react`, the priority
61
62
  import RsbuildConig from '@site-docs-en/components/rsbuild-config-tooltip';
62
63
 
63
64
  <RsbuildConig />
65
+
66
+ ### Disable Default Config
67
+
68
+ You can manually set `transformImport: false` to disable the default config.
69
+
70
+ ```js
71
+ export default {
72
+ source: {
73
+ transformImport: false,
74
+ },
75
+ };
76
+ ```
77
+
78
+ You can also use the [function usage](https://rsbuild.dev/config/source/transform-import#function-type) of `transformImport` to modify the default configuration.
79
+
80
+ ```js
81
+ export default {
82
+ source: {
83
+ transformImport: (imports) => {
84
+ return imports.filter(data => data.libraryName !== 'antd');
85
+ },
86
+ },
87
+ };
88
+ ```
89
+
90
+ For example, if you use `externals` to avoid bundling antd, because `transformImport` will convert the imported path of antd by default, the matching path changes and externals cannot take effect. At this time, you can disable `transformImport` to avoid this problem.
@@ -8,10 +8,12 @@ configName: output.sourceMap
8
8
  - **类型:**
9
9
 
10
10
  ```ts
11
- type SourceMap = {
12
- js?: Rspack.Configuration['devtool'];
13
- css?: boolean;
14
- };
11
+ type SourceMap =
12
+ | boolean
13
+ | {
14
+ js?: Rspack.Configuration['devtool'];
15
+ css?: boolean;
16
+ };
15
17
  ```
16
18
 
17
19
  - **默认值:**
@@ -11,6 +11,7 @@ configName: source.transformImport
11
11
 
12
12
  ```ts
13
13
  type TransformImport =
14
+ | false
14
15
  | Array<{
15
16
  libraryName: string;
16
17
  libraryDirectory?: string;
@@ -61,3 +62,29 @@ const defaultArcoConfig = [
61
62
  import RsbuildConig from '@site-docs/components/rsbuild-config-tooltip';
62
63
 
63
64
  <RsbuildConig />
65
+
66
+ ### 禁用默认配置
67
+
68
+ 你可以手动设置 `transformImport: false` 来关掉 transformImport 的默认行为。
69
+
70
+ ```js
71
+ export default {
72
+ source: {
73
+ transformImport: false,
74
+ },
75
+ };
76
+ ```
77
+
78
+ 你也可以使用 `transformImport` 的 [function 用法](https://rsbuild.dev/zh/config/source/transform-import#function-%E7%B1%BB%E5%9E%8B) 对默认配置进行自定义修改。
79
+
80
+ ```js
81
+ export default {
82
+ source: {
83
+ transformImport: (imports) => {
84
+ return imports.filter(data => data.libraryName !== 'antd');
85
+ },
86
+ },
87
+ };
88
+ ```
89
+
90
+ 比如,当你使用了 `externals` 来避免打包 antd 时,由于 `transformImport` 默认会转换 antd 的引用路径,导致匹配的路径发生了变化,因此 externals 无法正确生效,此时你可以设置关闭 `transformImport` 来避免该问题。
package/package.json CHANGED
@@ -15,14 +15,14 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.62.0",
18
+ "version": "2.63.0",
19
19
  "publishConfig": {
20
20
  "registry": "https://registry.npmjs.org/",
21
21
  "access": "public",
22
22
  "provenance": true
23
23
  },
24
24
  "dependencies": {
25
- "@modern-js/sandpack-react": "2.62.0"
25
+ "@modern-js/sandpack-react": "2.63.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@rspress/shared": "1.35.4",