@modern-js/runtime 2.0.0-beta.4 → 2.0.0-beta.6
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 +133 -0
- package/dist/js/modern/document/Body.js +2 -2
- package/dist/js/modern/document/DocumentStructrueContext.js +2 -1
- package/dist/js/modern/document/Head.js +3 -1
- package/dist/js/modern/document/Html.js +2 -0
- package/dist/js/modern/document/Links.js +10 -0
- package/dist/js/modern/document/Root.js +1 -1
- package/dist/js/modern/document/cli/index.js +8 -2
- package/dist/js/modern/document/constants.js +4 -0
- package/dist/js/modern/document/index.js +1 -0
- package/dist/js/modern/router/cli/index.js +7 -9
- package/dist/js/modern/router/runtime/index.js +1 -0
- package/dist/js/modern/router/runtime/plugin.node.js +3 -3
- package/dist/js/modern/router/runtime/utils.js +8 -4
- package/dist/js/modern/ssr/cli/index.js +2 -2
- package/dist/js/node/cli/index.js +13 -11
- package/dist/js/node/common.js +7 -3
- package/dist/js/node/core/app-config.js +8 -3
- package/dist/js/node/core/compatible.js +41 -37
- package/dist/js/node/core/index.js +17 -6
- package/dist/js/node/core/loader/index.js +7 -3
- package/dist/js/node/core/loader/loaderManager.js +19 -14
- package/dist/js/node/core/loader/useLoader.js +22 -22
- package/dist/js/node/core/plugin.js +17 -10
- package/dist/js/node/document/Body.js +8 -4
- package/dist/js/node/document/DocumentContext.js +7 -3
- package/dist/js/node/document/DocumentStructrueContext.js +9 -4
- package/dist/js/node/document/Head.js +11 -4
- package/dist/js/node/document/Html.js +9 -3
- package/dist/js/node/document/Links.js +33 -0
- package/dist/js/node/document/Root.js +9 -4
- package/dist/js/node/document/Script.js +7 -3
- package/dist/js/node/document/Scripts.js +7 -3
- package/dist/js/node/document/cli/index.js +35 -30
- package/dist/js/node/document/constants.js +25 -3
- package/dist/js/node/document/index.js +12 -11
- package/dist/js/node/exports/head.js +6 -4
- package/dist/js/node/exports/loadable.js +6 -4
- package/dist/js/node/exports/server.js +7 -3
- package/dist/js/node/exports/styled.js +6 -4
- package/dist/js/node/index.js +15 -3
- package/dist/js/node/router/cli/index.js +29 -31
- package/dist/js/node/router/index.js +8 -4
- package/dist/js/node/router/runtime/DefaultNotFound.js +7 -3
- package/dist/js/node/router/runtime/index.js +10 -5
- package/dist/js/node/router/runtime/plugin.js +27 -22
- package/dist/js/node/router/runtime/plugin.node.js +40 -37
- package/dist/js/node/router/runtime/root/index.js +7 -3
- package/dist/js/node/router/runtime/root/load.js +14 -8
- package/dist/js/node/router/runtime/server.js +3 -3
- package/dist/js/node/router/runtime/types.js +15 -0
- package/dist/js/node/router/runtime/utils.js +48 -38
- package/dist/js/node/router/runtime/withRouter.js +24 -22
- package/dist/js/node/runtime-context.js +8 -3
- package/dist/js/node/ssr/cli/babel-plugin-ssr-loader-id.js +109 -128
- package/dist/js/node/ssr/cli/index.js +21 -21
- package/dist/js/node/ssr/index.js +34 -32
- package/dist/js/node/ssr/index.node.js +30 -28
- package/dist/js/node/ssr/prefetch.js +11 -9
- package/dist/js/node/ssr/react/index.js +8 -3
- package/dist/js/node/ssr/react/nossr/index.js +7 -3
- package/dist/js/node/ssr/react/prerender/index.js +24 -22
- package/dist/js/node/ssr/react/prerender/type.js +15 -0
- package/dist/js/node/ssr/react/prerender/util.js +11 -3
- package/dist/js/node/ssr/react/withCallback/index.js +7 -3
- package/dist/js/node/ssr/serverRender/helmet.js +5 -3
- package/dist/js/node/ssr/serverRender/index.js +8 -6
- package/dist/js/node/ssr/serverRender/renderToStream/buildTemplate.after.js +7 -3
- package/dist/js/node/ssr/serverRender/renderToStream/buildTemplate.share.js +8 -3
- package/dist/js/node/ssr/serverRender/renderToStream/bulidTemplate.before.js +7 -3
- package/dist/js/node/ssr/serverRender/renderToStream/index.js +14 -10
- package/dist/js/node/ssr/serverRender/renderToStream/loadable.js +7 -3
- package/dist/js/node/ssr/serverRender/renderToStream/renderToPipe.js +22 -22
- package/dist/js/node/ssr/serverRender/renderToStream/styledComponent.js +7 -3
- package/dist/js/node/ssr/serverRender/renderToStream/template.js +7 -3
- package/dist/js/node/ssr/serverRender/renderToStream/type.js +15 -0
- package/dist/js/node/ssr/serverRender/renderToString/entry.js +19 -17
- package/dist/js/node/ssr/serverRender/renderToString/index.js +13 -9
- package/dist/js/node/ssr/serverRender/renderToString/loadable.js +7 -3
- package/dist/js/node/ssr/serverRender/renderToString/reduce.js +7 -3
- package/dist/js/node/ssr/serverRender/renderToString/styledComponent.js +7 -3
- package/dist/js/node/ssr/serverRender/renderToString/template.js +8 -3
- package/dist/js/node/ssr/serverRender/renderToString/type.js +7 -3
- package/dist/js/node/ssr/serverRender/types.js +7 -3
- package/dist/js/node/ssr/serverRender/utils.js +8 -3
- package/dist/js/node/ssr/utils.js +25 -19
- package/dist/js/node/state/cli/index.js +5 -3
- package/dist/js/node/state/index.js +8 -4
- package/dist/js/node/state/plugins.js +10 -3
- package/dist/js/node/state/runtime/index.js +10 -5
- package/dist/js/node/state/runtime/plugin.js +23 -23
- package/dist/js/node/state/types.js +15 -0
- package/dist/js/treeshaking/document/Body.js +2 -2
- package/dist/js/treeshaking/document/DocumentStructrueContext.js +2 -1
- package/dist/js/treeshaking/document/Head.js +3 -1
- package/dist/js/treeshaking/document/Html.js +2 -0
- package/dist/js/treeshaking/document/Links.js +8 -0
- package/dist/js/treeshaking/document/Root.js +1 -1
- package/dist/js/treeshaking/document/cli/index.js +9 -4
- package/dist/js/treeshaking/document/constants.js +2 -1
- package/dist/js/treeshaking/document/index.js +1 -0
- package/dist/js/treeshaking/router/cli/index.js +7 -9
- package/dist/js/treeshaking/router/runtime/index.js +1 -0
- package/dist/js/treeshaking/router/runtime/plugin.node.js +2 -2
- package/dist/js/treeshaking/router/runtime/utils.js +8 -4
- package/dist/js/treeshaking/ssr/cli/index.js +2 -2
- package/dist/types/document/DocumentStructrueContext.d.ts +1 -0
- package/dist/types/document/Links.d.ts +2 -0
- package/dist/types/document/constants.d.ts +1 -0
- package/dist/types/document/index.d.ts +1 -0
- package/dist/types/router/runtime/index.d.ts +1 -0
- package/dist/types/router/runtime/types.d.ts +1 -1
- package/package.json +18 -15
- package/types/index.d.ts +2 -2
- package/types/router.d.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,138 @@
|
|
|
1
1
|
# @modern-js/runtime
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.6
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- dda38c9c3e: chore: v2
|
|
8
|
+
|
|
9
|
+
### Minor Changes
|
|
10
|
+
|
|
11
|
+
- c9e800d39a: feat: support React18 streaming SSR
|
|
12
|
+
feat: 支持 React18 流式 SSR
|
|
13
|
+
- df7ee2d: feat: runtime user config types extends
|
|
14
|
+
feat: runtime 用户配置类型扩展
|
|
15
|
+
- 543be9558e: feat: compile server loader and support handle loader request
|
|
16
|
+
feat: 编译 server loader 并支持处理 loader 的请求
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 2344eb26ed: fix: bootstrap function params type define
|
|
21
|
+
|
|
22
|
+
fix: 修复 bootstrap 函数参数类型定义
|
|
23
|
+
|
|
24
|
+
- a11fcf8b50: feat: fallback logic of streaming ssr
|
|
25
|
+
feat: streaming ssr 降级逻辑
|
|
26
|
+
- a93159440e: feat: support modify routes for csr app
|
|
27
|
+
feat: 支持 modifyRoutes API
|
|
28
|
+
- e7ce0636d1: fix: root layout css chunks should't be loaded
|
|
29
|
+
fix: 不应该加载 root layout 的 css chunks
|
|
30
|
+
- b18fa8f3ed: feat: remove @loadable/component in streaming ssr
|
|
31
|
+
feat: 移除 streaming ssr 中的 @loadable/component 逻辑
|
|
32
|
+
- 50d4675e5b: fix: add document cli export
|
|
33
|
+
|
|
34
|
+
fix: 增加 document cli 插件的导出
|
|
35
|
+
|
|
36
|
+
- 6604f1b8b3: feat: support router basename
|
|
37
|
+
feat: router 插件支持设置 basename
|
|
38
|
+
- fda836fe8a: feat: support `models`,`initialState` config for state plugin
|
|
39
|
+
feat: state 插件支持`model`,`initialState` 配置
|
|
40
|
+
- d6bc321747: fix: the Document.tsx missed hmr
|
|
41
|
+
|
|
42
|
+
fix: Document.tsx 未能引发 hmr
|
|
43
|
+
|
|
44
|
+
- 3e57f2bd58: feat: add document feature with plugin
|
|
45
|
+
|
|
46
|
+
feat: 增加 document 功能插件
|
|
47
|
+
|
|
48
|
+
- 2e6031955e: fix: some optimizations for router and loader
|
|
49
|
+
fix: 一些 router 和 loader 的优化
|
|
50
|
+
q
|
|
51
|
+
- c5798d284f: fix(runtime): apply babel-plugin-ssr-loader-id when SSR is not used
|
|
52
|
+
|
|
53
|
+
fix(runtime): 在未启动 SSR 时需要注册 babel-plugin-ssr-loader-id
|
|
54
|
+
|
|
55
|
+
- fbf5eed5aa: fix: fix ssg failure due to lack of Web Response API
|
|
56
|
+
fix: 修复因为缺少 Web Response API 而导致 ssg 失败
|
|
57
|
+
- a2509bfbdb: feat: bump esbuild from 0.14.38 to 0.15.7
|
|
58
|
+
|
|
59
|
+
feat: 将 esbuild 从 0.14.38 版本升级至 0.15.7 版本
|
|
60
|
+
|
|
61
|
+
- a7c68832b3: fix: only register babel-plugin-ssr-loader-id when SSR is enabled
|
|
62
|
+
|
|
63
|
+
fix: 仅在开启 SSR 的场景下注册 babel-plugin-ssr-loader-id
|
|
64
|
+
|
|
65
|
+
- 425e57092d: feat: export react-router-dom/server staticRouter
|
|
66
|
+
feat: 导出 react-router-dom/server 的 staticRouter 组件
|
|
67
|
+
- e4357f1856: fix: change default document file and name
|
|
68
|
+
|
|
69
|
+
fix: 重置默认的 document 文件和文件名
|
|
70
|
+
|
|
71
|
+
- 4369648ae2: fix: fix html template of streaming ssr
|
|
72
|
+
fix: 修复流式渲染的 html 模版
|
|
73
|
+
- 92c0994468: chore: remove `registerPrefetch`
|
|
74
|
+
chore: 移除 `registerPrefetch`
|
|
75
|
+
- 2cc2eb35ba: fix: fix state plugin config
|
|
76
|
+
fix: 修复 state 插件 config 参数
|
|
77
|
+
- 6bda14ed71: feat: refactor router with react-router@6.4
|
|
78
|
+
|
|
79
|
+
feat: 使用 react-router@6.4 重构路由模块
|
|
80
|
+
|
|
81
|
+
- 92004d1906: feat: support load chunks parallelly
|
|
82
|
+
feat: 支持并行加载 chunks
|
|
83
|
+
- 40ed5874c6: feat: inject css chunk into html for streaming ssr
|
|
84
|
+
feat: streaming ssr 返回的 html 注入 css chunk
|
|
85
|
+
- 60d5378632: fix: function extname should not return array
|
|
86
|
+
fix: 函数 extname 不应该返回一个数组
|
|
87
|
+
- 8b8e1bb571: feat: support nested routes
|
|
88
|
+
feat: 支持嵌套路由
|
|
89
|
+
- 3bbea92b2a: feat: support Hook、Middleware new API
|
|
90
|
+
feat: 支持 Hook、Middleware 的新 API
|
|
91
|
+
- 21d7521: fix: the Body not use Root jsx
|
|
92
|
+
|
|
93
|
+
fix: 修复 Body 里的 Root 引用格式
|
|
94
|
+
|
|
95
|
+
- 9144c21d27: fix: esbuild config use file
|
|
96
|
+
|
|
97
|
+
fix: 更改 esbuild 读取指定 ts 配置
|
|
98
|
+
|
|
99
|
+
- 18aaf42249: fix: fix server loader redirects
|
|
100
|
+
fix: 修复 server loader 重定向错误
|
|
101
|
+
- 34702d5d47: feat: support internal env vars: metaName_TARGET
|
|
102
|
+
feat: 支持内置环境变量 metaName_TARGET
|
|
103
|
+
- fcace5b5b9: fix: remove overmuch `@modernjs/utils` dependency import in ssr runtime & SSR hydrate error
|
|
104
|
+
fix: 去除 ssr 运行时过多的 `@modernjs/utils` 依赖引入 & SSR hydrate 错误
|
|
105
|
+
- Updated dependencies [7879e8f711]
|
|
106
|
+
- Updated dependencies [6aca875011]
|
|
107
|
+
- Updated dependencies [2e6031955e]
|
|
108
|
+
- Updated dependencies [7b7d12cf8f]
|
|
109
|
+
- Updated dependencies [7efeed4]
|
|
110
|
+
- Updated dependencies [92f0eade39]
|
|
111
|
+
- Updated dependencies [edd1cfb1af]
|
|
112
|
+
- Updated dependencies [cc971eabfc]
|
|
113
|
+
- Updated dependencies [5b9049f2e9]
|
|
114
|
+
- Updated dependencies [6bda14ed71]
|
|
115
|
+
- Updated dependencies [92004d1906]
|
|
116
|
+
- Updated dependencies [b8bbe036c7]
|
|
117
|
+
- Updated dependencies [40ed5874c6]
|
|
118
|
+
- Updated dependencies [87c1ff86b9]
|
|
119
|
+
- Updated dependencies [d5a31df781]
|
|
120
|
+
- Updated dependencies [dda38c9c3e]
|
|
121
|
+
- Updated dependencies [102d32e4ba]
|
|
122
|
+
- Updated dependencies [8b8e1bb571]
|
|
123
|
+
- Updated dependencies [3bbea92b2a]
|
|
124
|
+
- Updated dependencies [b710adb843]
|
|
125
|
+
- Updated dependencies [f179749375]
|
|
126
|
+
- Updated dependencies [ea7cf06257]
|
|
127
|
+
- Updated dependencies [bbe4c4ab64]
|
|
128
|
+
- Updated dependencies [e4558a0bc4]
|
|
129
|
+
- Updated dependencies [abf3421a75]
|
|
130
|
+
- Updated dependencies [543be9558e]
|
|
131
|
+
- Updated dependencies [14b712da84]
|
|
132
|
+
- @modern-js/types@2.0.0-beta.6
|
|
133
|
+
- @modern-js/utils@2.0.0-beta.6
|
|
134
|
+
- @modern-js/plugin@2.0.0-beta.6
|
|
135
|
+
|
|
3
136
|
## 2.0.0-beta.4
|
|
4
137
|
|
|
5
138
|
### Major Changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useContext } from "react";
|
|
3
3
|
import {
|
|
4
4
|
DOCUMENT_CHUNKSMAP_PLACEHOLDER,
|
|
@@ -11,7 +11,7 @@ function Body(props) {
|
|
|
11
11
|
const { children } = props;
|
|
12
12
|
return /* @__PURE__ */ jsxs("body", {
|
|
13
13
|
children: [
|
|
14
|
-
hasSetRoot ? null : DefaultRoot,
|
|
14
|
+
hasSetRoot ? null : /* @__PURE__ */ jsx(DefaultRoot, {}),
|
|
15
15
|
children,
|
|
16
16
|
`${DOCUMENT_CHUNKSMAP_PLACEHOLDER}`,
|
|
17
17
|
`${DOCUMENT_SSRDATASCRIPT_PLACEHOLDER}`
|
|
@@ -2,13 +2,15 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useContext } from "react";
|
|
3
3
|
import { DocumentStructrueContext } from "./DocumentStructrueContext";
|
|
4
4
|
import { Scripts } from "./Scripts";
|
|
5
|
+
import { Links } from "./Links";
|
|
5
6
|
import { DOCUMENT_META_PLACEHOLDER } from "./constants";
|
|
6
7
|
function Head(props) {
|
|
7
|
-
const { hasSetScripts } = useContext(DocumentStructrueContext);
|
|
8
|
+
const { hasSetScripts, hasSetLinks } = useContext(DocumentStructrueContext);
|
|
8
9
|
const { children } = props;
|
|
9
10
|
return /* @__PURE__ */ jsxs("head", {
|
|
10
11
|
children: [
|
|
11
12
|
`${DOCUMENT_META_PLACEHOLDER}`,
|
|
13
|
+
!hasSetLinks && /* @__PURE__ */ jsx(Links, {}),
|
|
12
14
|
!hasSetScripts && /* @__PURE__ */ jsx(Scripts, {}),
|
|
13
15
|
children
|
|
14
16
|
]
|
|
@@ -28,6 +28,7 @@ function Html(props) {
|
|
|
28
28
|
const { children } = props;
|
|
29
29
|
const hasSetHead = Boolean(findTargetChild("Head", children));
|
|
30
30
|
const hasSetScripts = Boolean(findTargetElement("Scripts", children));
|
|
31
|
+
const hasSetLinks = Boolean(findTargetElement("Links", children));
|
|
31
32
|
const hasSetBody = Boolean(findTargetChild("Body", children));
|
|
32
33
|
const hasSetRoot = Boolean(findTargetElement("Root", children));
|
|
33
34
|
const notMissMustChild = [
|
|
@@ -59,6 +60,7 @@ function Html(props) {
|
|
|
59
60
|
value: {
|
|
60
61
|
hasSetHead,
|
|
61
62
|
hasSetScripts,
|
|
63
|
+
hasSetLinks,
|
|
62
64
|
hasSetRoot,
|
|
63
65
|
hasSetBody,
|
|
64
66
|
docChild: children
|
|
@@ -42,6 +42,7 @@ import { createDebugger, findExists, fs } from "@modern-js/utils";
|
|
|
42
42
|
import { DocumentContext } from "../DocumentContext";
|
|
43
43
|
import {
|
|
44
44
|
DOCUMENT_SCRIPTS_PLACEHOLDER,
|
|
45
|
+
DOCUMENT_LINKS_PLACEHOLDER,
|
|
45
46
|
DOCUMENT_FILE_NAME,
|
|
46
47
|
DOCUMENT_META_PLACEHOLDER,
|
|
47
48
|
PLACEHOLDER_REPLACER_MAP,
|
|
@@ -167,9 +168,14 @@ var cli_default = () => ({
|
|
|
167
168
|
htmlWebpackPlugin.tags.headTags.filter((item) => item.tagName === "script").join(""),
|
|
168
169
|
htmlWebpackPlugin.tags.bodyTags.toString()
|
|
169
170
|
].join("");
|
|
171
|
+
const links = [
|
|
172
|
+
htmlWebpackPlugin.tags.headTags.filter((item) => item.tagName === "link").join("")
|
|
173
|
+
].join("");
|
|
170
174
|
const metas = [
|
|
171
175
|
templateParameters.meta,
|
|
172
|
-
htmlWebpackPlugin.tags.headTags.filter(
|
|
176
|
+
htmlWebpackPlugin.tags.headTags.filter(
|
|
177
|
+
(item) => item.tagName !== "script" && item.tagName !== "link"
|
|
178
|
+
).join("")
|
|
173
179
|
].join("");
|
|
174
180
|
if (html.includes(DOCUMENT_SCRIPT_PLACEHOLDER_START) && html.includes(DOCUMENT_SCRIPT_PLACEHOLDER_END)) {
|
|
175
181
|
html = html.replaceAll(
|
|
@@ -180,7 +186,7 @@ var cli_default = () => ({
|
|
|
180
186
|
(_scriptStr, $1) => `<script>${decodeURIComponent($1)}<\/script>`
|
|
181
187
|
);
|
|
182
188
|
}
|
|
183
|
-
const finalHtml = `<!DOCTYPE html>${html}`.replace(DOCUMENT_META_PLACEHOLDER, metas).replace(DOCUMENT_SSR_PLACEHOLDER, HTML_SEPARATOR).replace(DOCUMENT_SCRIPTS_PLACEHOLDER, scripts).replace(
|
|
189
|
+
const finalHtml = `<!DOCTYPE html>${html}`.replace(DOCUMENT_META_PLACEHOLDER, metas).replace(DOCUMENT_SSR_PLACEHOLDER, HTML_SEPARATOR).replace(DOCUMENT_SCRIPTS_PLACEHOLDER, scripts).replace(DOCUMENT_LINKS_PLACEHOLDER, links).replace(
|
|
184
190
|
DOCUMENT_CHUNKSMAP_PLACEHOLDER,
|
|
185
191
|
PLACEHOLDER_REPLACER_MAP[DOCUMENT_CHUNKSMAP_PLACEHOLDER]
|
|
186
192
|
).replace(
|
|
@@ -14,6 +14,9 @@ const DOCUMENT_FILE_NAME = "Document";
|
|
|
14
14
|
const DOCUMENT_SCRIPTS_PLACEHOLDER = encodeURIComponent(
|
|
15
15
|
"<!-- chunk scripts placeholder -->"
|
|
16
16
|
);
|
|
17
|
+
const DOCUMENT_LINKS_PLACEHOLDER = encodeURIComponent(
|
|
18
|
+
"<!-- chunk links placeholder -->"
|
|
19
|
+
);
|
|
17
20
|
const DOCUMENT_NO_SCRIPTE_PLACEHOLDER = encodeURIComponent("<!-- no-script -->");
|
|
18
21
|
const DOCUMENT_SCRIPT_PLACEHOLDER_START = encodeURIComponent(
|
|
19
22
|
"<!-- script-start -->"
|
|
@@ -30,6 +33,7 @@ const PLACEHOLDER_REPLACER_MAP = {
|
|
|
30
33
|
export {
|
|
31
34
|
DOCUMENT_CHUNKSMAP_PLACEHOLDER,
|
|
32
35
|
DOCUMENT_FILE_NAME,
|
|
36
|
+
DOCUMENT_LINKS_PLACEHOLDER,
|
|
33
37
|
DOCUMENT_META_PLACEHOLDER,
|
|
34
38
|
DOCUMENT_NO_SCRIPTE_PLACEHOLDER,
|
|
35
39
|
DOCUMENT_SCRIPTS_PLACEHOLDER,
|
|
@@ -24,6 +24,10 @@ import {
|
|
|
24
24
|
} from "@modern-js/utils";
|
|
25
25
|
const PLUGIN_IDENTIFIER = "router";
|
|
26
26
|
const ROUTES_IDENTIFIER = "routes";
|
|
27
|
+
const isV5 = (config) => {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
return ((_b = (_a = config == null ? void 0 : config.runtime) == null ? void 0 : _a.router) == null ? void 0 : _b.mode) === "react-router-5";
|
|
30
|
+
};
|
|
27
31
|
var cli_default = () => ({
|
|
28
32
|
name: "@modern-js/plugin-router",
|
|
29
33
|
required: ["@modern-js/runtime"],
|
|
@@ -49,10 +53,8 @@ var cli_default = () => ({
|
|
|
49
53
|
return PLUGIN_SCHEMAS["@modern-js/plugin-router"];
|
|
50
54
|
},
|
|
51
55
|
modifyEntryImports({ entrypoint, imports }) {
|
|
52
|
-
var _a, _b;
|
|
53
56
|
const { entryName, fileSystemRoutes } = entrypoint;
|
|
54
57
|
const userConfig = api.useResolvedConfigContext();
|
|
55
|
-
const isLegacy = Boolean((_b = (_a = userConfig == null ? void 0 : userConfig.runtime) == null ? void 0 : _a.router) == null ? void 0 : _b.legacy);
|
|
56
58
|
const { packageName } = api.useAppContext();
|
|
57
59
|
const runtimeConfig = getEntryOptions(
|
|
58
60
|
entryName,
|
|
@@ -62,7 +64,7 @@ var cli_default = () => ({
|
|
|
62
64
|
);
|
|
63
65
|
runtimeConfigMap.set(entryName, runtimeConfig);
|
|
64
66
|
if (runtimeConfig == null ? void 0 : runtimeConfig.router) {
|
|
65
|
-
if (!
|
|
67
|
+
if (!isV5(userConfig)) {
|
|
66
68
|
imports.push({
|
|
67
69
|
value: "@modern-js/runtime/plugins",
|
|
68
70
|
specifiers: [{ imported: PLUGIN_IDENTIFIER }]
|
|
@@ -79,13 +81,11 @@ var cli_default = () => ({
|
|
|
79
81
|
};
|
|
80
82
|
},
|
|
81
83
|
modifyEntryRuntimePlugins({ entrypoint, plugins }) {
|
|
82
|
-
var _a, _b;
|
|
83
84
|
const { entryName, fileSystemRoutes } = entrypoint;
|
|
84
85
|
const { serverRoutes } = api.useAppContext();
|
|
85
86
|
const userConfig = api.useResolvedConfigContext();
|
|
86
|
-
const isLegacy = Boolean((_b = (_a = userConfig == null ? void 0 : userConfig.runtime) == null ? void 0 : _a.router) == null ? void 0 : _b.legacy);
|
|
87
87
|
const runtimeConfig = runtimeConfigMap.get(entryName);
|
|
88
|
-
if (runtimeConfig.router && !
|
|
88
|
+
if (runtimeConfig.router && !isV5(userConfig)) {
|
|
89
89
|
const serverBase = serverRoutes.filter((route) => route.entryName === entryName).map((route) => route.urlPath).sort((a, b) => a.length - b.length > 0 ? -1 : 1);
|
|
90
90
|
plugins.push({
|
|
91
91
|
name: PLUGIN_IDENTIFIER,
|
|
@@ -105,10 +105,8 @@ var cli_default = () => ({
|
|
|
105
105
|
};
|
|
106
106
|
},
|
|
107
107
|
addRuntimeExports() {
|
|
108
|
-
var _a, _b;
|
|
109
108
|
const userConfig = api.useResolvedConfigContext();
|
|
110
|
-
|
|
111
|
-
if (!isLegacy) {
|
|
109
|
+
if (!isV5(userConfig)) {
|
|
112
110
|
pluginsExportsUtils.addExport(
|
|
113
111
|
`export { default as router } from '@modern-js/runtime/router'`
|
|
114
112
|
);
|
|
@@ -2,6 +2,7 @@ import { routerPlugin } from "./plugin";
|
|
|
2
2
|
var runtime_default = routerPlugin;
|
|
3
3
|
import { modifyRoutes } from "./plugin";
|
|
4
4
|
export * from "react-router-dom";
|
|
5
|
+
export * from "react-router-dom/server";
|
|
5
6
|
export * from "./withRouter";
|
|
6
7
|
export {
|
|
7
8
|
runtime_default as default,
|
|
@@ -39,10 +39,10 @@ var __async = (__this, __arguments, generator) => {
|
|
|
39
39
|
};
|
|
40
40
|
import { jsx } from "react/jsx-runtime";
|
|
41
41
|
import { useContext } from "react";
|
|
42
|
-
import {
|
|
42
|
+
import { createStaticHandler } from "@remix-run/router";
|
|
43
43
|
import {
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
createStaticRouter,
|
|
45
|
+
StaticRouterProvider
|
|
46
46
|
} from "react-router-dom/server";
|
|
47
47
|
import hoistNonReactStatics from "hoist-non-react-statics";
|
|
48
48
|
import { installGlobals } from "@remix-run/node";
|
|
@@ -36,9 +36,6 @@ import { DefaultNotFound } from "./DefaultNotFound";
|
|
|
36
36
|
import { RootLayout } from "./root";
|
|
37
37
|
const renderNestedRoute = (nestedRoute, parent) => {
|
|
38
38
|
const { children, index, id, component: Component } = nestedRoute;
|
|
39
|
-
const childElements = children == null ? void 0 : children.map((childRoute) => {
|
|
40
|
-
return renderNestedRoute(childRoute, nestedRoute);
|
|
41
|
-
});
|
|
42
39
|
const routeProps = {
|
|
43
40
|
caseSensitive: nestedRoute.caseSensitive,
|
|
44
41
|
path: nestedRoute.path,
|
|
@@ -64,11 +61,15 @@ const renderNestedRoute = (nestedRoute, parent) => {
|
|
|
64
61
|
fallback: /* @__PURE__ */ jsx(Loading, {}),
|
|
65
62
|
children: /* @__PURE__ */ jsx(Component, {})
|
|
66
63
|
});
|
|
67
|
-
} else {
|
|
64
|
+
} else if (!(parent == null ? void 0 : parent.index)) {
|
|
68
65
|
element = /* @__PURE__ */ jsx(Suspense, {
|
|
69
66
|
children: /* @__PURE__ */ jsx(Component, {})
|
|
70
67
|
});
|
|
68
|
+
} else {
|
|
69
|
+
element = /* @__PURE__ */ jsx(Component, {});
|
|
71
70
|
}
|
|
71
|
+
} else {
|
|
72
|
+
nestedRoute.loading = parent == null ? void 0 : parent.loading;
|
|
72
73
|
}
|
|
73
74
|
if (!parent && element) {
|
|
74
75
|
element = /* @__PURE__ */ jsx(RootLayout, {
|
|
@@ -79,6 +80,9 @@ const renderNestedRoute = (nestedRoute, parent) => {
|
|
|
79
80
|
if (element) {
|
|
80
81
|
routeProps.element = element;
|
|
81
82
|
}
|
|
83
|
+
const childElements = children == null ? void 0 : children.map((childRoute) => {
|
|
84
|
+
return renderNestedRoute(childRoute, nestedRoute);
|
|
85
|
+
});
|
|
82
86
|
const routeElement = index ? /* @__PURE__ */ jsx(Route, __spreadProps(__spreadValues({}, routeProps), {
|
|
83
87
|
index: true
|
|
84
88
|
}), id) : /* @__PURE__ */ jsx(Route, __spreadProps(__spreadValues({}, routeProps), {
|
|
@@ -114,9 +114,9 @@ var cli_default = () => ({
|
|
|
114
114
|
userConfig.runtimeByEntries,
|
|
115
115
|
packageName
|
|
116
116
|
);
|
|
117
|
-
if ((_a = runtimeConfig == null ? void 0 : runtimeConfig.router) == null ? void 0 : _a.
|
|
117
|
+
if (((_a = runtimeConfig == null ? void 0 : runtimeConfig.router) == null ? void 0 : _a.mode) === "react-router-5") {
|
|
118
118
|
throw new Error(
|
|
119
|
-
`
|
|
119
|
+
`router v5 plugin doesn't support streaming SSR, check your config 'runtime.router'`
|
|
120
120
|
);
|
|
121
121
|
}
|
|
122
122
|
if (fileSystemRoutes && !entrypoint.nestedRoutesEntry) {
|
|
@@ -21,17 +21,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
mod
|
|
22
22
|
));
|
|
23
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
-
var stdin_exports = {};
|
|
25
|
-
__export(stdin_exports, {
|
|
26
|
-
default: () => cli_default
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(stdin_exports);
|
|
29
|
-
var import_path = __toESM(require("path"));
|
|
30
|
-
var import_utils = require("@modern-js/utils");
|
|
31
|
-
var import_cli = __toESM(require("../state/cli"));
|
|
32
|
-
var import_cli2 = __toESM(require("../ssr/cli"));
|
|
33
|
-
var import_cli3 = __toESM(require("../router/cli"));
|
|
34
|
-
var import_cli4 = __toESM(require("../document/cli"));
|
|
35
24
|
var __async = (__this, __arguments, generator) => {
|
|
36
25
|
return new Promise((resolve, reject) => {
|
|
37
26
|
var fulfilled = (value) => {
|
|
@@ -52,6 +41,17 @@ var __async = (__this, __arguments, generator) => {
|
|
|
52
41
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
53
42
|
});
|
|
54
43
|
};
|
|
44
|
+
var cli_exports = {};
|
|
45
|
+
__export(cli_exports, {
|
|
46
|
+
default: () => cli_default
|
|
47
|
+
});
|
|
48
|
+
module.exports = __toCommonJS(cli_exports);
|
|
49
|
+
var import_path = __toESM(require("path"));
|
|
50
|
+
var import_utils = require("@modern-js/utils");
|
|
51
|
+
var import_cli = __toESM(require("../state/cli"));
|
|
52
|
+
var import_cli2 = __toESM(require("../ssr/cli"));
|
|
53
|
+
var import_cli3 = __toESM(require("../router/cli"));
|
|
54
|
+
var import_cli4 = __toESM(require("../document/cli"));
|
|
55
55
|
var cli_default = () => ({
|
|
56
56
|
name: "@modern-js/runtime",
|
|
57
57
|
post: [
|
|
@@ -95,3 +95,5 @@ var cli_default = () => ({
|
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
97
|
});
|
|
98
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
99
|
+
0 && (module.exports = {});
|
package/dist/js/node/common.js
CHANGED
|
@@ -15,9 +15,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var
|
|
19
|
-
__export(
|
|
18
|
+
var common_exports = {};
|
|
19
|
+
__export(common_exports, {
|
|
20
20
|
isBrowser: () => isBrowser
|
|
21
21
|
});
|
|
22
|
-
module.exports = __toCommonJS(
|
|
22
|
+
module.exports = __toCommonJS(common_exports);
|
|
23
23
|
const isBrowser = () => typeof window !== "undefined" && window.name !== "nodejs";
|
|
24
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
25
|
+
0 && (module.exports = {
|
|
26
|
+
isBrowser
|
|
27
|
+
});
|
|
@@ -15,15 +15,20 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var
|
|
19
|
-
__export(
|
|
18
|
+
var app_config_exports = {};
|
|
19
|
+
__export(app_config_exports, {
|
|
20
20
|
defineConfig: () => defineConfig,
|
|
21
21
|
getConfig: () => getConfig
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(app_config_exports);
|
|
24
24
|
const APP_CONFIG_SYMBOL = "config";
|
|
25
25
|
const getConfig = (Component) => Component[APP_CONFIG_SYMBOL];
|
|
26
26
|
const defineConfig = (Component, config) => {
|
|
27
27
|
Component[APP_CONFIG_SYMBOL] = config;
|
|
28
28
|
return Component;
|
|
29
29
|
};
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
defineConfig,
|
|
33
|
+
getConfig
|
|
34
|
+
});
|
|
@@ -2,47 +2,14 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
-
mod
|
|
22
|
-
));
|
|
23
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
-
var stdin_exports = {};
|
|
25
|
-
__export(stdin_exports, {
|
|
26
|
-
bootstrap: () => bootstrap,
|
|
27
|
-
createApp: () => createApp,
|
|
28
|
-
useRuntimeContext: () => useRuntimeContext
|
|
29
|
-
});
|
|
30
|
-
module.exports = __toCommonJS(stdin_exports);
|
|
31
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
-
var import_react = __toESM(require("react"));
|
|
33
|
-
var import_hoist_non_react_statics = __toESM(require("hoist-non-react-statics"));
|
|
34
|
-
var import_constants = require("@modern-js/utils/constants");
|
|
35
|
-
var import_runtime_context = require("../runtime-context");
|
|
36
|
-
var import_plugin = require("./plugin");
|
|
37
|
-
var import_loaderManager = require("./loader/loaderManager");
|
|
38
|
-
var __defProp2 = Object.defineProperty;
|
|
39
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
40
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
41
8
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
42
|
-
var __defNormalProp = (obj, key, value) => key in obj ?
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
43
10
|
var __spreadValues = (a, b) => {
|
|
44
11
|
for (var prop in b || (b = {}))
|
|
45
|
-
if (
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
46
13
|
__defNormalProp(a, prop, b[prop]);
|
|
47
14
|
if (__getOwnPropSymbols)
|
|
48
15
|
for (var prop of __getOwnPropSymbols(b)) {
|
|
@@ -54,7 +21,7 @@ var __spreadValues = (a, b) => {
|
|
|
54
21
|
var __objRest = (source, exclude) => {
|
|
55
22
|
var target = {};
|
|
56
23
|
for (var prop in source)
|
|
57
|
-
if (
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
58
25
|
target[prop] = source[prop];
|
|
59
26
|
if (source != null && __getOwnPropSymbols)
|
|
60
27
|
for (var prop of __getOwnPropSymbols(source)) {
|
|
@@ -63,6 +30,23 @@ var __objRest = (source, exclude) => {
|
|
|
63
30
|
}
|
|
64
31
|
return target;
|
|
65
32
|
};
|
|
33
|
+
var __export = (target, all) => {
|
|
34
|
+
for (var name in all)
|
|
35
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
36
|
+
};
|
|
37
|
+
var __copyProps = (to, from, except, desc) => {
|
|
38
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
39
|
+
for (let key of __getOwnPropNames(from))
|
|
40
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
41
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
42
|
+
}
|
|
43
|
+
return to;
|
|
44
|
+
};
|
|
45
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
46
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
47
|
+
mod
|
|
48
|
+
));
|
|
49
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
66
50
|
var __async = (__this, __arguments, generator) => {
|
|
67
51
|
return new Promise((resolve, reject) => {
|
|
68
52
|
var fulfilled = (value) => {
|
|
@@ -83,6 +67,20 @@ var __async = (__this, __arguments, generator) => {
|
|
|
83
67
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
84
68
|
});
|
|
85
69
|
};
|
|
70
|
+
var compatible_exports = {};
|
|
71
|
+
__export(compatible_exports, {
|
|
72
|
+
bootstrap: () => bootstrap,
|
|
73
|
+
createApp: () => createApp,
|
|
74
|
+
useRuntimeContext: () => useRuntimeContext
|
|
75
|
+
});
|
|
76
|
+
module.exports = __toCommonJS(compatible_exports);
|
|
77
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
78
|
+
var import_react = __toESM(require("react"));
|
|
79
|
+
var import_hoist_non_react_statics = __toESM(require("hoist-non-react-statics"));
|
|
80
|
+
var import_constants = require("@modern-js/utils/constants");
|
|
81
|
+
var import_runtime_context = require("../runtime-context");
|
|
82
|
+
var import_plugin = require("./plugin");
|
|
83
|
+
var import_loaderManager = require("./loader/loaderManager");
|
|
86
84
|
const IS_REACT18 = process.env.IS_REACT18 === "true";
|
|
87
85
|
function isClientArgs(id) {
|
|
88
86
|
return typeof id === "string" || typeof HTMLElement !== "undefined" && id instanceof HTMLElement;
|
|
@@ -306,3 +304,9 @@ const useRuntimeContext = () => {
|
|
|
306
304
|
);
|
|
307
305
|
return memoizedContext;
|
|
308
306
|
};
|
|
307
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
308
|
+
0 && (module.exports = {
|
|
309
|
+
bootstrap,
|
|
310
|
+
createApp,
|
|
311
|
+
useRuntimeContext
|
|
312
|
+
});
|
|
@@ -16,8 +16,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var core_exports = {};
|
|
20
|
+
__export(core_exports, {
|
|
21
21
|
RuntimeReactContext: () => import_runtime_context.RuntimeReactContext,
|
|
22
22
|
ServerRouterContext: () => import_runtime_context.ServerRouterContext,
|
|
23
23
|
createPlugin: () => import_plugin.createPlugin,
|
|
@@ -27,10 +27,21 @@ __export(stdin_exports, {
|
|
|
27
27
|
registerInit: () => import_plugin.registerInit,
|
|
28
28
|
runtime: () => import_plugin.runtime
|
|
29
29
|
});
|
|
30
|
-
module.exports = __toCommonJS(
|
|
30
|
+
module.exports = __toCommonJS(core_exports);
|
|
31
31
|
var import_plugin = require("./plugin");
|
|
32
32
|
var import_app_config = require("./app-config");
|
|
33
|
-
__reExport(
|
|
33
|
+
__reExport(core_exports, require("./compatible"), module.exports);
|
|
34
34
|
var import_runtime_context = require("../runtime-context");
|
|
35
|
-
__reExport(
|
|
36
|
-
__reExport(
|
|
35
|
+
__reExport(core_exports, require("./loader"), module.exports);
|
|
36
|
+
__reExport(core_exports, require("@modern-js/plugin"), module.exports);
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
RuntimeReactContext,
|
|
40
|
+
ServerRouterContext,
|
|
41
|
+
createPlugin,
|
|
42
|
+
createRuntime,
|
|
43
|
+
defineConfig,
|
|
44
|
+
getConfig,
|
|
45
|
+
registerInit,
|
|
46
|
+
runtime
|
|
47
|
+
});
|
|
@@ -21,9 +21,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
mod
|
|
22
22
|
));
|
|
23
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
-
var
|
|
25
|
-
__export(
|
|
24
|
+
var loader_exports = {};
|
|
25
|
+
__export(loader_exports, {
|
|
26
26
|
useLoader: () => import_useLoader.default
|
|
27
27
|
});
|
|
28
|
-
module.exports = __toCommonJS(
|
|
28
|
+
module.exports = __toCommonJS(loader_exports);
|
|
29
29
|
var import_useLoader = __toESM(require("./useLoader"));
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
useLoader
|
|
33
|
+
});
|