@modern-js/runtime 2.0.0-beta.5 → 2.0.0-beta.7

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.
Files changed (30) hide show
  1. package/CHANGELOG.md +161 -0
  2. package/dist/js/modern/document/DocumentStructrueContext.js +2 -1
  3. package/dist/js/modern/document/Head.js +3 -1
  4. package/dist/js/modern/document/Html.js +2 -0
  5. package/dist/js/modern/document/Links.js +10 -0
  6. package/dist/js/modern/document/cli/index.js +8 -2
  7. package/dist/js/modern/document/constants.js +4 -0
  8. package/dist/js/modern/document/index.js +1 -0
  9. package/dist/js/modern/router/runtime/plugin.node.js +3 -3
  10. package/dist/js/node/document/DocumentStructrueContext.js +2 -1
  11. package/dist/js/node/document/Head.js +3 -1
  12. package/dist/js/node/document/Html.js +2 -0
  13. package/dist/js/node/document/Links.js +33 -0
  14. package/dist/js/node/document/cli/index.js +7 -2
  15. package/dist/js/node/document/constants.js +5 -0
  16. package/dist/js/node/document/index.js +1 -0
  17. package/dist/js/node/router/runtime/plugin.node.js +3 -3
  18. package/dist/js/treeshaking/document/DocumentStructrueContext.js +2 -1
  19. package/dist/js/treeshaking/document/Head.js +3 -1
  20. package/dist/js/treeshaking/document/Html.js +2 -0
  21. package/dist/js/treeshaking/document/Links.js +8 -0
  22. package/dist/js/treeshaking/document/cli/index.js +9 -4
  23. package/dist/js/treeshaking/document/constants.js +2 -1
  24. package/dist/js/treeshaking/document/index.js +1 -0
  25. package/dist/js/treeshaking/router/runtime/plugin.node.js +2 -2
  26. package/dist/types/document/DocumentStructrueContext.d.ts +1 -0
  27. package/dist/types/document/Links.d.ts +2 -0
  28. package/dist/types/document/constants.d.ts +1 -0
  29. package/dist/types/document/index.d.ts +1 -0
  30. package/package.json +17 -17
package/CHANGELOG.md CHANGED
@@ -1,5 +1,166 @@
1
1
  # @modern-js/runtime
2
2
 
