@modern-js/module-tools-docs 2.9.0 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @modern-js/module-tools-docs
2
2
 
3
+ ## 2.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f1b2629: feat: add `dts.abortOnError` config
8
+ feat: 添加 `dts.abortOnError` 配置
9
+
10
+ ### Patch Changes
11
+
12
+ - 6118636: fix(module-tools, module-tools-docs): fix svgr usage
13
+ fix(module-tools, module-tools-docs): 修复 svgr 的使用
14
+ - Updated dependencies [210e9d6]
15
+ - Updated dependencies [95dd73e]
16
+ - @modern-js/doc-tools@2.11.0
17
+ - @modern-js/doc-plugin-auto-sidebar@2.11.0
18
+
19
+ ## 2.10.0
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies [c413d79]
24
+ - @modern-js/doc-tools@2.10.0
25
+ - @modern-js/doc-plugin-auto-sidebar@2.10.0
26
+
3
27
  ## 2.9.0
4
28
 
5
29
  ### Patch Changes
@@ -95,6 +95,34 @@ Packaged to handle svg as a React component, options reference [svgr](https://re
95
95
  - type: `boolean | Object`
96
96
  - default: `false`
97
97
 
98
+ When svgr feature is enabled, you can use svg as a component using the default export.
99
+
100
+ ```js index.ts
101
+ // true
102
+ import Logo from './logo.svg';
103
+
104
+ export default () => <Logo />;
105
+ ```
106
+
107
+ :::warning
108
+ The following usage is not currently supported:
109
+
110
+ ```js index.ts
111
+ import { ReactComponent } from './logo.svg';
112
+ ```
113
+ :::
114
+
115
+ When enabled, the type of svg used can be modified by adding a type definition to the `modern-app-env.d.ts` file:
116
+
117
+ ``` ts modern-app-env.d.ts focus=1:3
118
+ declare module '*.svg' {
119
+ const src: React.FunctionComponent<React.SVGProps<SVGSVGElement>>;
120
+ export default src;
121
+ }
122
+
123
+ /// <reference types='@modern-js/module-tools/types' />
124
+ ```
125
+
98
126
  #### include
99
127
 
100
128
  Set the matching svg file
@@ -183,17 +211,30 @@ To prevent excessive global replacement substitution, it is recommended that the
183
211
 
184
212
  ## dts
185
213
 
186
- The dts file generates the relevant configuration, by default it generates
214
+ The dts file generates the relevant configuration, by default it generates.
187
215
 
188
216
  - type: `false | Object`
189
- - default: `{}`
217
+ - default:
190
218
 
191
- ### tsconfigPath
219
+ ``` js
220
+ {
221
+ abortOnError: true,
222
+ distPath: './',
223
+ only: false,
224
+ tsconfigPath: './tsconfig.json',
225
+ }
226
+ ```
192
227
 
193
- Path to the tsconfig file
228
+ ### abortOnError
194
229
 
195
- - type: `string`
196
- - default: `. /tsconfig.json`
230
+ Whether to allow the build to succeed in case of a type error. By default, this will cause the build to fail in case of a type error.
231
+
232
+ :::warning
233
+ When this configuration is turned on, there is no guarantee that the type files will be generated properly and accurately. In `buildType: 'bundle'` or Bundle build mode, the type file must not be generated.
234
+ :::
235
+
236
+ - type: `boolean`
237
+ - default: `true`
197
238
 
198
239
  ### distPath
199
240
 
@@ -209,6 +250,13 @@ Generate only dts files, not js files
209
250
  - type: `boolean`
210
251
  - default: `false`
211
252
 
253
+ ### tsconfigPath
254
+
255
+ Path to the tsconfig file
256
+
257
+ - type: `string`
258
+ - default: `. /tsconfig.json`
259
+
212
260
  ## externals
213
261
 
214
262
  Configure external dependencies that will not be packaged into the final bundle
@@ -98,34 +98,51 @@ export default defineConfig({
98
98
 
99
99
  ### svgr
100
100
 
101
- 打包时将 svg 作为一个 React 组件处理,options 参考 [svgr](https://react-svgr.com/docs/options/),另外还支持了 `include` 和 `exclude` 两个配置项,用于匹配需要处理的 svg 文件。
101
+ 打包时将 SVG 作为一个 React 组件处理,options 参考 [svgr](https://react-svgr.com/docs/options/),另外还支持了 `include` 和 `exclude` 两个配置项,用于匹配需要处理的 SVG 文件。
102
102
 
103
103
  - 类型: `boolean | Object`
104
104
  - 默认值: `false`
105
105
 
106
- :::tip
107
- 开启 svgr 后,仍然使用 default export 导出 svg,所以你只能导入默认值。
106
+ 开启 svgr 功能后,可以使用默认导出的方式将 SVG 当做组件使用。
108
107
 
109
108
  ```js index.ts
110
109
  // true
111
- import logo from './logo.svg';
110
+ import Logo from './logo.svg';
111
+
112
+ export default () => <Logo />;
113
+ ```
114
+
115
+ :::warning
112
116
 
113
- // false
117
+ 目前不支持下面的用法:
118
+
119
+ ```js index.ts
114
120
  import { ReactComponent } from './logo.svg';
115
121
  ```
116
122
 
117
123
  :::
118
124
 
125
+ 当开启功能后,可以通过在 `modern-app-env.d.ts` 文件中增加类型定义,修改使用 SVG 的类型:
126
+
127
+ ``` ts modern-app-env.d.ts focus=1:3
128
+ declare module '*.svg' {
129
+ const src: React.FunctionComponent<React.SVGProps<SVGSVGElement>>;
130
+ export default src;
131
+ }
132
+
133
+ /// <reference types='@modern-js/module-tools/types' />
134
+ ```
135
+
119
136
  #### include
120
137
 
121
- 设定匹配的 svg 文件
138
+ 设定匹配的 SVG 文件
122
139
 
123
140
  - 类型: `string | RegExp | (string | RegExp)[]`
124
141
  - 默认值: `/\.svg$/`
125
142
 
126
143
  #### exclude
127
144
 
128
- 设定不匹配的 svg 文件
145
+ 设定不匹配的 SVG 文件
129
146
 
130
147
  - 类型: `string | RegExp | (string | RegExp)[]`
131
148
  - 默认值: `undefined`
@@ -236,17 +253,30 @@ export default defineConfig({
236
253
 
237
254
  ## dts
238
255
 
239
- 类型文件生成的相关配置,默认会生成。
256
+ 类型文件生成的相关配置,默认情况会生成。
240
257
 
241
258
  - 类型: `false | Object`
242
- - 默认值: `{}`
259
+ - 默认值:
243
260
 
244
- ### tsconfigPath
261
+ ``` js
262
+ {
263
+ abortOnError: true,
264
+ distPath: './',
265
+ only: false,
266
+ tsconfigPath: './tsconfig.json',
267
+ }
268
+ ```
245
269
 
246
- TypeScript 配置文件的路径。
270
+ ### abortOnError
247
271
 
248
- - 类型: `string`
249
- - 默认值: `./tsconfig.json`
272
+ 在出现类型错误的时候,是否允许构建成功。**默认情况下,在出现类型错误的时候会导致构建失败**。
273
+
274
+ :::warning
275
+ 当关闭该配置后,无法保证类型文件能正常生成,且不保证内容正确。在 `buildType: 'bundle'` 或者 Bundle 构建模式下,类型文件一定不会生成。
276
+ :::
277
+
278
+ - 类型:`boolean`
279
+ - 默认值:`true`
250
280
 
251
281
  ### distPath
252
282
 
@@ -262,6 +292,14 @@ TypeScript 配置文件的路径。
262
292
  - 类型: `boolean`
263
293
  - 默认值: `false`
264
294
 
295
+ ### tsconfigPath
296
+
297
+ TypeScript 配置文件的路径。
298
+
299
+ - 类型: `string`
300
+ - 默认值: `./tsconfig.json`
301
+
302
+
265
303
  ## externals
266
304
 
267
305
  配置外部依赖,不会被打包到最终的 bundle 中。
package/package.json CHANGED
@@ -5,15 +5,15 @@
5
5
  "bugs": "https://github.com/web-infra-dev/modern.js/issues",
6
6
  "repository": "web-infra-dev/modern.js",
7
7
  "license": "MIT",
8
- "version": "2.9.0",
8
+ "version": "2.11.0",
9
9
  "main": "index.js",
10
10
  "dependencies": {
11
11
  "@code-hike/mdx": "^0.7.4",
12
12
  "react": "^18.2.0",
13
13
  "react-dom": "^18.2.0",
14
14
  "shiki": "^0.11.1",
15
- "@modern-js/doc-plugin-auto-sidebar": "2.9.0",
16
- "@modern-js/doc-tools": "2.9.0"
15
+ "@modern-js/doc-plugin-auto-sidebar": "2.11.0",
16
+ "@modern-js/doc-tools": "2.11.0"
17
17
  },
18
18
  "scripts": {
19
19
  "dev": "modern dev",