@modern-js/module-tools-docs 2.57.0 → 2.57.1
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
|
@@ -878,6 +878,7 @@ For more information about JSX Transform, you can refer to the following links:
|
|
|
878
878
|
|
|
879
879
|
- [React Blog - Introducing the New JSX Transform](https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html).
|
|
880
880
|
- [esbuild - JSX](https://esbuild.github.io/api/#jsx).
|
|
881
|
+
|
|
881
882
|
:::
|
|
882
883
|
|
|
883
884
|
## metafile
|
|
@@ -978,6 +979,34 @@ export default {
|
|
|
978
979
|
|
|
979
980
|
Custom module resolution options
|
|
980
981
|
|
|
982
|
+
### resolve.alias
|
|
983
|
+
|
|
984
|
+
The basic usage is the same as [alias](#alias).
|
|
985
|
+
|
|
986
|
+
The issue with [alias](#alias) is that we incorrectly handled Module IDs in a bundleless scenario:
|
|
987
|
+
```js
|
|
988
|
+
import { createElement } from "react";
|
|
989
|
+
```
|
|
990
|
+
When we configure alias: `{ react: 'react-native' }`, the result becomes:
|
|
991
|
+
```js
|
|
992
|
+
import { createElement } from "./react-native";
|
|
993
|
+
```
|
|
994
|
+
A Module ID is incorrectly processed as a relative path, which is not expected.
|
|
995
|
+
|
|
996
|
+
We want to fix this issue, but it may break existing projects.
|
|
997
|
+
|
|
998
|
+
Therefore, in **MAJOR_VERSION.58.0**, we provided `resolve.alias` to solve this problem. Additionally, `resolve.alias` removed the default value `{ "@": "./src"}` provided by [alias](#alias).
|
|
999
|
+
|
|
1000
|
+
If you need this feature, please use `resolve.alias`.
|
|
1001
|
+
|
|
1002
|
+
In the next major version, `resolve.alias` will replace [alias](#alias).
|
|
1003
|
+
|
|
1004
|
+
:::warning
|
|
1005
|
+
- Note that this configuration should not be mixed with [alias](#alias).
|
|
1006
|
+
- Ensure that this configuration specifies a relative path, such as `{ "@": "./src" }` rather than `{ "@": "src"}`.
|
|
1007
|
+
|
|
1008
|
+
:::
|
|
1009
|
+
|
|
981
1010
|
### resolve.mainFields
|
|
982
1011
|
|
|
983
1012
|
A list of fields in package.json to try when parsing the package entry point.
|
|
@@ -968,6 +968,33 @@ export default {
|
|
|
968
968
|
|
|
969
969
|
自定义模块解析选项
|
|
970
970
|
|
|
971
|
+
### resolve.alias
|
|
972
|
+
|
|
973
|
+
基本用法和 [alias](#alias) 一致。
|
|
974
|
+
|
|
975
|
+
[alias](#alias) 的问题在于我们在 bundleless 场景下错误的处理了 Module ID 的情况:
|
|
976
|
+
```js
|
|
977
|
+
import { createElement } from "react";
|
|
978
|
+
```
|
|
979
|
+
当我们配置了 `alias: { react: 'react-native' }` 后,结果会变成
|
|
980
|
+
```js
|
|
981
|
+
import { createElement } from "./react-native";
|
|
982
|
+
```
|
|
983
|
+
一个 Module ID 被错误的处理成了相对路径,显然这是不符合预期的。
|
|
984
|
+
|
|
985
|
+
我们想要修复这个问题,但是这可能会破坏已有的项目,因此我们在 MAJOR_VERSION.58.0 版本提供了 `resolve.alias` 来解决这个问题。
|
|
986
|
+
并且 `resolve.alias` 里移除了 [alias](#alias) 提供的默认值 `{ "@": "./src"}`
|
|
987
|
+
|
|
988
|
+
如果你需要此功能,请使用 `resolve.alias`。
|
|
989
|
+
|
|
990
|
+
在下一个大版本,`resolve.alias` 将会取代 `alias` 。
|
|
991
|
+
|
|
992
|
+
:::warning
|
|
993
|
+
- 注意此配置不要与 [alias](#alias) 混用。
|
|
994
|
+
- 注意此配置必须标注一个相对路径,例如 `{ "@": "./src" }` 而非 `{ "@": "src"}`。
|
|
995
|
+
|
|
996
|
+
:::
|
|
997
|
+
|
|
971
998
|
### resolve.mainFields
|
|
972
999
|
|
|
973
1000
|
package.json 中,在解析包的入口点时尝试的字段列表。
|
|
@@ -1595,4 +1622,6 @@ export default defineConfig({
|
|
|
1595
1622
|
},
|
|
1596
1623
|
},
|
|
1597
1624
|
});
|
|
1598
|
-
```
|
|
1625
|
+
```import { aliases } from '../../../../../../toolkit/utils/dist/compiled/browserslist';
|
|
1626
|
+
import { createElement } from 'react';
|
|
1627
|
+
|
package/package.json
CHANGED
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
"directory": "packages/document/module-doc"
|
|
10
10
|
},
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"version": "2.57.
|
|
12
|
+
"version": "2.57.1",
|
|
13
13
|
"main": "index.js",
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"react": "^18.2.0",
|
|
16
16
|
"react-dom": "^18.2.0",
|
|
17
17
|
"rspress": "1.26.1",
|
|
18
18
|
"@rspress/shared": "1.26.1",
|
|
19
|
-
"@modern-js/doc-plugin-auto-sidebar": "2.57.
|
|
19
|
+
"@modern-js/doc-plugin-auto-sidebar": "2.57.1"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
22
|
"dev": "rspress dev",
|