@modern-js/module-tools-docs 2.49.0 → 2.49.2
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,15 @@
|
|
|
1
1
|
# @modern-js/module-tools-docs
|
|
2
2
|
|
|
3
|
+
## 2.49.2
|
|
4
|
+
|
|
5
|
+
## 2.49.1
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- bfba084: docs: bump Rspress v1.18.2 and remove dividers
|
|
10
|
+
- 4d5d222: docs(module-doc): align `define` description to actual behavior
|
|
11
|
+
docs(module-doc): 对齐 `define` 的文档描述和实际行为一致
|
|
12
|
+
|
|
3
13
|
## 2.49.0
|
|
4
14
|
|
|
5
15
|
## 2.48.6
|
|
@@ -376,16 +376,23 @@ Define global variables that will be injected into the code
|
|
|
376
376
|
- **Type**: `Record<string, string>`
|
|
377
377
|
- **Default**: `{}`
|
|
378
378
|
|
|
379
|
-
Since the `define` function is implemented by global text replacement, you need to ensure that the global variable values are strings. A safer approach is to convert the value of each global variable to a string,
|
|
379
|
+
Since the `define` function is implemented by global text replacement, you need to ensure that the global variable values are strings. A safer approach is to convert the value of each global variable to a string, as follows.
|
|
380
|
+
|
|
381
|
+
:::info
|
|
382
|
+
Modern.js automatically performs JSON serialization handling internally, so manual serialization is not required.
|
|
383
|
+
|
|
384
|
+
If automatic serialization is not needed, you can define [`alias`](https://esbuild.github.io/api/#alias) using [`esbuildOptions`](/api/config/build-config.html#esbuildoptions) configuration.
|
|
385
|
+
|
|
386
|
+
:::
|
|
380
387
|
|
|
381
388
|
```js title="modern.config.ts"
|
|
382
|
-
export default {
|
|
389
|
+
export default defineConfig({
|
|
383
390
|
buildConfig: {
|
|
384
391
|
define: {
|
|
385
|
-
VERSION:
|
|
392
|
+
VERSION: require('./package.json').version || '0.0.0',
|
|
386
393
|
},
|
|
387
394
|
},
|
|
388
|
-
};
|
|
395
|
+
});
|
|
389
396
|
```
|
|
390
397
|
|
|
391
398
|
If the project is a TypeScript project, then you may need to add the following to the `.d.ts` file in the project source directory.
|
|
@@ -403,7 +410,7 @@ import { defineConfig } from '@modern-js/module-tools';
|
|
|
403
410
|
export default defineConfig({
|
|
404
411
|
buildConfig: {
|
|
405
412
|
define: {
|
|
406
|
-
'process.env.VERSION':
|
|
413
|
+
'process.env.VERSION': process.env.VERSION || '0.0.0',
|
|
407
414
|
},
|
|
408
415
|
},
|
|
409
416
|
});
|
|
@@ -369,13 +369,19 @@ type Options = {
|
|
|
369
369
|
- 类型: `Record<string, string>`
|
|
370
370
|
- 默认值: `{}`
|
|
371
371
|
|
|
372
|
-
由于 `define`
|
|
372
|
+
由于 `define` 功能是由全局文本替换实现的,所以需要保证全局变量值为字符串,更为安全的做法是将每个全局变量的值转化为字符串,如下所示:
|
|
373
|
+
|
|
374
|
+
:::info
|
|
375
|
+
框架内部会自动进行 JSON 序列化处理,因此不需要手动执行序列化。
|
|
376
|
+
|
|
377
|
+
如果不需要自动序列化,可以通过配置 [`esbuildOptions`](/api/config/build-config.html#esbuildoptions) 定义 [`alias`](https://esbuild.github.io/api/#alias) 来实现。
|
|
378
|
+
:::
|
|
373
379
|
|
|
374
380
|
```js title="modern.config.ts"
|
|
375
381
|
export default defineConfig({
|
|
376
382
|
buildConfig: {
|
|
377
383
|
define: {
|
|
378
|
-
VERSION:
|
|
384
|
+
VERSION: require('./package.json').version || '0.0.0',
|
|
379
385
|
},
|
|
380
386
|
},
|
|
381
387
|
});
|
|
@@ -396,7 +402,7 @@ import { defineConfig } from '@modern-js/module-tools';
|
|
|
396
402
|
export default defineConfig({
|
|
397
403
|
buildConfig: {
|
|
398
404
|
define: {
|
|
399
|
-
'process.env.VERSION':
|
|
405
|
+
'process.env.VERSION': process.env.VERSION || '0.0.0',
|
|
400
406
|
},
|
|
401
407
|
},
|
|
402
408
|
});
|
package/package.json
CHANGED
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
"directory": "packages/document/module-doc"
|
|
10
10
|
},
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"version": "2.49.
|
|
12
|
+
"version": "2.49.2",
|
|
13
13
|
"main": "index.js",
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"react": "^18.2.0",
|
|
16
16
|
"react-dom": "^18.2.0",
|
|
17
|
-
"rspress": "1.
|
|
18
|
-
"@rspress/shared": "1.
|
|
19
|
-
"@modern-js/doc-plugin-auto-sidebar": "2.49.
|
|
17
|
+
"rspress": "1.18.2",
|
|
18
|
+
"@rspress/shared": "1.18.2",
|
|
19
|
+
"@modern-js/doc-plugin-auto-sidebar": "2.49.2"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
22
|
"dev": "rspress dev",
|