@modern-js/runtime 2.58.2-alpha.0 → 2.58.3
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/dist/cjs/cli/code.js +1 -1
- package/dist/cjs/cli/index.js +11 -14
- package/dist/cjs/cli/ssr/babel-plugin-ssr-loader-id.js +1 -1
- package/dist/cjs/cli/ssr/index.js +14 -1
- package/dist/cjs/cli/template.js +1 -1
- package/dist/cjs/core/browser/hydrate.js +1 -1
- package/dist/cjs/core/browser/index.js +36 -17
- package/dist/cjs/core/compatible.js +4 -4
- package/dist/cjs/core/context/runtime.js +1 -1
- package/dist/cjs/core/loader/loaderManager.js +1 -1
- package/dist/cjs/core/loader/useLoader.js +1 -1
- package/dist/cjs/core/server/react/prerender/index.js +1 -1
- package/dist/cjs/core/server/requestHandler.js +14 -6
- package/dist/cjs/core/server/stream/afterTemplate.js +1 -1
- package/dist/cjs/core/server/stream/beforeTemplate.js +3 -3
- package/dist/cjs/core/server/stream/createReadableStream.js +2 -2
- package/dist/cjs/core/server/stream/createReadableStream.worker.js +2 -2
- package/dist/cjs/core/server/stream/shared.js +1 -1
- package/dist/cjs/core/server/stream/template.js +1 -1
- package/dist/cjs/core/server/string/index.js +29 -29
- package/dist/cjs/core/server/string/prefetch.js +5 -5
- package/dist/cjs/core/server/string/ssrData.js +1 -1
- package/dist/cjs/document/Body.js +1 -1
- package/dist/cjs/document/Head.js +1 -1
- package/dist/cjs/document/Root.js +1 -1
- package/dist/cjs/document/cli/index.js +2 -2
- package/dist/cjs/router/cli/code/getClientRoutes/getRoutes.js +1 -1
- package/dist/cjs/router/cli/code/getClientRoutes/getRoutesLegacy.js +1 -1
- package/dist/cjs/router/cli/code/index.js +6 -6
- package/dist/cjs/router/cli/code/templates.js +15 -8
- package/dist/cjs/router/cli/code/utils.js +1 -1
- package/dist/cjs/router/cli/handler.js +2 -2
- package/dist/cjs/router/runtime/DeferredDataScripts.node.js +2 -2
- package/dist/cjs/router/runtime/PrefetchLink.js +1 -1
- package/dist/cjs/router/runtime/plugin.js +4 -4
- package/dist/cjs/router/runtime/plugin.node.js +6 -6
- package/dist/cjs/router/runtime/utils.js +2 -2
- package/dist/cjs/state/plugins.js +1 -1
- package/dist/cjs/state/runtime/plugin.js +6 -6
- package/dist/esm/cli/code.js +3 -4
- package/dist/esm/cli/index.js +7 -10
- package/dist/esm/cli/ssr/babel-plugin-ssr-loader-id.js +1 -1
- package/dist/esm/cli/ssr/index.js +16 -1
- package/dist/esm/cli/template.js +1 -1
- package/dist/esm/core/browser/hydrate.js +1 -1
- package/dist/esm/core/browser/index.js +33 -14
- package/dist/esm/core/browser/withCallback.js +1 -1
- package/dist/esm/core/compatible.js +4 -4
- package/dist/esm/core/context/runtime.js +1 -1
- package/dist/esm/core/loader/loaderManager.js +3 -1
- package/dist/esm/core/loader/useLoader.js +1 -1
- package/dist/esm/core/plugin/base.js +1 -1
- package/dist/esm/core/plugin/index.js +1 -1
- package/dist/esm/core/server/react/prerender/index.js +2 -2
- package/dist/esm/core/server/requestHandler.js +13 -6
- package/dist/esm/core/server/stream/afterTemplate.js +1 -1
- package/dist/esm/core/server/stream/beforeTemplate.js +3 -3
- package/dist/esm/core/server/stream/createReadableStream.js +2 -2
- package/dist/esm/core/server/stream/createReadableStream.worker.js +2 -2
- package/dist/esm/core/server/stream/shared.js +1 -1
- package/dist/esm/core/server/stream/template.js +1 -1
- package/dist/esm/core/server/string/index.js +12 -15
- package/dist/esm/core/server/string/prefetch.js +2 -2
- package/dist/esm/core/server/string/ssrData.js +1 -1
- package/dist/esm/document/Body.js +1 -1
- package/dist/esm/document/Comment.js +1 -1
- package/dist/esm/document/Head.js +1 -1
- package/dist/esm/document/Root.js +1 -1
- package/dist/esm/document/Script.js +1 -1
- package/dist/esm/document/Style.js +1 -1
- package/dist/esm/document/cli/index.js +3 -3
- package/dist/esm/router/cli/code/getClientRoutes/getRoutes.js +2 -2
- package/dist/esm/router/cli/code/getClientRoutes/getRoutesLegacy.js +2 -2
- package/dist/esm/router/cli/code/getClientRoutes/utils.js +2 -2
- package/dist/esm/router/cli/code/index.js +4 -4
- package/dist/esm/router/cli/code/nestedRoutes.js +1 -1
- package/dist/esm/router/cli/code/templates.js +2 -2
- package/dist/esm/router/cli/code/utils.js +2 -2
- package/dist/esm/router/cli/entry.js +1 -1
- package/dist/esm/router/cli/handler.js +2 -2
- package/dist/esm/router/cli/index.js +1 -1
- package/dist/esm/router/runtime/DeferredDataScripts.node.js +2 -2
- package/dist/esm/router/runtime/PrefetchLink.js +1 -1
- package/dist/esm/router/runtime/plugin.js +4 -4
- package/dist/esm/router/runtime/plugin.node.js +6 -6
- package/dist/esm/router/runtime/utils.js +2 -2
- package/dist/esm/state/plugins.js +1 -1
- package/dist/esm/state/runtime/plugin.js +4 -4
- package/dist/esm-node/cli/code.js +3 -3
- package/dist/esm-node/cli/index.js +7 -10
- package/dist/esm-node/cli/ssr/babel-plugin-ssr-loader-id.js +1 -1
- package/dist/esm-node/cli/ssr/index.js +14 -1
- package/dist/esm-node/cli/template.js +1 -1
- package/dist/esm-node/core/browser/hydrate.js +1 -1
- package/dist/esm-node/core/browser/index.js +36 -17
- package/dist/esm-node/core/browser/withCallback.js +1 -1
- package/dist/esm-node/core/compatible.js +4 -4
- package/dist/esm-node/core/context/runtime.js +1 -1
- package/dist/esm-node/core/loader/loaderManager.js +1 -1
- package/dist/esm-node/core/loader/useLoader.js +1 -1
- package/dist/esm-node/core/plugin/base.js +1 -1
- package/dist/esm-node/core/plugin/index.js +1 -1
- package/dist/esm-node/core/server/react/prerender/index.js +2 -2
- package/dist/esm-node/core/server/requestHandler.js +13 -5
- package/dist/esm-node/core/server/stream/afterTemplate.js +1 -1
- package/dist/esm-node/core/server/stream/beforeTemplate.js +3 -3
- package/dist/esm-node/core/server/stream/createReadableStream.js +2 -2
- package/dist/esm-node/core/server/stream/createReadableStream.worker.js +2 -2
- package/dist/esm-node/core/server/stream/shared.js +1 -1
- package/dist/esm-node/core/server/stream/template.js +1 -1
- package/dist/esm-node/core/server/string/index.js +21 -21
- package/dist/esm-node/core/server/string/prefetch.js +2 -2
- package/dist/esm-node/core/server/string/ssrData.js +1 -1
- package/dist/esm-node/document/Body.js +1 -1
- package/dist/esm-node/document/Comment.js +1 -1
- package/dist/esm-node/document/Head.js +1 -1
- package/dist/esm-node/document/Root.js +1 -1
- package/dist/esm-node/document/Script.js +1 -1
- package/dist/esm-node/document/Style.js +1 -1
- package/dist/esm-node/document/cli/index.js +3 -3
- package/dist/esm-node/router/cli/code/getClientRoutes/getRoutes.js +2 -2
- package/dist/esm-node/router/cli/code/getClientRoutes/getRoutesLegacy.js +2 -2
- package/dist/esm-node/router/cli/code/getClientRoutes/utils.js +2 -2
- package/dist/esm-node/router/cli/code/index.js +4 -4
- package/dist/esm-node/router/cli/code/nestedRoutes.js +1 -1
- package/dist/esm-node/router/cli/code/templates.js +16 -9
- package/dist/esm-node/router/cli/code/utils.js +2 -2
- package/dist/esm-node/router/cli/entry.js +1 -1
- package/dist/esm-node/router/cli/handler.js +2 -2
- package/dist/esm-node/router/cli/index.js +1 -1
- package/dist/esm-node/router/runtime/DeferredDataScripts.node.js +2 -2
- package/dist/esm-node/router/runtime/PrefetchLink.js +1 -1
- package/dist/esm-node/router/runtime/plugin.js +4 -4
- package/dist/esm-node/router/runtime/plugin.node.js +6 -6
- package/dist/esm-node/router/runtime/utils.js +2 -2
- package/dist/esm-node/state/plugins.js +1 -1
- package/dist/esm-node/state/runtime/plugin.js +4 -4
- package/dist/types/cli/alias.d.ts +1 -1
- package/dist/types/cli/code.d.ts +1 -1
- package/dist/types/cli/index.d.ts +3 -3
- package/dist/types/cli/ssr/index.d.ts +1 -1
- package/dist/types/common.d.ts +1 -1
- package/dist/types/config.d.ts +1 -1
- package/dist/types/core/browser/hydrate.d.ts +3 -3
- package/dist/types/core/browser/index.d.ts +1 -1
- package/dist/types/core/browser/withCallback.d.ts +1 -1
- package/dist/types/core/compatible.d.ts +3 -3
- package/dist/types/core/config.d.ts +1 -1
- package/dist/types/core/context/index.d.ts +1 -1
- package/dist/types/core/context/runtime.d.ts +5 -5
- package/dist/types/core/loader/loaderManager.d.ts +2 -2
- package/dist/types/core/plugin/base.d.ts +2 -2
- package/dist/types/core/plugin/index.d.ts +1 -1
- package/dist/types/core/plugin/runner.d.ts +1 -1
- package/dist/types/core/react/index.d.ts +1 -1
- package/dist/types/core/react/wrapper.d.ts +1 -1
- package/dist/types/core/server/helmet.d.ts +1 -1
- package/dist/types/core/server/index.d.ts +1 -1
- package/dist/types/core/server/react/nossr/index.d.ts +1 -1
- package/dist/types/core/server/react/prerender/util.d.ts +1 -1
- package/dist/types/core/server/requestHandler.d.ts +3 -3
- package/dist/types/core/server/stream/afterTemplate.d.ts +4 -4
- package/dist/types/core/server/stream/beforeTemplate.d.ts +2 -2
- package/dist/types/core/server/stream/createReadableStream.d.ts +1 -1
- package/dist/types/core/server/stream/createReadableStream.worker.d.ts +1 -1
- package/dist/types/core/server/stream/shared.d.ts +3 -3
- package/dist/types/core/server/stream/template.d.ts +1 -1
- package/dist/types/core/server/string/index.d.ts +1 -1
- package/dist/types/core/server/string/loadable.d.ts +2 -2
- package/dist/types/core/server/string/prefetch.d.ts +5 -5
- package/dist/types/core/server/string/ssrData.d.ts +4 -4
- package/dist/types/core/server/string/styledComponent.d.ts +1 -1
- package/dist/types/core/server/string/types.d.ts +2 -2
- package/dist/types/core/server/utils.d.ts +3 -3
- package/dist/types/core/types.d.ts +2 -2
- package/dist/types/document/DocumentStructureContext.d.ts +1 -1
- package/dist/types/document/cli/index.d.ts +2 -2
- package/dist/types/exports/server.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/router/cli/code/index.d.ts +2 -2
- package/dist/types/router/cli/code/templates.d.ts +1 -1
- package/dist/types/router/cli/entry.d.ts +1 -1
- package/dist/types/router/cli/handler.d.ts +3 -3
- package/dist/types/router/cli/index.d.ts +1 -1
- package/dist/types/router/runtime/DeferredDataScripts.node.d.ts +1 -1
- package/dist/types/router/runtime/PrefetchLink.d.ts +1 -1
- package/dist/types/router/runtime/hooks.d.ts +1 -1
- package/dist/types/router/runtime/index.d.ts +1 -1
- package/dist/types/router/runtime/plugin.d.ts +1 -1
- package/dist/types/router/runtime/routeModule.d.ts +1 -1
- package/dist/types/router/runtime/types.d.ts +2 -2
- package/dist/types/router/runtime/utils.d.ts +4 -4
- package/dist/types/router/runtime/withRouter.d.ts +1 -1
- package/dist/types/state/cli/index.d.ts +1 -1
- package/package.json +13 -12
- package/types/index.d.ts +1 -1
- package/types/router.d.ts +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
3
3
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
4
|
-
import { buildShellBeforeTemplate } from "./beforeTemplate";
|
|
5
4
|
import { buildShellAfterTemplate } from "./afterTemplate";
|
|
5
|
+
import { buildShellBeforeTemplate } from "./beforeTemplate";
|
|
6
6
|
var HTML_SEPARATOR = "<!--<?- html ?>-->";
|
|
7
7
|
var getTemplates = function() {
|
|
8
8
|
var _ref = _async_to_generator(function(htmlTemplate, options) {
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
3
3
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
4
|
-
import ReactHelmet from "react-helmet";
|
|
5
|
-
import ReactDomServer from "react-dom/server";
|
|
6
|
-
import { time } from "@modern-js/runtime-utils/time";
|
|
7
4
|
import { run } from "@modern-js/runtime-utils/node";
|
|
5
|
+
import { time } from "@modern-js/runtime-utils/time";
|
|
8
6
|
import { parseHeaders } from "@modern-js/runtime-utils/universal/request";
|
|
7
|
+
import ReactDomServer from "react-dom/server";
|
|
8
|
+
import ReactHelmet from "react-helmet";
|
|
9
|
+
import { RenderLevel } from "../../constants";
|
|
9
10
|
import { wrapRuntimeContextProvider } from "../../react/wrapper";
|
|
10
|
-
import { createReplaceHelemt } from "../helmet";
|
|
11
|
-
import { getSSRConfigByEntry, safeReplace } from "../utils";
|
|
12
11
|
import { CHUNK_CSS_PLACEHOLDER, CHUNK_JS_PLACEHOLDER, HTML_PLACEHOLDER, SSR_DATA_PLACEHOLDER } from "../constants";
|
|
12
|
+
import { createReplaceHelemt } from "../helmet";
|
|
13
13
|
import { buildHtml } from "../shared";
|
|
14
14
|
import { SSRErrors, SSRTimings, createOnError, createOnTiming } from "../tracer";
|
|
15
|
-
import {
|
|
16
|
-
import { SSRDataCollector } from "./ssrData";
|
|
15
|
+
import { getSSRConfigByEntry, safeReplace } from "../utils";
|
|
17
16
|
import { LoadableCollector } from "./loadable";
|
|
18
|
-
import { StyledCollector } from "./styledComponent";
|
|
19
17
|
import { prefetch } from "./prefetch";
|
|
18
|
+
import { SSRDataCollector } from "./ssrData";
|
|
19
|
+
import { StyledCollector } from "./styledComponent";
|
|
20
20
|
var renderString = function() {
|
|
21
21
|
var _ref = _async_to_generator(function(request, serverRoot, options) {
|
|
22
22
|
var headersData;
|
|
@@ -128,11 +128,6 @@ function _generateHtml() {
|
|
|
128
128
|
onError = param.onError, onTiming = param.onTiming;
|
|
129
129
|
end = time();
|
|
130
130
|
html = "";
|
|
131
|
-
if (!(chunkSet.renderLevel >= RenderLevel.SERVER_PREFETCH))
|
|
132
|
-
return [
|
|
133
|
-
3,
|
|
134
|
-
4
|
|
135
|
-
];
|
|
136
131
|
_state.label = 1;
|
|
137
132
|
case 1:
|
|
138
133
|
_state.trys.push([
|
|
@@ -145,9 +140,11 @@ function _generateHtml() {
|
|
|
145
140
|
var _creator_collect;
|
|
146
141
|
return ((_creator_collect = creator.collect) === null || _creator_collect === void 0 ? void 0 : _creator_collect.call(creator, pre)) || pre;
|
|
147
142
|
}, App);
|
|
148
|
-
|
|
143
|
+
if (chunkSet.renderLevel >= RenderLevel.SERVER_PREFETCH) {
|
|
144
|
+
html = ReactDomServer.renderToString(finalApp);
|
|
145
|
+
chunkSet.renderLevel = RenderLevel.SERVER_RENDER;
|
|
146
|
+
}
|
|
149
147
|
helmetData = ReactHelmet.renderStatic();
|
|
150
|
-
chunkSet.renderLevel = RenderLevel.SERVER_RENDER;
|
|
151
148
|
return [
|
|
152
149
|
4,
|
|
153
150
|
Promise.all(collectors.map(function(component) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
|
-
import { renderToStaticMarkup } from "react-dom/server";
|
|
4
|
-
import { run } from "@modern-js/runtime-utils/node";
|
|
5
3
|
import { ChunkExtractor } from "@loadable/server";
|
|
4
|
+
import { run } from "@modern-js/runtime-utils/node";
|
|
6
5
|
import { time } from "@modern-js/runtime-utils/time";
|
|
7
6
|
import { parseHeaders } from "@modern-js/runtime-utils/universal/request";
|
|
7
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
8
8
|
import { wrapRuntimeContextProvider } from "../../react/wrapper";
|
|
9
9
|
import { SSRErrors, SSRTimings } from "../tracer";
|
|
10
10
|
var prefetch = function() {
|
|
@@ -6,8 +6,8 @@ import { _ as _class_private_method_get } from "@swc/helpers/_/_class_private_me
|
|
|
6
6
|
import { _ as _class_private_method_init } from "@swc/helpers/_/_class_private_method_init";
|
|
7
7
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
8
8
|
import { serializeJson } from "@modern-js/runtime-utils/node";
|
|
9
|
-
import { attributesToString, serializeErrors } from "../utils";
|
|
10
9
|
import { ROUTER_DATA_JSON_ID, SSR_DATA_JSON_ID } from "../../constants";
|
|
10
|
+
import { attributesToString, serializeErrors } from "../utils";
|
|
11
11
|
var _options = /* @__PURE__ */ new WeakMap(), _getSSRData = /* @__PURE__ */ new WeakSet(), _getSSRDataScripts = /* @__PURE__ */ new WeakSet();
|
|
12
12
|
var SSRDataCollector = /* @__PURE__ */ function() {
|
|
13
13
|
"use strict";
|
|
@@ -3,9 +3,9 @@ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
|
3
3
|
import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
|
|
4
4
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { useContext } from "react";
|
|
6
|
-
import { BODY_PARTICALS_SEPARATOR, DOCUMENT_CHUNKSMAP_PLACEHOLDER, DOCUMENT_SSRDATASCRIPT_PLACEHOLDER } from "./constants";
|
|
7
6
|
import { DocumentStructureContext } from "./DocumentStructureContext";
|
|
8
7
|
import { DefaultRoot } from "./Root";
|
|
8
|
+
import { BODY_PARTICALS_SEPARATOR, DOCUMENT_CHUNKSMAP_PLACEHOLDER, DOCUMENT_SSRDATASCRIPT_PLACEHOLDER } from "./constants";
|
|
9
9
|
function Body(props) {
|
|
10
10
|
var hasSetRoot = useContext(DocumentStructureContext).hasSetRoot;
|
|
11
11
|
var children = props.children, rest = _object_without_properties(props, [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { DOCUMENT_COMMENT_PLACEHOLDER_END, DOCUMENT_COMMENT_PLACEHOLDER_START } from "./constants";
|
|
3
3
|
function Comment(props) {
|
|
4
4
|
var comment = props.comment, children = props.children;
|
|
5
5
|
var commentStr = encodeURIComponent(children || comment || "");
|
|
@@ -4,8 +4,8 @@ import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_
|
|
|
4
4
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { useContext } from "react";
|
|
6
6
|
import { DocumentStructureContext } from "./DocumentStructureContext";
|
|
7
|
-
import { Scripts } from "./Scripts";
|
|
8
7
|
import { Links } from "./Links";
|
|
8
|
+
import { Scripts } from "./Scripts";
|
|
9
9
|
import { Title } from "./Title";
|
|
10
10
|
import { DOCUMENT_META_PLACEHOLDER, HEAD_PARTICALS_SEPARATOR, TOP_PARTICALS_SEPARATOR } from "./constants";
|
|
11
11
|
function Head(props) {
|
|
@@ -2,8 +2,8 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
|
2
2
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
3
3
|
import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
|
|
4
4
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
-
import { useContext } from "react";
|
|
6
5
|
import { omit } from "@modern-js/utils/lodash";
|
|
6
|
+
import { useContext } from "react";
|
|
7
7
|
import { DocumentContext } from "./DocumentContext";
|
|
8
8
|
import { DOCUMENT_SSR_PLACEHOLDER } from "./constants";
|
|
9
9
|
function Root(props) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { DOCUMENT_SCRIPT_PLACEHOLDER_END, DOCUMENT_SCRIPT_PLACEHOLDER_START } from "./constants";
|
|
3
3
|
function Script(props) {
|
|
4
4
|
var content = props.content;
|
|
5
5
|
var contentStr = content.toString();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { DOCUMENT_STYLE_PLACEHOLDER_END, DOCUMENT_STYLE_PLACEHOLDER_START } from "./constants";
|
|
3
3
|
function Style(props) {
|
|
4
4
|
var content = props.content, children = props.children;
|
|
5
5
|
var contentStr = children || content;
|
|
@@ -3,12 +3,12 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
|
3
3
|
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
4
4
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
5
5
|
import path from "path";
|
|
6
|
+
import { fs, createDebugger, findExists } from "@modern-js/utils";
|
|
7
|
+
import { build } from "esbuild";
|
|
6
8
|
import React from "react";
|
|
7
9
|
import ReactDomServer from "react-dom/server";
|
|
8
|
-
import { build } from "esbuild";
|
|
9
|
-
import { createDebugger, findExists, fs } from "@modern-js/utils";
|
|
10
10
|
import { DocumentContext } from "../DocumentContext";
|
|
11
|
-
import {
|
|
11
|
+
import { BODY_PARTICALS_SEPARATOR, DOCUMENT_CHUNKSMAP_PLACEHOLDER, DOCUMENT_COMMENT_PLACEHOLDER_END, DOCUMENT_COMMENT_PLACEHOLDER_START, DOCUMENT_FILE_NAME, DOCUMENT_LINKS_PLACEHOLDER, DOCUMENT_META_PLACEHOLDER, DOCUMENT_SCRIPTS_PLACEHOLDER, DOCUMENT_SCRIPT_PLACEHOLDER_END, DOCUMENT_SCRIPT_PLACEHOLDER_START, DOCUMENT_SSRDATASCRIPT_PLACEHOLDER, DOCUMENT_SSR_PLACEHOLDER, DOCUMENT_STYLE_PLACEHOLDER_END, DOCUMENT_STYLE_PLACEHOLDER_START, DOCUMENT_TITLE_PLACEHOLDER, DOC_EXT, HEAD_PARTICALS_SEPARATOR, HTML_SEPARATOR, PLACEHOLDER_REPLACER_MAP, TOP_PARTICALS_SEPARATOR } from "../constants";
|
|
12
12
|
var debug = createDebugger("html_genarate");
|
|
13
13
|
var getDocumenByEntryName = function getDocumenByEntryName2(entrypoints, entryName, fallbackDir) {
|
|
14
14
|
var _entrypoints_find;
|
|
@@ -2,10 +2,10 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
|
2
2
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { fs } from "@modern-js/utils";
|
|
5
|
-
import { makeLegalIdentifier } from "../makeLegalIdentifier";
|
|
6
5
|
import { FILE_SYSTEM_ROUTES_COMPONENTS_DIR, FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP, FILE_SYSTEM_ROUTES_INDEX, FILE_SYSTEM_ROUTES_LAYOUT } from "../../constants";
|
|
6
|
+
import { makeLegalIdentifier } from "../makeLegalIdentifier";
|
|
7
7
|
import { replaceWithAlias } from "../utils";
|
|
8
|
-
import { debug, findLayout,
|
|
8
|
+
import { debug, findLayout, getRouteWeight, shouldSkip } from "./utils";
|
|
9
9
|
var compName = function(srcDirectory, filePath) {
|
|
10
10
|
var legalCompName = makeLegalIdentifier(path.relative(srcDirectory, filePath));
|
|
11
11
|
return "Comp_".concat(legalCompName);
|
|
@@ -3,9 +3,9 @@ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { fs } from "@modern-js/utils";
|
|
5
5
|
import { FILE_SYSTEM_ROUTES_COMPONENTS_DIR, FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP, FILE_SYSTEM_ROUTES_INDEX, FILE_SYSTEM_ROUTES_LAYOUT } from "../../constants";
|
|
6
|
-
import { replaceWithAlias } from "../utils";
|
|
7
6
|
import { makeLegalIdentifier } from "../makeLegalIdentifier";
|
|
8
|
-
import {
|
|
7
|
+
import { replaceWithAlias } from "../utils";
|
|
8
|
+
import { debug, findLayout, getRouteWeight, shouldSkip } from "./utils";
|
|
9
9
|
var compName = function(srcDirectory, filePath) {
|
|
10
10
|
var legalCompName = makeLegalIdentifier(path.relative(srcDirectory, filePath));
|
|
11
11
|
return "Comp_".concat(legalCompName);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import { JS_EXTENSIONS, createDebugger, findExists
|
|
3
|
-
import {
|
|
2
|
+
import { fs, JS_EXTENSIONS, createDebugger, findExists } from "@modern-js/utils";
|
|
3
|
+
import { FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT, FILE_SYSTEM_ROUTES_IGNORED_REGEX, FILE_SYSTEM_ROUTES_LAYOUT } from "../../constants";
|
|
4
4
|
var debug = createDebugger("get-client-routes");
|
|
5
5
|
var findLayout = function(dir) {
|
|
6
6
|
return findExists(JS_EXTENSIONS.map(function(ext) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import { fs, getEntryOptions, isRouterV5, isSSGEntry, isUseSSRBundle, logger
|
|
4
|
+
import { fs, filterRoutesForServer, filterRoutesLoader, getEntryOptions, isRouterV5, isSSGEntry, isUseSSRBundle, logger } from "@modern-js/utils";
|
|
5
5
|
import { cloneDeep } from "@modern-js/utils/lodash";
|
|
6
|
-
import { FILE_SYSTEM_ROUTES_FILE_NAME } from "../constants";
|
|
7
6
|
import { ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME } from "../../../cli/constants";
|
|
8
|
-
import
|
|
7
|
+
import { FILE_SYSTEM_ROUTES_FILE_NAME } from "../constants";
|
|
9
8
|
import { getClientRoutes, getClientRoutesLegacy } from "./getClientRoutes";
|
|
10
|
-
import { getServerLoadersFile, getServerCombinedModueFile } from "./utils";
|
|
11
9
|
import { walk } from "./nestedRoutes";
|
|
10
|
+
import * as templates from "./templates";
|
|
11
|
+
import { getServerCombinedModueFile, getServerLoadersFile } from "./utils";
|
|
12
12
|
var generateCode = function() {
|
|
13
13
|
var _ref = _async_to_generator(function(appContext, config, entrypoints, api) {
|
|
14
14
|
var internalDirectory, srcDirectory, internalDirAlias, internalSrcAlias, packageName, hookRunners, isV5, getRoutes, oldVersion;
|
|
@@ -3,7 +3,7 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
|
3
3
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
4
4
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
5
5
|
import * as path from "path";
|
|
6
|
-
import {
|
|
6
|
+
import { fs, JS_EXTENSIONS, normalizeToPosixPath } from "@modern-js/utils";
|
|
7
7
|
import { NESTED_ROUTE } from "../constants";
|
|
8
8
|
import { getPathWithoutExt, hasAction, replaceWithAlias } from "./utils";
|
|
9
9
|
var conventionNames = Object.values(NESTED_ROUTE);
|
|
@@ -4,7 +4,7 @@ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
|
4
4
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
5
5
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
6
6
|
import path from "path";
|
|
7
|
-
import { findExists, formatImportPath,
|
|
7
|
+
import { fs, findExists, formatImportPath, getEntryOptions, isSSGEntry, slash } from "@modern-js/utils";
|
|
8
8
|
import { ROUTE_MODULES } from "@modern-js/utils/universal/constants";
|
|
9
9
|
import { APP_CONFIG_NAME, APP_INIT_EXPORTED, TEMP_LOADERS_DIR } from "../constants";
|
|
10
10
|
import { getPathWithoutExt, getServerLoadersFile, parseModule, replaceWithAlias } from "./utils";
|
|
@@ -414,7 +414,7 @@ function ssrLoaderCombinedModule(entrypoints, entrypoint, config, appContext) {
|
|
|
414
414
|
if (!config.source.enableAsyncEntry) {
|
|
415
415
|
return combinedModule;
|
|
416
416
|
}
|
|
417
|
-
return '
|
|
417
|
+
return '\n async function loadModules() {\n const [moduleA, moduleB] = await Promise.all([\n import("'.concat(slash(serverLoaderRuntime), '"),\n import("').concat(slash(serverLoadersFile), '")\n ]);\n\n return {\n ...moduleA,\n ...moduleB\n };\n }\n\n export { loadModules };\n ');
|
|
418
418
|
}
|
|
419
419
|
return null;
|
|
420
420
|
}
|
|
@@ -4,9 +4,9 @@ import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
|
4
4
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
5
5
|
import fs from "fs";
|
|
6
6
|
import path from "path";
|
|
7
|
-
import {
|
|
8
|
-
import { transform } from "esbuild";
|
|
7
|
+
import { JS_EXTENSIONS, fs as fse, normalizeToPosixPath } from "@modern-js/utils";
|
|
9
8
|
import { parse } from "es-module-lexer";
|
|
9
|
+
import { transform } from "esbuild";
|
|
10
10
|
import { ACTION_EXPORT_NAME, LOADER_EXPORT_NAME } from "../constants";
|
|
11
11
|
var walkDirectory = function(dir) {
|
|
12
12
|
return fs.readdirSync(dir).reduce(function(previous, filename) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
2
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import { JS_EXTENSIONS, findExists,
|
|
4
|
+
import { fs, JS_EXTENSIONS, findExists, isRouterV5 } from "@modern-js/utils";
|
|
5
5
|
import { hasApp } from "../../cli/entry";
|
|
6
6
|
import { FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT, NESTED_ROUTES_DIR, PAGES_DIR_NAME } from "./constants";
|
|
7
7
|
var hasPages = function(dir) {
|
|
@@ -2,9 +2,9 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { cloneDeep } from "@modern-js/utils/lodash";
|
|
5
|
-
import { modifyEntrypoints } from "./entry";
|
|
6
|
-
import { isPageComponentFile } from "./code/utils";
|
|
7
5
|
import * as templates from "./code/templates";
|
|
6
|
+
import { isPageComponentFile } from "./code/utils";
|
|
7
|
+
import { modifyEntrypoints } from "./entry";
|
|
8
8
|
var originEntrypoints = [];
|
|
9
9
|
function handleModifyEntrypoints(api, entrypoints) {
|
|
10
10
|
return _handleModifyEntrypoints.apply(this, arguments);
|
|
@@ -3,7 +3,7 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
|
3
3
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
4
4
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
5
5
|
import path from "node:path";
|
|
6
|
-
import { createRuntimeExportsUtils, filterRoutesForServer,
|
|
6
|
+
import { fs, NESTED_ROUTE_SPEC_FILE, createRuntimeExportsUtils, filterRoutesForServer, getEntryOptions, isRouterV5 as isV5 } from "@modern-js/utils";
|
|
7
7
|
import { isRouteEntry } from "./entry";
|
|
8
8
|
import { handleFileChange, handleGeneratorEntryCode, handleModifyEntrypoints } from "./handler";
|
|
9
9
|
import { isRouteEntry as isRouteEntry2 } from "./entry";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { Suspense, useEffect, useRef, useMemo } from "react";
|
|
4
|
-
import { Await, useAsyncError } from "@modern-js/runtime-utils/router";
|
|
5
3
|
import { serializeJson } from "@modern-js/runtime-utils/node";
|
|
4
|
+
import { Await, useAsyncError } from "@modern-js/runtime-utils/router";
|
|
5
|
+
import { Suspense, useEffect, useMemo, useRef } from "react";
|
|
6
6
|
import { serializeErrors } from "./utils";
|
|
7
7
|
var setupFnStr = "function s(r,e){_ROUTER_DATA.r=_ROUTER_DATA.r||{},_ROUTER_DATA.r[r]=_ROUTER_DATA.r[r]||{};return new Promise((function(A,R){_ROUTER_DATA.r[r][e]={resolve:A,reject:R}}))};";
|
|
8
8
|
var resolveFnStr = "function r(e,r,o,A){A?_ROUTER_DATA.r[e][r].reject(A):_ROUTER_DATA.r[e][r].resolve(o)};";
|
|
@@ -4,8 +4,8 @@ import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_
|
|
|
4
4
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
5
5
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
6
6
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
|
+
import { Link as RouterLink, NavLink as RouterNavLink, matchRoutes, useHref, useMatches, useResolvedPath } from "@modern-js/runtime-utils/router";
|
|
7
8
|
import React, { useContext, useMemo } from "react";
|
|
8
|
-
import { Link as RouterLink, matchRoutes, useResolvedPath, useHref, useMatches, NavLink as RouterNavLink } from "@modern-js/runtime-utils/router";
|
|
9
9
|
import { RuntimeReactContext } from "../../core";
|
|
10
10
|
function composeEventHandlers(theirHandler, ourHandler) {
|
|
11
11
|
return function(event) {
|
|
@@ -2,12 +2,12 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
|
2
2
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
3
3
|
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
import { useContext, useMemo } from "react";
|
|
6
|
-
import { createBrowserRouter, createHashRouter, RouterProvider, createRoutesFromElements, useMatches, useLocation, useHref } from "@modern-js/runtime-utils/router";
|
|
7
|
-
import { parsedJSONFromElement } from "@modern-js/runtime-utils/parsed";
|
|
8
5
|
import { merge } from "@modern-js/runtime-utils/merge";
|
|
9
|
-
import {
|
|
6
|
+
import { parsedJSONFromElement } from "@modern-js/runtime-utils/parsed";
|
|
7
|
+
import { RouterProvider, createBrowserRouter, createHashRouter, createRoutesFromElements, useHref, useLocation, useMatches } from "@modern-js/runtime-utils/router";
|
|
8
|
+
import { useContext, useMemo } from "react";
|
|
10
9
|
import { RuntimeReactContext } from "../../core";
|
|
10
|
+
import { getGlobalLayoutApp, getGlobalRoutes } from "../../core/context";
|
|
11
11
|
import { modifyRoutes as modifyRoutesHook } from "./hooks";
|
|
12
12
|
import { deserializeErrors, renderRoutes, urlJoin } from "./utils";
|
|
13
13
|
var finalRouteConfig = {
|
|
@@ -4,20 +4,20 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
|
4
4
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
5
5
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
6
6
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
|
-
import {
|
|
7
|
+
import { merge } from "@modern-js/runtime-utils/merge";
|
|
8
|
+
import { createRequestContext, reporterCtx } from "@modern-js/runtime-utils/node";
|
|
9
|
+
import { StaticRouterProvider, createStaticRouter } from "@modern-js/runtime-utils/node/router";
|
|
8
10
|
import { createStaticHandler } from "@modern-js/runtime-utils/remix-router";
|
|
9
|
-
import { createStaticRouter, StaticRouterProvider } from "@modern-js/runtime-utils/node/router";
|
|
10
11
|
import { createRoutesFromElements } from "@modern-js/runtime-utils/router";
|
|
11
|
-
import { reporterCtx, createRequestContext } from "@modern-js/runtime-utils/node";
|
|
12
12
|
import { time } from "@modern-js/runtime-utils/time";
|
|
13
13
|
import { LOADER_REPORTER_NAME } from "@modern-js/utils/universal/constants";
|
|
14
|
-
import {
|
|
14
|
+
import { useContext } from "react";
|
|
15
15
|
import { JSX_SHELL_STREAM_END_MARK } from "../../common";
|
|
16
16
|
import { RuntimeReactContext } from "../../core";
|
|
17
17
|
import { getGlobalLayoutApp, getGlobalRoutes } from "../../core/context";
|
|
18
|
-
import { renderRoutes, urlJoin } from "./utils";
|
|
19
|
-
import { modifyRoutes as modifyRoutesHook } from "./hooks";
|
|
20
18
|
import DeferredDataScripts from "./DeferredDataScripts.node";
|
|
19
|
+
import { modifyRoutes as modifyRoutesHook } from "./hooks";
|
|
20
|
+
import { renderRoutes, urlJoin } from "./utils";
|
|
21
21
|
function createRemixReuqest(request) {
|
|
22
22
|
var method = "GET";
|
|
23
23
|
var headers = request.headers;
|
|
@@ -4,9 +4,9 @@ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
|
4
4
|
import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
|
|
5
5
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
import { Route, isRouteErrorResponse } from "@modern-js/runtime-utils/router";
|
|
8
|
-
import { UNSAFE_ErrorResponseImpl as ErrorResponseImpl } from "@modern-js/runtime-utils/remix-router";
|
|
9
7
|
import { renderNestedRoute } from "@modern-js/runtime-utils/browser";
|
|
8
|
+
import { UNSAFE_ErrorResponseImpl as ErrorResponseImpl } from "@modern-js/runtime-utils/remix-router";
|
|
9
|
+
import { Route, isRouteErrorResponse } from "@modern-js/runtime-utils/router";
|
|
10
10
|
import { DefaultNotFound } from "./DefaultNotFound";
|
|
11
11
|
import DeferredDataScripts from "./DeferredDataScripts";
|
|
12
12
|
function getRouteComponents(routes, param) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { plugin as effectsPlugin } from "@modern-js-reduck/plugin-effects";
|
|
2
1
|
import autoActionsPlugin from "@modern-js-reduck/plugin-auto-actions";
|
|
2
|
+
import { plugin as effectsPlugin } from "@modern-js-reduck/plugin-effects";
|
|
3
3
|
import immerPlugin from "@modern-js-reduck/plugin-immutable";
|
|
4
4
|
import { default as default2 } from "@modern-js-reduck/plugin-devtools";
|
|
5
5
|
var effects = function() {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
2
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
-
import { useContext } from "react";
|
|
5
|
-
import { createStore } from "@modern-js-reduck/store";
|
|
6
4
|
import { Provider } from "@modern-js-reduck/react";
|
|
5
|
+
import { createStore } from "@modern-js-reduck/store";
|
|
7
6
|
import { merge } from "@modern-js/runtime-utils/merge";
|
|
8
|
-
import {
|
|
9
|
-
import { RuntimeReactContext } from "../../core";
|
|
7
|
+
import { useContext } from "react";
|
|
10
8
|
import { isBrowser } from "../../common";
|
|
9
|
+
import { RuntimeReactContext } from "../../core";
|
|
10
|
+
import { autoActions, devtools, effects, immer } from "../plugins";
|
|
11
11
|
var StatePluginHandleMap = {
|
|
12
12
|
immer,
|
|
13
13
|
effects,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { fs } from "@modern-js/utils";
|
|
3
|
+
import { ENTRY_BOOTSTRAP_FILE_NAME, ENTRY_POINT_FILE_NAME, ENTRY_POINT_REGISTER_FILE_NAME, ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME, ENTRY_POINT_RUNTIME_REGISTER_FILE_NAME, ENTRY_SERVER_BOOTSTRAP_FILE_NAME, INDEX_FILE_NAME, SERVER_ENTRY_POINT_FILE_NAME } from "./constants";
|
|
4
4
|
import * as template from "./template";
|
|
5
5
|
import * as serverTemplate from "./template.server";
|
|
6
|
-
function getSSRMode(entry
|
|
6
|
+
function getSSRMode(entry, config) {
|
|
7
7
|
const { ssr, ssrByEntries } = config.server;
|
|
8
8
|
if (config.output.ssg) {
|
|
9
9
|
return "string";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { isReact18 as checkIsReact18, cleanRequireCache, createRuntimeExportsUtils } from "@modern-js/utils";
|
|
3
|
-
import { statePlugin } from "../state/cli";
|
|
4
|
-
import { routerPlugin } from "../router/cli";
|
|
5
3
|
import { documentPlugin } from "../document/cli";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { ENTRY_BOOTSTRAP_FILE_NAME, ENTRY_POINT_FILE_NAME } from "./constants";
|
|
9
|
-
import { generateCode } from "./code";
|
|
4
|
+
import { routerPlugin } from "../router/cli";
|
|
5
|
+
import { statePlugin } from "../state/cli";
|
|
10
6
|
import { builderPluginAlias } from "./alias";
|
|
7
|
+
import { generateCode } from "./code";
|
|
8
|
+
import { ENTRY_BOOTSTRAP_FILE_NAME, ENTRY_POINT_FILE_NAME } from "./constants";
|
|
9
|
+
import { isRuntimeEntry } from "./entry";
|
|
10
|
+
import { ssrPlugin } from "./ssr";
|
|
11
11
|
import { isRuntimeEntry as isRuntimeEntry2 } from "./entry";
|
|
12
12
|
const runtimePlugin = (params) => ({
|
|
13
13
|
name: "@modern-js/runtime",
|
|
@@ -103,10 +103,7 @@ const runtimePlugin = (params) => ({
|
|
|
103
103
|
]
|
|
104
104
|
},
|
|
105
105
|
bundlerChain: (chain) => {
|
|
106
|
-
chain.module.rule("modern-entry").test(
|
|
107
|
-
/\.js$/,
|
|
108
|
-
/\.jsx$/
|
|
109
|
-
]).include.add(path.resolve(appDirectory, "node_modules", `.${metaName}`)).end().sideEffects(true);
|
|
106
|
+
chain.module.rule("modern-entry").test(/\.jsx?$/).include.add(path.resolve(appDirectory, "node_modules", `.${metaName}`)).end().sideEffects(true);
|
|
110
107
|
},
|
|
111
108
|
/**
|
|
112
109
|
* Add IgnorePlugin to fix react-dom/client import error when use react17
|
|
@@ -2,8 +2,8 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
2
2
|
var __commonJS = (cb, mod) => function __require() {
|
|
3
3
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
4
|
};
|
|
5
|
-
import crypto from "crypto";
|
|
6
5
|
import { Buffer as Buffer2 } from "buffer";
|
|
6
|
+
import crypto from "crypto";
|
|
7
7
|
import * as t from "@babel/types";
|
|
8
8
|
import { get } from "@modern-js/utils/lodash";
|
|
9
9
|
var require_babel_plugin_ssr_loader_id = __commonJS({
|
|
@@ -52,6 +52,7 @@ const ssrPlugin = () => ({
|
|
|
52
52
|
"@modern-js/runtime"
|
|
53
53
|
],
|
|
54
54
|
setup: (api) => {
|
|
55
|
+
const appContext = api.useAppContext();
|
|
55
56
|
return {
|
|
56
57
|
// for bundle
|
|
57
58
|
config() {
|
|
@@ -89,7 +90,19 @@ const ssrPlugin = () => ({
|
|
|
89
90
|
}
|
|
90
91
|
},
|
|
91
92
|
tools: {
|
|
92
|
-
babel: babelHandler
|
|
93
|
+
babel: babelHandler,
|
|
94
|
+
bundlerChain: (chain, { isServer }) => {
|
|
95
|
+
if (isServer && appContext.moduleType === "module") {
|
|
96
|
+
chain.output.libraryTarget("module").set("chunkFormat", "module");
|
|
97
|
+
chain.output.library({
|
|
98
|
+
type: "module"
|
|
99
|
+
});
|
|
100
|
+
chain.experiments({
|
|
101
|
+
...chain.get("experiments"),
|
|
102
|
+
outputModule: true
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
93
106
|
}
|
|
94
107
|
};
|
|
95
108
|
}
|
|
@@ -53,7 +53,7 @@ const runtimeGlobalContext = ({ srcDirectory, internalSrcAlias, metaName, entry,
|
|
|
53
53
|
return `import { setGlobalContext } from '@${metaName}/runtime/context'
|
|
54
54
|
|
|
55
55
|
import App from '${// We need to get the path of App.tsx here, but the entry is `src/entry.tsx`
|
|
56
|
-
formatImportPath(customEntry ? entry.replace("entry.tsx", "App
|
|
56
|
+
formatImportPath(customEntry ? entry.replace("entry.tsx", "App").replace(srcDirectory, internalSrcAlias) : entry.replace(srcDirectory, internalSrcAlias).replace(".tsx", ""))}';
|
|
57
57
|
|
|
58
58
|
setGlobalContext({
|
|
59
59
|
App,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { normalizePathname } from "@modern-js/runtime-utils/url";
|
|
3
2
|
import { loadableReady } from "@loadable/component";
|
|
3
|
+
import { normalizePathname } from "@modern-js/runtime-utils/url";
|
|
4
4
|
import { RenderLevel } from "../constants";
|
|
5
5
|
import { wrapRuntimeContextProvider } from "../react/wrapper";
|
|
6
6
|
import { WithCallback } from "./withCallback";
|
|
@@ -1,31 +1,50 @@
|
|
|
1
|
-
import cookieTool from "cookie";
|
|
2
1
|
import { parsedJSONFromElement } from "@modern-js/runtime-utils/parsed";
|
|
2
|
+
import cookieTool from "cookie";
|
|
3
|
+
import { ROUTER_DATA_JSON_ID, SSR_DATA_JSON_ID } from "../constants";
|
|
3
4
|
import { getGlobalAppInit } from "../context";
|
|
4
5
|
import { getInitialContext } from "../context/runtime";
|
|
5
6
|
import { createLoaderManager } from "../loader/loaderManager";
|
|
6
7
|
import { getGlobalRunner } from "../plugin/runner";
|
|
7
8
|
import { wrapRuntimeContextProvider } from "../react/wrapper";
|
|
8
|
-
import { ROUTER_DATA_JSON_ID, SSR_DATA_JSON_ID } from "../constants";
|
|
9
9
|
import { hydrateRoot } from "./hydrate";
|
|
10
10
|
const IS_REACT18 = process.env.IS_REACT18 === "true";
|
|
11
|
+
const getQuery = () => window.location.search.substring(1).split("&").reduce((res, item) => {
|
|
12
|
+
const [key, value] = item.split("=");
|
|
13
|
+
if (key) {
|
|
14
|
+
res[key] = value;
|
|
15
|
+
}
|
|
16
|
+
return res;
|
|
17
|
+
}, {});
|
|
11
18
|
function getSSRData() {
|
|
19
|
+
var _ssrData_context, _ssrData_context1, _ssrRequest_headers;
|
|
12
20
|
const ssrData = window._SSR_DATA;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
const ssrRequest = ssrData === null || ssrData === void 0 ? void 0 : (_ssrData_context = ssrData.context) === null || _ssrData_context === void 0 ? void 0 : _ssrData_context.request;
|
|
22
|
+
const finalSSRData = {
|
|
23
|
+
...ssrData || {
|
|
24
|
+
renderLevel: 0,
|
|
25
|
+
mode: "string"
|
|
26
|
+
},
|
|
27
|
+
context: {
|
|
28
|
+
...(ssrData === null || ssrData === void 0 ? void 0 : ssrData.context) || {},
|
|
29
|
+
request: {
|
|
30
|
+
...(ssrData === null || ssrData === void 0 ? void 0 : (_ssrData_context1 = ssrData.context) === null || _ssrData_context1 === void 0 ? void 0 : _ssrData_context1.request) || {},
|
|
31
|
+
params: (ssrRequest === null || ssrRequest === void 0 ? void 0 : ssrRequest.params) || {},
|
|
32
|
+
host: (ssrRequest === null || ssrRequest === void 0 ? void 0 : ssrRequest.host) || location.host,
|
|
33
|
+
pathname: (ssrRequest === null || ssrRequest === void 0 ? void 0 : ssrRequest.pathname) || location.pathname,
|
|
34
|
+
headers: (ssrRequest === null || ssrRequest === void 0 ? void 0 : ssrRequest.headers) || {},
|
|
35
|
+
cookieMap: cookieTool.parse(document.cookie || "") || {},
|
|
36
|
+
cookie: document.cookie || "",
|
|
37
|
+
userAgent: (ssrRequest === null || ssrRequest === void 0 ? void 0 : (_ssrRequest_headers = ssrRequest.headers) === null || _ssrRequest_headers === void 0 ? void 0 : _ssrRequest_headers["user-agent"]) || navigator.userAgent,
|
|
38
|
+
referer: document.referrer,
|
|
39
|
+
query: {
|
|
40
|
+
...getQuery(),
|
|
41
|
+
...(ssrRequest === null || ssrRequest === void 0 ? void 0 : ssrRequest.query) || {}
|
|
42
|
+
},
|
|
43
|
+
url: location.href
|
|
25
44
|
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
return finalSSRData;
|
|
29
48
|
}
|
|
30
49
|
function isClientArgs(id) {
|
|
31
50
|
return typeof id === "undefined" || typeof id === "string" || typeof HTMLElement !== "undefined" && id instanceof HTMLElement;
|