3
+ ## 2.0.0-beta.7
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
+
14
+ ### Patch Changes
15
+
16
+ - 6bda14ed71: feat: refactor router with react-router@6.4
17
+
18
+ feat: 使用 react-router@6.4 重构路由模块
19
+
20
+ - 8b8e1bb571: feat: support nested routes
21
+ feat: 支持嵌套路由
22
+ - Updated dependencies [edd1cfb1af]
23
+ - Updated dependencies [6bda14ed71]
24
+ - Updated dependencies [dda38c9c3e]
25
+ - Updated dependencies [8b8e1bb571]
26
+ - Updated dependencies [bbe4c4ab64]
27
+ - @modern-js/utils@2.0.0-beta.7
28
+ - @modern-js/types@2.0.0-beta.7
29
+ - @modern-js/plugin@2.0.0-beta.7
30
+
31
+ ## 2.0.0-beta.6
32
+
33
+ ### Major Changes
34
+
35
+ - dda38c9c3e: chore: v2
36
+
37
+ ### Minor Changes
38
+
39
+ - c9e800d39a: feat: support React18 streaming SSR
40
+ feat: 支持 React18 流式 SSR
41
+ - df7ee2d: feat: runtime user config types extends
42
+ feat: runtime 用户配置类型扩展
43
+ - 543be9558e: feat: compile server loader and support handle loader request
44
+ feat: 编译 server loader 并支持处理 loader 的请求
45
+
46
+ ### Patch Changes
47
+
48
+ - 2344eb26ed: fix: bootstrap function params type define
49
+
50
+ fix: 修复 bootstrap 函数参数类型定义
51
+
52
+ - a11fcf8b50: feat: fallback logic of streaming ssr
53
+ feat: streaming ssr 降级逻辑
54
+ - a93159440e: feat: support modify routes for csr app
55
+ feat: 支持 modifyRoutes API
56
+ - e7ce0636d1: fix: root layout css chunks should't be loaded
57
+ fix: 不应该加载 root layout 的 css chunks
58
+ - b18fa8f3ed: feat: remove @loadable/component in streaming ssr
59
+ feat: 移除 streaming ssr 中的 @loadable/component 逻辑
60
+ - 50d4675e5b: fix: add document cli export
61
+
62
+ fix: 增加 document cli 插件的导出
63
+
64
+ - 6604f1b8b3: feat: support router basename
65
+ feat: router 插件支持设置 basename
66
+ - fda836fe8a: feat: support `models`,`initialState` config for state plugin
67
+ feat: state 插件支持`model`,`initialState` 配置
68
+ - d6bc321747: fix: the Document.tsx missed hmr
69
+
70
+ fix: Document.tsx 未能引发 hmr
71
+
72
+ - 3e57f2bd58: feat: add document feature with plugin
73
+
74
+ feat: 增加 document 功能插件
75
+
76
+ - 2e6031955e: fix: some optimizations for router and loader
77
+ fix: 一些 router 和 loader 的优化
78
+ q
79
+ - c5798d284f: fix(runtime): apply babel-plugin-ssr-loader-id when SSR is not used
80
+
81
+ fix(runtime): 在未启动 SSR 时需要注册 babel-plugin-ssr-loader-id
82
+
83
+ - fbf5eed5aa: fix: fix ssg failure due to lack of Web Response API
84
+ fix: 修复因为缺少 Web Response API 而导致 ssg 失败
85
+ - a2509bfbdb: feat: bump esbuild from 0.14.38 to 0.15.7
86
+
87
+ feat: 将 esbuild 从 0.14.38 版本升级至 0.15.7 版本
88
+
89
+ - a7c68832b3: fix: only register babel-plugin-ssr-loader-id when SSR is enabled
90
+
91
+ fix: 仅在开启 SSR 的场景下注册 babel-plugin-ssr-loader-id
92
+
93
+ - 425e57092d: feat: export react-router-dom/server staticRouter
94
+ feat: 导出 react-router-dom/server 的 staticRouter 组件
95
+ - e4357f1856: fix: change default document file and name
96
+
97
+ fix: 重置默认的 document 文件和文件名
98
+
99
+ - 4369648ae2: fix: fix html template of streaming ssr
100
+ fix: 修复流式渲染的 html 模版
101
+ - 92c0994468: chore: remove `registerPrefetch`
102
+ chore: 移除 `registerPrefetch`
103
+ - 2cc2eb35ba: fix: fix state plugin config
104
+ fix: 修复 state 插件 config 参数
105
+ - 6bda14ed71: feat: refactor router with react-router@6.4
106
+
107
+ feat: 使用 react-router@6.4 重构路由模块
108
+
109
+ - 92004d1906: feat: support load chunks parallelly
110
+ feat: 支持并行加载 chunks
111
+ - 40ed5874c6: feat: inject css chunk into html for streaming ssr
112
+ feat: streaming ssr 返回的 html 注入 css chunk
113
+ - 60d5378632: fix: function extname should not return array
114
+ fix: 函数 extname 不应该返回一个数组
115
+ - 8b8e1bb571: feat: support nested routes
116
+ feat: 支持嵌套路由
117
+ - 3bbea92b2a: feat: support Hook、Middleware new API
118
+ feat: 支持 Hook、Middleware 的新 API
119
+ - 21d7521: fix: the Body not use Root jsx
120
+
121
+ fix: 修复 Body 里的 Root 引用格式
122
+
123
+ - 9144c21d27: fix: esbuild config use file
124
+
125
+ fix: 更改 esbuild 读取指定 ts 配置
126
+
127
+ - 18aaf42249: fix: fix server loader redirects
128
+ fix: 修复 server loader 重定向错误
129
+ - 34702d5d47: feat: support internal env vars: metaName_TARGET
130
+ feat: 支持内置环境变量 metaName_TARGET
131
+ - fcace5b5b9: fix: remove overmuch `@modernjs/utils` dependency import in ssr runtime & SSR hydrate error
132
+ fix: 去除 ssr 运行时过多的 `@modernjs/utils` 依赖引入 & SSR hydrate 错误
133
+ - Updated dependencies [7879e8f711]
134
+ - Updated dependencies [6aca875011]
135
+ - Updated dependencies [2e6031955e]
136
+ - Updated dependencies [7b7d12cf8f]
137
+ - Updated dependencies [7efeed4]
138
+ - Updated dependencies [92f0eade39]
139
+ - Updated dependencies [edd1cfb1af]
140
+ - Updated dependencies [cc971eabfc]
141
+ - Updated dependencies [5b9049f2e9]
142
+ - Updated dependencies [6bda14ed71]
143
+ - Updated dependencies [92004d1906]
144
+ - Updated dependencies [b8bbe036c7]
145
+ - Updated dependencies [40ed5874c6]
146
+ - Updated dependencies [87c1ff86b9]
147
+ - Updated dependencies [d5a31df781]
148
+ - Updated dependencies [dda38c9c3e]
149
+ - Updated dependencies [102d32e4ba]
150
+ - Updated dependencies [8b8e1bb571]
151
+ - Updated dependencies [3bbea92b2a]
152
+ - Updated dependencies [b710adb843]
153
+ - Updated dependencies [f179749375]
154
+ - Updated dependencies [ea7cf06257]
155
+ - Updated dependencies [bbe4c4ab64]
156
+ - Updated dependencies [e4558a0bc4]
157
+ - Updated dependencies [abf3421a75]
158
+ - Updated dependencies [543be9558e]
159
+ - Updated dependencies [14b712da84]
160
+ - @modern-js/types@2.0.0-beta.6
161
+ - @modern-js/utils@2.0.0-beta.6
162
+ - @modern-js/plugin@2.0.0-beta.6
163
+
3
164
  ## 2.0.0-beta.4
4
165
 
5
166
  ### Major Changes
@@ -3,7 +3,8 @@ const DocumentStructrueContext = React.createContext({
3
3
  hasSetHead: false,
4
4
  hasSetScripts: false,
5
5
  hasSetBody: false,
6
- hasSetRoot: false
6
+ hasSetRoot: false,
7
+ hasSetLinks: false
7
8
  });
8
9
  export {
9
10
  DocumentStructrueContext
@@ -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
@@ -0,0 +1,10 @@
1
+ import { Fragment, jsx } from "react/jsx-runtime";
2
+ import { DOCUMENT_LINKS_PLACEHOLDER } from "./constants";
3
+ function Links() {
4
+ return /* @__PURE__ */ jsx(Fragment, {
5
+ children: DOCUMENT_LINKS_PLACEHOLDER
6
+ });
7
+ }
8
+ export {
9
+ Links
10
+ };
@@ -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((item) => item.tagName !== "script").join("")
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,
@@ -4,6 +4,7 @@ export * from "./DocumentStructrueContext";
4
4
  export * from "./Head";
5
5
  export * from "./Body";
6
6
  export * from "./Root";
7
+ export * from "./Links";
7
8
  export * from "./Scripts";
8
9
  export * from "./Script";
9
10
  export * from "./constants";
@@ -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 { unstable_createStaticHandler as createStaticHandler } from "@remix-run/router";
42
+ import { createStaticHandler } from "@remix-run/router";
43
43
  import {
44
- unstable_createStaticRouter as createStaticRouter,
45
- unstable_StaticRouterProvider as StaticRouterProvider
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";
@@ -31,7 +31,8 @@ const DocumentStructrueContext = import_react.default.createContext({
31
31
  hasSetHead: false,
32
32
  hasSetScripts: false,
33
33
  hasSetBody: false,
34
- hasSetRoot: false
34
+ hasSetRoot: false,
35
+ hasSetLinks: false
35
36
  });
36
37
  // Annotate the CommonJS export names for ESM import in node:
37
38
  0 && (module.exports = {
@@ -25,13 +25,15 @@ var import_jsx_runtime = require("react/jsx-runtime");
25
25
  var import_react = require("react");
26
26
  var import_DocumentStructrueContext = require("./DocumentStructrueContext");
27
27
  var import_Scripts = require("./Scripts");
28
+ var import_Links = require("./Links");
28
29
  var import_constants = require("./constants");
29
30
  function Head(props) {
30
- const { hasSetScripts } = (0, import_react.useContext)(import_DocumentStructrueContext.DocumentStructrueContext);
31
+ const { hasSetScripts, hasSetLinks } = (0, import_react.useContext)(import_DocumentStructrueContext.DocumentStructrueContext);
31
32
  const { children } = props;
32
33
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("head", {
33
34
  children: [
34
35
  `${import_constants.DOCUMENT_META_PLACEHOLDER}`,
36
+ !hasSetLinks && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Links.Links, {}),
35
37
  !hasSetScripts && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Scripts.Scripts, {}),
36
38
  children
37
39
  ]
@@ -50,6 +50,7 @@ function Html(props) {
50
50
  const { children } = props;
51
51
  const hasSetHead = Boolean(findTargetChild("Head", children));
52
52
  const hasSetScripts = Boolean(findTargetElement("Scripts", children));
53
+ const hasSetLinks = Boolean(findTargetElement("Links", children));
53
54
  const hasSetBody = Boolean(findTargetChild("Body", children));
54
55
  const hasSetRoot = Boolean(findTargetElement("Root", children));
55
56
  const notMissMustChild = [
@@ -81,6 +82,7 @@ function Html(props) {
81
82
  value: {
82
83
  hasSetHead,
83
84
  hasSetScripts,
85
+ hasSetLinks,
84
86
  hasSetRoot,
85
87
  hasSetBody,
86
88
  docChild: children
@@ -0,0 +1,33 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var Links_exports = {};
19
+ __export(Links_exports, {
20
+ Links: () => Links
21
+ });
22
+ module.exports = __toCommonJS(Links_exports);
23
+ var import_jsx_runtime = require("react/jsx-runtime");
24
+ var import_constants = require("./constants");
25
+ function Links() {
26
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
27
+ children: import_constants.DOCUMENT_LINKS_PLACEHOLDER
28
+ });
29
+ }
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ Links
33
+ });
@@ -181,9 +181,14 @@ var cli_default = () => ({
181
181
  htmlWebpackPlugin.tags.headTags.filter((item) => item.tagName === "script").join(""),
182
182
  htmlWebpackPlugin.tags.bodyTags.toString()
183
183
  ].join("");
184
+ const links = [
185
+ htmlWebpackPlugin.tags.headTags.filter((item) => item.tagName === "link").join("")
186
+ ].join("");
184
187
  const metas = [
185
188
  templateParameters.meta,
186
- htmlWebpackPlugin.tags.headTags.filter((item) => item.tagName !== "script").join("")
189
+ htmlWebpackPlugin.tags.headTags.filter(
190
+ (item) => item.tagName !== "script" && item.tagName !== "link"
191
+ ).join("")
187
192
  ].join("");
188
193
  if (html.includes(import_constants.DOCUMENT_SCRIPT_PLACEHOLDER_START) && html.includes(import_constants.DOCUMENT_SCRIPT_PLACEHOLDER_END)) {
189
194
  html = html.replaceAll(
@@ -194,7 +199,7 @@ var cli_default = () => ({
194
199
  (_scriptStr, $1) => `<script>${decodeURIComponent($1)}<\/script>`
195
200
  );
196
201
  }
197
- const finalHtml = `<!DOCTYPE html>${html}`.replace(import_constants.DOCUMENT_META_PLACEHOLDER, metas).replace(import_constants.DOCUMENT_SSR_PLACEHOLDER, import_constants.HTML_SEPARATOR).replace(import_constants.DOCUMENT_SCRIPTS_PLACEHOLDER, scripts).replace(
202
+ const finalHtml = `<!DOCTYPE html>${html}`.replace(import_constants.DOCUMENT_META_PLACEHOLDER, metas).replace(import_constants.DOCUMENT_SSR_PLACEHOLDER, import_constants.HTML_SEPARATOR).replace(import_constants.DOCUMENT_SCRIPTS_PLACEHOLDER, scripts).replace(import_constants.DOCUMENT_LINKS_PLACEHOLDER, links).replace(
198
203
  import_constants.DOCUMENT_CHUNKSMAP_PLACEHOLDER,
199
204
  import_constants.PLACEHOLDER_REPLACER_MAP[import_constants.DOCUMENT_CHUNKSMAP_PLACEHOLDER]
200
205
  ).replace(
@@ -19,6 +19,7 @@ var constants_exports = {};
19
19
  __export(constants_exports, {
20
20
  DOCUMENT_CHUNKSMAP_PLACEHOLDER: () => DOCUMENT_CHUNKSMAP_PLACEHOLDER,
21
21
  DOCUMENT_FILE_NAME: () => DOCUMENT_FILE_NAME,
22
+ DOCUMENT_LINKS_PLACEHOLDER: () => DOCUMENT_LINKS_PLACEHOLDER,
22
23
  DOCUMENT_META_PLACEHOLDER: () => DOCUMENT_META_PLACEHOLDER,
23
24
  DOCUMENT_NO_SCRIPTE_PLACEHOLDER: () => DOCUMENT_NO_SCRIPTE_PLACEHOLDER,
24
25
  DOCUMENT_SCRIPTS_PLACEHOLDER: () => DOCUMENT_SCRIPTS_PLACEHOLDER,
@@ -49,6 +50,9 @@ const DOCUMENT_FILE_NAME = "Document";
49
50
  const DOCUMENT_SCRIPTS_PLACEHOLDER = encodeURIComponent(
50
51
  "<!-- chunk scripts placeholder -->"
51
52
  );
53
+ const DOCUMENT_LINKS_PLACEHOLDER = encodeURIComponent(
54
+ "<!-- chunk links placeholder -->"
55
+ );
52
56
  const DOCUMENT_NO_SCRIPTE_PLACEHOLDER = encodeURIComponent("<!-- no-script -->");
53
57
  const DOCUMENT_SCRIPT_PLACEHOLDER_START = encodeURIComponent(
54
58
  "<!-- script-start -->"
@@ -66,6 +70,7 @@ const PLACEHOLDER_REPLACER_MAP = {
66
70
  0 && (module.exports = {
67
71
  DOCUMENT_CHUNKSMAP_PLACEHOLDER,
68
72
  DOCUMENT_FILE_NAME,
73
+ DOCUMENT_LINKS_PLACEHOLDER,
69
74
  DOCUMENT_META_PLACEHOLDER,
70
75
  DOCUMENT_NO_SCRIPTE_PLACEHOLDER,
71
76
  DOCUMENT_SCRIPTS_PLACEHOLDER,
@@ -20,6 +20,7 @@ __reExport(document_exports, require("./DocumentStructrueContext"), module.expor
20
20
  __reExport(document_exports, require("./Head"), module.exports);
21
21
  __reExport(document_exports, require("./Body"), module.exports);
22
22
  __reExport(document_exports, require("./Root"), module.exports);
23
+ __reExport(document_exports, require("./Links"), module.exports);
23
24
  __reExport(document_exports, require("./Scripts"), module.exports);
24
25
  __reExport(document_exports, require("./Script"), module.exports);
25
26
  __reExport(document_exports, require("./constants"), module.exports);
@@ -118,7 +118,7 @@ const routerPlugin = ({
118
118
  const baseUrl = request.baseUrl;
119
119
  const _basename = baseUrl === "/" ? (0, import_utils.urlJoin)(baseUrl, basename) : baseUrl;
120
120
  const routes = createRoutes ? createRoutes() : (0, import_react_router_dom.createRoutesFromElements)((0, import_utils.renderRoutes)(routesConfig));
121
- const { query } = (0, import_router.unstable_createStaticHandler)(routes, {
121
+ const { query } = (0, import_router.createStaticHandler)(routes, {
122
122
  basename: _basename
123
123
  });
124
124
  const remixRequest = createFetchRequest(request);
@@ -126,7 +126,7 @@ const routerPlugin = ({
126
126
  if (routerContext instanceof Response) {
127
127
  return routerContext;
128
128
  }
129
- const router = (0, import_server.unstable_createStaticRouter)(routes, routerContext);
129
+ const router = (0, import_server.createStaticRouter)(routes, routerContext);
130
130
  context.router = router;
131
131
  context.routerContext = routerContext;
132
132
  context.routes = routes;
@@ -142,7 +142,7 @@ const routerPlugin = ({
142
142
  return (props) => {
143
143
  const { router, routerContext } = (0, import_react.useContext)(import_core.RuntimeReactContext);
144
144
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadProps(__spreadValues({}, props), {
145
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_server.unstable_StaticRouterProvider, {
145
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_server.StaticRouterProvider, {
146
146
  router,
147
147
  context: routerContext,
148
148
  nonce: "the-nonce"
@@ -3,6 +3,7 @@ var DocumentStructrueContext = React.createContext({
3
3
  hasSetHead: false,
4
4
  hasSetScripts: false,
5
5
  hasSetBody: false,
6
- hasSetRoot: false
6
+ hasSetRoot: false,
7
+ hasSetLinks: false
7
8
  });
8
9
  export { DocumentStructrueContext };
@@ -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
- var hasSetScripts = useContext(DocumentStructrueContext).hasSetScripts;
8
+ var ref = useContext(DocumentStructrueContext), hasSetScripts = ref.hasSetScripts, hasSetLinks = ref.hasSetLinks;
8
9
  var children = props.children;
9
10
  return /* @__PURE__ */ jsxs("head", {
10
11
  children: [
11
12
  "".concat(DOCUMENT_META_PLACEHOLDER),
13
+ !hasSetLinks && /* @__PURE__ */ jsx(Links, {}),
12
14
  !hasSetScripts && /* @__PURE__ */ jsx(Scripts, {}),
13
15
  children
14
16
  ]
@@ -47,6 +47,7 @@ function Html(props) {
47
47
  var children = props.children;
48
48
  var hasSetHead = Boolean(findTargetChild("Head", children));
49
49
  var hasSetScripts = Boolean(findTargetElement("Scripts", children));
50
+ var hasSetLinks = Boolean(findTargetElement("Links", children));
50
51
  var hasSetBody = Boolean(findTargetChild("Body", children));
51
52
  var hasSetRoot = Boolean(findTargetElement("Root", children));
52
53
  var notMissMustChild = [
@@ -82,6 +83,7 @@ function Html(props) {
82
83
  value: {
83
84
  hasSetHead: hasSetHead,
84
85
  hasSetScripts: hasSetScripts,
86
+ hasSetLinks: hasSetLinks,
85
87
  hasSetRoot: hasSetRoot,
86
88
  hasSetBody: hasSetBody,
87
89
  docChild: children
@@ -0,0 +1,8 @@
1
+ import { Fragment, jsx } from "react/jsx-runtime";
2
+ import { DOCUMENT_LINKS_PLACEHOLDER } from "./constants";
3
+ function Links() {
4
+ return /* @__PURE__ */ jsx(Fragment, {
5
+ children: DOCUMENT_LINKS_PLACEHOLDER
6
+ });
7
+ }
8
+ export { Links };
@@ -181,7 +181,7 @@ import ReactDomServer from "react-dom/server";
181
181
  import { build } from "esbuild";
182
182
  import { createDebugger, findExists, fs } from "@modern-js/utils";
183
183
  import { DocumentContext } from "../DocumentContext";
184
- import { DOCUMENT_SCRIPTS_PLACEHOLDER, DOCUMENT_FILE_NAME, DOCUMENT_META_PLACEHOLDER, PLACEHOLDER_REPLACER_MAP, DOC_EXT, DOCUMENT_SSR_PLACEHOLDER, DOCUMENT_CHUNKSMAP_PLACEHOLDER, DOCUMENT_SSRDATASCRIPT_PLACEHOLDER, DOCUMENT_SCRIPT_PLACEHOLDER_START, DOCUMENT_SCRIPT_PLACEHOLDER_END, HTML_SEPARATOR } from "../constants";
184
+ import { DOCUMENT_SCRIPTS_PLACEHOLDER, DOCUMENT_LINKS_PLACEHOLDER, DOCUMENT_FILE_NAME, DOCUMENT_META_PLACEHOLDER, PLACEHOLDER_REPLACER_MAP, DOC_EXT, DOCUMENT_SSR_PLACEHOLDER, DOCUMENT_CHUNKSMAP_PLACEHOLDER, DOCUMENT_SSRDATASCRIPT_PLACEHOLDER, DOCUMENT_SCRIPT_PLACEHOLDER_START, DOCUMENT_SCRIPT_PLACEHOLDER_END, HTML_SEPARATOR } from "../constants";
185
185
  var debug = createDebugger("html_genarate");
186
186
  var getDocumenByEntryName = function getDocumenByEntryName(entrypoints, entryName, fallbackDir) {
187
187
  var ref;
@@ -230,7 +230,7 @@ var cli_default = function() {
230
230
  }
231
231
  return function() {
232
232
  var _ref = _asyncToGenerator(function(param) {
233
- var htmlWebpackPlugin, documentParams, tempTsConfigFile, userTsConfigFilePath, tsConfig, err, htmlOutputFile, Document, HTMLElement, html, scripts, metas, finalHtml;
233
+ var htmlWebpackPlugin, documentParams, tempTsConfigFile, userTsConfigFilePath, tsConfig, err, htmlOutputFile, Document, HTMLElement, html, scripts, links, metas, finalHtml;
234
234
  return __generator(this, function(_state) {
235
235
  switch(_state.label){
236
236
  case 0:
@@ -333,10 +333,15 @@ var cli_default = function() {
333
333
  }).join(""),
334
334
  htmlWebpackPlugin.tags.bodyTags.toString()
335
335
  ].join("");
336
+ links = [
337
+ htmlWebpackPlugin.tags.headTags.filter(function(item) {
338
+ return item.tagName === "link";
339
+ }).join("")
340
+ ].join("");
336
341
  metas = [
337
342
  templateParameters.meta,
338
343
  htmlWebpackPlugin.tags.headTags.filter(function(item) {
339
- return item.tagName !== "script";
344
+ return item.tagName !== "script" && item.tagName !== "link";
340
345
  }).join("")
341
346
  ].join("");
342
347
  if (html.includes(DOCUMENT_SCRIPT_PLACEHOLDER_START) && html.includes(DOCUMENT_SCRIPT_PLACEHOLDER_END)) {
@@ -344,7 +349,7 @@ var cli_default = function() {
344
349
  return "<script>".concat(decodeURIComponent($1), "</script>");
345
350
  });
346
351
  }
347
- finalHtml = "<!DOCTYPE html>".concat(html).replace(DOCUMENT_META_PLACEHOLDER, metas).replace(DOCUMENT_SSR_PLACEHOLDER, HTML_SEPARATOR).replace(DOCUMENT_SCRIPTS_PLACEHOLDER, scripts).replace(DOCUMENT_CHUNKSMAP_PLACEHOLDER, PLACEHOLDER_REPLACER_MAP[DOCUMENT_CHUNKSMAP_PLACEHOLDER]).replace(DOCUMENT_SSRDATASCRIPT_PLACEHOLDER, PLACEHOLDER_REPLACER_MAP[DOCUMENT_SSRDATASCRIPT_PLACEHOLDER]);
352
+ finalHtml = "<!DOCTYPE html>".concat(html).replace(DOCUMENT_META_PLACEHOLDER, metas).replace(DOCUMENT_SSR_PLACEHOLDER, HTML_SEPARATOR).replace(DOCUMENT_SCRIPTS_PLACEHOLDER, scripts).replace(DOCUMENT_LINKS_PLACEHOLDER, links).replace(DOCUMENT_CHUNKSMAP_PLACEHOLDER, PLACEHOLDER_REPLACER_MAP[DOCUMENT_CHUNKSMAP_PLACEHOLDER]).replace(DOCUMENT_SSRDATASCRIPT_PLACEHOLDER, PLACEHOLDER_REPLACER_MAP[DOCUMENT_SSRDATASCRIPT_PLACEHOLDER]);
348
353
  return [
349
354
  2,
350
355
  finalHtml
@@ -26,9 +26,10 @@ var DOCUMENT_CHUNKSMAP_PLACEHOLDER = encodeURIComponent(HTML_CHUNKSMAP_SEPARATOR
26
26
  var DOCUMENT_SSRDATASCRIPT_PLACEHOLDER = encodeURIComponent(HTML_SSRDATASCRIPT_SEPARATOR);
27
27
  var DOCUMENT_FILE_NAME = "Document";
28
28
  var DOCUMENT_SCRIPTS_PLACEHOLDER = encodeURIComponent("<!-- chunk scripts placeholder -->");
29
+ var DOCUMENT_LINKS_PLACEHOLDER = encodeURIComponent("<!-- chunk links placeholder -->");
29
30
  var DOCUMENT_NO_SCRIPTE_PLACEHOLDER = encodeURIComponent("<!-- no-script -->");
30
31
  var DOCUMENT_SCRIPT_PLACEHOLDER_START = encodeURIComponent("<!-- script-start -->");
31
32
  var DOCUMENT_SCRIPT_PLACEHOLDER_END = encodeURIComponent("<!-- script-end -->");
32
33
  var _obj;
33
34
  var PLACEHOLDER_REPLACER_MAP = (_obj = {}, _defineProperty(_obj, DOCUMENT_NO_SCRIPTE_PLACEHOLDER, "We're sorry but react app doesn't work properly without JavaScript enabled. Please enable it to continue."), _defineProperty(_obj, DOCUMENT_SSR_PLACEHOLDER, HTML_SEPARATOR), _defineProperty(_obj, DOCUMENT_CHUNKSMAP_PLACEHOLDER, HTML_CHUNKSMAP_SEPARATOR), _defineProperty(_obj, DOCUMENT_SSRDATASCRIPT_PLACEHOLDER, HTML_SSRDATASCRIPT_SEPARATOR), _obj);
34
- export { DOCUMENT_CHUNKSMAP_PLACEHOLDER, DOCUMENT_FILE_NAME, DOCUMENT_META_PLACEHOLDER, DOCUMENT_NO_SCRIPTE_PLACEHOLDER, DOCUMENT_SCRIPTS_PLACEHOLDER, DOCUMENT_SCRIPT_PLACEHOLDER_END, DOCUMENT_SCRIPT_PLACEHOLDER_START, DOCUMENT_SSRDATASCRIPT_PLACEHOLDER, DOCUMENT_SSR_PLACEHOLDER, DOC_EXT, HTML_CHUNKSMAP_SEPARATOR, HTML_SEPARATOR, HTML_SSRDATASCRIPT_SEPARATOR, PLACEHOLDER_REPLACER_MAP };
35
+ export { DOCUMENT_CHUNKSMAP_PLACEHOLDER, DOCUMENT_FILE_NAME, DOCUMENT_LINKS_PLACEHOLDER, DOCUMENT_META_PLACEHOLDER, DOCUMENT_NO_SCRIPTE_PLACEHOLDER, DOCUMENT_SCRIPTS_PLACEHOLDER, DOCUMENT_SCRIPT_PLACEHOLDER_END, DOCUMENT_SCRIPT_PLACEHOLDER_START, DOCUMENT_SSRDATASCRIPT_PLACEHOLDER, DOCUMENT_SSR_PLACEHOLDER, DOC_EXT, HTML_CHUNKSMAP_SEPARATOR, HTML_SEPARATOR, HTML_SSRDATASCRIPT_SEPARATOR, PLACEHOLDER_REPLACER_MAP };
@@ -4,6 +4,7 @@ export * from "./DocumentStructrueContext";
4
4
  export * from "./Head";
5
5
  export * from "./Body";
6
6
  export * from "./Root";
7
+ export * from "./Links";
7
8
  export * from "./Scripts";
8
9
  export * from "./Script";
9
10
  export * from "./constants";
@@ -229,8 +229,8 @@ var __generator = this && this.__generator || function(thisArg, body) {
229
229
  };
230
230
  import { jsx } from "react/jsx-runtime";
231
231
  import { useContext } from "react";
232
- import { unstable_createStaticHandler as createStaticHandler } from "@remix-run/router";
233
- import { unstable_createStaticRouter as createStaticRouter, unstable_StaticRouterProvider as StaticRouterProvider } from "react-router-dom/server";
232
+ import { createStaticHandler } from "@remix-run/router";
233
+ import { createStaticRouter, StaticRouterProvider } from "react-router-dom/server";
234
234
  import hoistNonReactStatics from "hoist-non-react-statics";
235
235
  import { installGlobals } from "@remix-run/node";
236
236
  import { createRoutesFromElements } from "react-router-dom";
@@ -2,6 +2,7 @@ import React, { ReactNode } from 'react';
2
2
  declare type DocumentStructrueContextProps = {
3
3
  hasSetHead?: boolean;
4
4
  hasSetScripts?: boolean;
5
+ hasSetLinks?: boolean;
5
6
  hasSetBody?: boolean;
6
7
  hasSetRoot?: boolean;
7
8
  docChild?: ReactNode;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function Links(): JSX.Element;
@@ -8,6 +8,7 @@ export declare const DOCUMENT_CHUNKSMAP_PLACEHOLDER: string;
8
8
  export declare const DOCUMENT_SSRDATASCRIPT_PLACEHOLDER: string;
9
9
  export declare const DOCUMENT_FILE_NAME = "Document";
10
10
  export declare const DOCUMENT_SCRIPTS_PLACEHOLDER: string;
11
+ export declare const DOCUMENT_LINKS_PLACEHOLDER: string;
11
12
  export declare const DOCUMENT_NO_SCRIPTE_PLACEHOLDER: string;
12
13
  export declare const DOCUMENT_SCRIPT_PLACEHOLDER_START: string;
13
14
  export declare const DOCUMENT_SCRIPT_PLACEHOLDER_END: string;
@@ -4,6 +4,7 @@ export * from './DocumentStructrueContext';
4
4
  export * from './Head';
5
5
  export * from './Body';
6
6
  export * from './Root';
7
+ export * from './Links';
7
8
  export * from './Scripts';
8
9
  export * from './Script';
9
10
  export * from './constants';
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.0.0-beta.5",
14
+ "version": "2.0.0-beta.7",
15
15
  "engines": {
16
16
  "node": ">=14.17.6"
17
17
  },
@@ -128,21 +128,20 @@
128
128
  },
129
129
  "dependencies": {
130
130
  "@babel/core": "^7.18.0",
131
- "@babel/types": "^7.18.0",
132
131
  "@babel/runtime": "^7.18.0",
132
+ "@babel/types": "^7.18.0",
133
133
  "@loadable/babel-plugin": "^5.13.2",
134
- "@loadable/webpack-plugin": "5.15.2",
135
134
  "@loadable/component": "^5.15.0",
136
135
  "@loadable/server": "^5.15.1",
136
+ "@loadable/webpack-plugin": "5.15.2",
137
137
  "@modern-js-reduck/plugin-auto-actions": "^1.1.4",
138
138
  "@modern-js-reduck/plugin-devtools": "^1.1.4",
139
139
  "@modern-js-reduck/plugin-effects": "^1.1.4",
140
140
  "@modern-js-reduck/plugin-immutable": "^1.1.4",
141
141
  "@modern-js-reduck/react": "^1.1.4",
142
142
  "@modern-js-reduck/store": "^1.1.4",
143
- "@modern-js/plugin": "2.0.0-beta.4",
144
- "@modern-js/types": "2.0.0-beta.4",
145
- "@modern-js/utils": "2.0.0-beta.4",
143
+ "@remix-run/node": "^1.9.0",
144
+ "@remix-run/router": "^1.2.0",
146
145
  "@types/loadable__component": "^5.13.4",
147
146
  "@types/react-helmet": "^6.1.2",
148
147
  "@types/redux-logger": "^3.0.9",
@@ -150,28 +149,24 @@
150
149
  "hoist-non-react-statics": "^3.3.2",
151
150
  "invariant": "^2.2.4",
152
151
  "react-helmet": "^6.1.0",
153
- "@remix-run/node": "^1.7.0",
154
- "@remix-run/router": "^1.0.4",
155
152
  "react-is": "^18",
156
- "react-router-dom": "^6.4.4",
153
+ "react-router-dom": "^6.6.0",
157
154
  "react-side-effect": "^2.1.1",
158
155
  "redux-logger": "^3.0.6",
159
156
  "serialize-javascript": "^6.0.0",
160
- "styled-components": "^5.3.1"
157
+ "styled-components": "^5.3.1",
158
+ "@modern-js/plugin": "2.0.0-beta.7",
159
+ "@modern-js/types": "2.0.0-beta.7",
160
+ "@modern-js/utils": "2.0.0-beta.7"
161
161
  },
162
162
  "peerDependencies": {
163
163
  "react": ">=17",
164
164
  "react-dom": ">=17"
165
165
  },
166
166
  "devDependencies": {
167
- "@modern-js/core": "2.0.0-beta.4",
168
- "@modern-js/server-core": "2.0.0-beta.4",
169
- "@scripts/build": "2.0.0-beta.4",
170
- "@modern-js/app-tools": "2.0.0-beta.4",
171
- "@scripts/jest-config": "2.0.0-beta.4",
167
+ "@remix-run/web-fetch": "^4.1.3",
172
168
  "@testing-library/react": "^13.4.0",
173
169
  "@testing-library/react-hooks": "^8.0.1",
174
- "@remix-run/web-fetch": "^4.1.3",
175
170
  "@types/invariant": "^2.2.30",
176
171
  "@types/jest": "^27",
177
172
  "@types/loadable__webpack-plugin": "^5.7.3",
@@ -182,7 +177,12 @@
182
177
  "react": "^18",
183
178
  "react-dom": "^18",
184
179
  "ts-jest": "^27.0.4",
185
- "typescript": "^4"
180
+ "typescript": "^4",
181
+ "@modern-js/app-tools": "2.0.0-beta.7",
182
+ "@modern-js/core": "2.0.0-beta.7",
183
+ "@modern-js/server-core": "2.0.0-beta.7",
184
+ "@scripts/jest-config": "2.0.0-beta.7",
185
+ "@scripts/build": "2.0.0-beta.7"
186
186
  },
187
187
  "sideEffects": false,
188
188
  "modernConfig": {},