@modern-js/runtime 2.21.0 → 2.22.0
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 +37 -0
- package/dist/cjs/cli/index.js +11 -1
- package/dist/cjs/common.js +9 -3
- package/dist/cjs/core/appConfig.js +6 -2
- package/dist/cjs/core/compatible.js +9 -3
- package/dist/cjs/core/index.js +24 -8
- package/dist/cjs/core/loader/index.js +3 -1
- package/dist/cjs/core/loader/loaderManager.js +6 -2
- package/dist/cjs/core/loader/useLoader.js +3 -1
- package/dist/cjs/core/plugin.js +12 -4
- package/dist/cjs/document/Body.js +3 -1
- package/dist/cjs/document/Comment.js +3 -1
- package/dist/cjs/document/DocumentContext.js +3 -1
- package/dist/cjs/document/DocumentStructureContext.js +3 -1
- package/dist/cjs/document/Head.js +6 -2
- package/dist/cjs/document/Html.js +3 -1
- package/dist/cjs/document/Links.js +3 -1
- package/dist/cjs/document/Root.js +6 -2
- package/dist/cjs/document/Script.js +3 -1
- package/dist/cjs/document/Scripts.js +3 -1
- package/dist/cjs/document/cli/index.js +6 -2
- package/dist/cjs/document/constants.js +51 -17
- package/dist/cjs/exports/head.js +3 -1
- package/dist/cjs/exports/loadable.js +3 -1
- package/dist/cjs/exports/server.js +3 -1
- package/dist/cjs/exports/styled.js +3 -1
- package/dist/cjs/index.js +27 -9
- package/dist/cjs/router/cli/index.js +3 -1
- package/dist/cjs/router/index.js +6 -2
- package/dist/cjs/router/runtime/DefaultNotFound.js +3 -1
- package/dist/cjs/router/runtime/DeferredDataScripts.js +3 -1
- package/dist/cjs/router/runtime/DeferredDataScripts.node.js +3 -1
- package/dist/cjs/router/runtime/PrefetchLink.js +9 -3
- package/dist/cjs/router/runtime/fetch.js +3 -1
- package/dist/cjs/router/runtime/fetch.node.js +3 -1
- package/dist/cjs/router/runtime/fetch.worker.js +3 -1
- package/dist/cjs/router/runtime/hooks.js +3 -1
- package/dist/cjs/router/runtime/index.js +183 -61
- package/dist/cjs/router/runtime/plugin.js +33 -5
- package/dist/cjs/router/runtime/plugin.node.js +28 -6
- package/dist/cjs/router/runtime/utils.js +21 -7
- package/dist/cjs/router/runtime/withRouter.js +3 -1
- package/dist/cjs/runtimeContext.js +6 -2
- package/dist/cjs/ssr/cli/index.js +10 -3
- package/dist/cjs/ssr/index.js +11 -4
- package/dist/cjs/ssr/index.node.js +6 -2
- package/dist/cjs/ssr/prefetch.js +3 -1
- package/dist/cjs/ssr/react/index.js +6 -2
- package/dist/cjs/ssr/react/nossr/index.js +3 -1
- package/dist/cjs/ssr/react/prerender/index.js +3 -1
- package/dist/cjs/ssr/react/prerender/util.js +15 -5
- package/dist/cjs/ssr/react/withCallback/index.js +3 -1
- package/dist/cjs/ssr/serverRender/helmet.js +3 -1
- package/dist/cjs/ssr/serverRender/index.js +3 -1
- package/dist/cjs/ssr/serverRender/renderToStream/buildTemplate.after.js +3 -1
- package/dist/cjs/ssr/serverRender/renderToStream/buildTemplate.share.js +6 -2
- package/dist/cjs/ssr/serverRender/renderToStream/bulidTemplate.before.js +3 -1
- package/dist/cjs/ssr/serverRender/renderToStream/index.js +3 -1
- package/dist/cjs/ssr/serverRender/renderToStream/loadable.js +3 -1
- package/dist/cjs/ssr/serverRender/renderToStream/renderToPipe.js +3 -1
- package/dist/cjs/ssr/serverRender/renderToStream/renderToPipe.worker.js +3 -1
- package/dist/cjs/ssr/serverRender/renderToStream/styledComponent.js +3 -1
- package/dist/cjs/ssr/serverRender/renderToStream/template.js +3 -1
- package/dist/cjs/ssr/serverRender/renderToString/entry.js +3 -1
- package/dist/cjs/ssr/serverRender/renderToString/index.js +3 -1
- package/dist/cjs/ssr/serverRender/renderToString/loadable.js +3 -1
- package/dist/cjs/ssr/serverRender/renderToString/reduce.js +3 -1
- package/dist/cjs/ssr/serverRender/renderToString/styledComponent.js +3 -1
- package/dist/cjs/ssr/serverRender/renderToString/template.js +6 -2
- package/dist/cjs/ssr/serverRender/renderToString/type.js +3 -1
- package/dist/cjs/ssr/serverRender/time.js +3 -1
- package/dist/cjs/ssr/serverRender/time.worker.js +3 -1
- package/dist/cjs/ssr/serverRender/types.js +3 -1
- package/dist/cjs/ssr/serverRender/utils.js +15 -5
- package/dist/cjs/ssr/utils.js +15 -5
- package/dist/cjs/state/cli/index.js +3 -1
- package/dist/cjs/state/index.js +6 -2
- package/dist/cjs/state/plugins.js +12 -4
- package/dist/cjs/state/runtime/index.js +3 -1
- package/dist/cjs/state/runtime/plugin.js +3 -1
- package/dist/esm/cli/index.js +8 -0
- package/dist/esm/router/runtime/plugin.js +20 -0
- package/dist/esm/router/runtime/plugin.node.js +19 -3
- package/dist/esm/ssr/cli/index.js +10 -2
- package/dist/esm/ssr/index.js +5 -2
- package/dist/esm-node/cli/index.js +8 -0
- package/dist/esm-node/router/runtime/plugin.js +20 -0
- package/dist/esm-node/router/runtime/plugin.node.js +19 -3
- package/dist/esm-node/ssr/cli/index.js +7 -2
- package/dist/esm-node/ssr/index.js +5 -2
- package/dist/types/runtimeContext.d.ts +5 -1
- package/dist/types/ssr/serverRender/types.d.ts +1 -0
- package/package.json +10 -9
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "buildShellAfterTemplate", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return buildShellAfterTemplate;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _runtimenode = require("@modern-js/utils/runtime-node");
|
|
10
12
|
const _utils = require("../utils");
|
|
@@ -10,8 +10,12 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
HEAD_REG_EXP: ()
|
|
14
|
-
|
|
13
|
+
HEAD_REG_EXP: function() {
|
|
14
|
+
return HEAD_REG_EXP;
|
|
15
|
+
},
|
|
16
|
+
buildTemplate: function() {
|
|
17
|
+
return buildTemplate;
|
|
18
|
+
}
|
|
15
19
|
});
|
|
16
20
|
const HEAD_REG_EXP = /<head(.|\n)*>(.|\n)*<\/head>/;
|
|
17
21
|
function buildTemplate(template, callbacks) {
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "buildShellBeforeTemplate", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return buildShellBeforeTemplate;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
10
12
|
const _reacthelmet = /* @__PURE__ */ _interop_require_default._(require("react-helmet"));
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "render", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return render;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
10
12
|
const _react = require("react");
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "getLoadableChunks", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return getLoadableChunks;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _server = require("@loadable/server");
|
|
10
12
|
function getLoadableChunks({ context, jsx }) {
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _stream = require("stream");
|
|
10
12
|
const _types = require("../types");
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _types = require("../types");
|
|
10
12
|
const _common = require("../../../common");
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "getStyledComponentCss", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return getStyledComponentCss;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _styledcomponents = require("styled-components");
|
|
10
12
|
function getStyledComponentCss({ jsx }) {
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "getTemplates", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return getTemplates;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _buildTemplateafter = require("./buildTemplate.after");
|
|
10
12
|
const _bulidTemplatebefore = require("./bulidTemplate.before");
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return Entry;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _define_property = require("@swc/helpers/_/_define_property");
|
|
10
12
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "render", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return render;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
10
12
|
const _runtimenode = require("@modern-js/utils/runtime-node");
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "toHtml", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return toHtml;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _server = require("@loadable/server");
|
|
10
12
|
const _utils = require("../../utils");
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "reduce", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return reduce;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
10
12
|
const _react = /* @__PURE__ */ _interop_require_default._(require("react"));
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "toHtml", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return toHtml;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _styledcomponents = require("styled-components");
|
|
10
12
|
const toHtml = (jsx, renderer, next) => {
|
|
@@ -10,8 +10,12 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
Fragment: ()
|
|
14
|
-
|
|
13
|
+
Fragment: function() {
|
|
14
|
+
return Fragment;
|
|
15
|
+
},
|
|
16
|
+
toFragments: function() {
|
|
17
|
+
return toFragments;
|
|
18
|
+
}
|
|
15
19
|
});
|
|
16
20
|
const _define_property = require("@swc/helpers/_/_define_property");
|
|
17
21
|
const VARIABLE_REG_EXP = /<!--<\?([-=+])\s*(.*?)\s*\?>-->/;
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "time", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return time;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
function processHrtime(previousTimestamp) {
|
|
10
12
|
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
@@ -10,11 +10,21 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
CSS_CHUNKS_PLACEHOLDER: ()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
CSS_CHUNKS_PLACEHOLDER: function() {
|
|
14
|
+
return CSS_CHUNKS_PLACEHOLDER;
|
|
15
|
+
},
|
|
16
|
+
SSR_DATA_JSON_ID: function() {
|
|
17
|
+
return SSR_DATA_JSON_ID;
|
|
18
|
+
},
|
|
19
|
+
ROUTER_DATA_JSON_ID: function() {
|
|
20
|
+
return ROUTER_DATA_JSON_ID;
|
|
21
|
+
},
|
|
22
|
+
getLoadableScripts: function() {
|
|
23
|
+
return getLoadableScripts;
|
|
24
|
+
},
|
|
25
|
+
attributesToString: function() {
|
|
26
|
+
return attributesToString;
|
|
27
|
+
}
|
|
18
28
|
});
|
|
19
29
|
const CSS_CHUNKS_PLACEHOLDER = "<!--<?- chunksMap.css ?>-->";
|
|
20
30
|
const SSR_DATA_JSON_ID = "__MODERN_SSR_DATA__";
|
package/dist/cjs/ssr/utils.js
CHANGED
|
@@ -10,11 +10,21 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
isReact18: ()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
isReact18: function() {
|
|
14
|
+
return isReact18;
|
|
15
|
+
},
|
|
16
|
+
formatServer: function() {
|
|
17
|
+
return formatServer;
|
|
18
|
+
},
|
|
19
|
+
formatClient: function() {
|
|
20
|
+
return formatClient;
|
|
21
|
+
},
|
|
22
|
+
mockResponse: function() {
|
|
23
|
+
return mockResponse;
|
|
24
|
+
},
|
|
25
|
+
isCrossOrigin: function() {
|
|
26
|
+
return isCrossOrigin;
|
|
27
|
+
}
|
|
18
28
|
});
|
|
19
29
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
30
|
const _cookie = /* @__PURE__ */ _interop_require_default._(require("cookie"));
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _utils = require("@modern-js/utils");
|
|
10
12
|
const PLUGIN_IDENTIFIER = "state";
|
package/dist/cjs/state/index.js
CHANGED
|
@@ -10,8 +10,12 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
state: ()
|
|
14
|
-
|
|
13
|
+
state: function() {
|
|
14
|
+
return _runtime.default;
|
|
15
|
+
},
|
|
16
|
+
default: function() {
|
|
17
|
+
return _runtime.default;
|
|
18
|
+
}
|
|
15
19
|
});
|
|
16
20
|
const _export_star = require("@swc/helpers/_/_export_star");
|
|
17
21
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
@@ -10,10 +10,18 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
devtools: ()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
devtools: function() {
|
|
14
|
+
return _plugindevtools.default;
|
|
15
|
+
},
|
|
16
|
+
effects: function() {
|
|
17
|
+
return effects;
|
|
18
|
+
},
|
|
19
|
+
immer: function() {
|
|
20
|
+
return immer;
|
|
21
|
+
},
|
|
22
|
+
autoActions: function() {
|
|
23
|
+
return autoActions;
|
|
24
|
+
}
|
|
17
25
|
});
|
|
18
26
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
19
27
|
const _plugineffects = require("@modern-js-reduck/plugin-effects");
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return _plugin.default;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _export_star = require("@swc/helpers/_/_export_star");
|
|
10
12
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _export_star = require("@swc/helpers/_/_export_star");
|
|
10
12
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
package/dist/esm/cli/index.js
CHANGED
|
@@ -43,6 +43,14 @@ export default function() {
|
|
|
43
43
|
globalVars: {
|
|
44
44
|
"process.env.IS_REACT18": process.env.IS_REACT18
|
|
45
45
|
}
|
|
46
|
+
},
|
|
47
|
+
tools: {
|
|
48
|
+
styledComponents: {
|
|
49
|
+
// https://github.com/styled-components/babel-plugin-styled-components/issues/287
|
|
50
|
+
topLevelImportPaths: [
|
|
51
|
+
"@modern-js/runtime/styled"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
46
54
|
}
|
|
47
55
|
};
|
|
48
56
|
},
|
|
@@ -1,9 +1,11 @@
|
|
|
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 { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
import { useContext } from "react";
|
|
4
5
|
import { createBrowserRouter, createHashRouter, RouterProvider, createRoutesFromElements, useMatches, useLocation } from "@modern-js/utils/runtime/router";
|
|
5
6
|
import hoistNonReactStatics from "hoist-non-react-statics";
|
|
6
7
|
import { parsedJSONFromElement } from "@modern-js/utils/runtime-browser";
|
|
8
|
+
import { RuntimeReactContext } from "../../core";
|
|
7
9
|
import { modifyRoutes as modifyRoutesHook } from "./hooks";
|
|
8
10
|
import { deserializeErrors, renderRoutes, urlJoin } from "./utils";
|
|
9
11
|
export var finalRouteConfig = {
|
|
@@ -83,6 +85,8 @@ export var routerPlugin = function(param) {
|
|
|
83
85
|
basename: _basename,
|
|
84
86
|
hydrationData: hydrationData
|
|
85
87
|
});
|
|
88
|
+
var runtimeContext = useContext(RuntimeReactContext);
|
|
89
|
+
runtimeContext.remixRouter = router;
|
|
86
90
|
return /* @__PURE__ */ _jsx(App, _object_spread_props(_object_spread({}, props), {
|
|
87
91
|
children: /* @__PURE__ */ _jsx(RouterProvider, {
|
|
88
92
|
router: router
|
|
@@ -102,6 +106,22 @@ export var routerPlugin = function(param) {
|
|
|
102
106
|
return next({
|
|
103
107
|
App: RouteApp
|
|
104
108
|
});
|
|
109
|
+
},
|
|
110
|
+
pickContext: function(param2, next) {
|
|
111
|
+
var context = param2.context, pickedContext = param2.pickedContext;
|
|
112
|
+
var remixRouter = context.remixRouter;
|
|
113
|
+
var router = {
|
|
114
|
+
navigate: remixRouter.navigate,
|
|
115
|
+
get location() {
|
|
116
|
+
return remixRouter.state.location;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
return next({
|
|
120
|
+
context: context,
|
|
121
|
+
pickedContext: _object_spread_props(_object_spread({}, pickedContext), {
|
|
122
|
+
router: router
|
|
123
|
+
})
|
|
124
|
+
});
|
|
105
125
|
}
|
|
106
126
|
};
|
|
107
127
|
}
|
|
@@ -123,7 +123,7 @@ export var routerPlugin = function(param) {
|
|
|
123
123
|
];
|
|
124
124
|
}
|
|
125
125
|
router = createStaticRouter(routes, routerContext);
|
|
126
|
-
context.
|
|
126
|
+
context.remixRouter = router;
|
|
127
127
|
context.routerContext = routerContext;
|
|
128
128
|
context.routes = routes;
|
|
129
129
|
context.routeManifest = context.ssrContext.routeManifest;
|
|
@@ -148,10 +148,10 @@ export var routerPlugin = function(param) {
|
|
|
148
148
|
}
|
|
149
149
|
var getRouteApp = function() {
|
|
150
150
|
return function(props) {
|
|
151
|
-
var _useContext = useContext(RuntimeReactContext),
|
|
151
|
+
var _useContext = useContext(RuntimeReactContext), remixRouter = _useContext.remixRouter, routerContext = _useContext.routerContext;
|
|
152
152
|
return /* @__PURE__ */ _jsx(App, _object_spread_props(_object_spread({}, props), {
|
|
153
153
|
children: /* @__PURE__ */ _jsx(StaticRouterProvider, {
|
|
154
|
-
router:
|
|
154
|
+
router: remixRouter,
|
|
155
155
|
context: routerContext,
|
|
156
156
|
hydrate: false
|
|
157
157
|
})
|
|
@@ -167,6 +167,22 @@ export var routerPlugin = function(param) {
|
|
|
167
167
|
return next({
|
|
168
168
|
App: RouteApp
|
|
169
169
|
});
|
|
170
|
+
},
|
|
171
|
+
pickContext: function(param2, next) {
|
|
172
|
+
var context = param2.context, pickedContext = param2.pickedContext;
|
|
173
|
+
var remixRouter = context.remixRouter;
|
|
174
|
+
var router = {
|
|
175
|
+
navigate: remixRouter.navigate,
|
|
176
|
+
get location() {
|
|
177
|
+
return remixRouter.state.location;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
return next({
|
|
181
|
+
context: context,
|
|
182
|
+
pickedContext: _object_spread_props(_object_spread({}, pickedContext), {
|
|
183
|
+
router: router
|
|
184
|
+
})
|
|
185
|
+
});
|
|
170
186
|
}
|
|
171
187
|
};
|
|
172
188
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
|
+
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
1
3
|
import path from "path";
|
|
2
4
|
import { getEntryOptions, SERVER_RENDER_FUNCTION_NAME, LOADABLE_STATS_FILE, isUseSSRBundle, createRuntimeExportsUtils, isSSGEntry } from "@modern-js/utils";
|
|
3
5
|
var PLUGIN_IDENTIFIER = "ssr";
|
|
@@ -137,11 +139,17 @@ export default function() {
|
|
|
137
139
|
};
|
|
138
140
|
},
|
|
139
141
|
modifyEntryRuntimePlugins: function modifyEntryRuntimePlugins(param) {
|
|
140
|
-
var entrypoint = param.entrypoint, plugins = param.plugins;
|
|
142
|
+
var entrypoint = param.entrypoint, plugins = param.plugins, bundlerConfigs = param.bundlerConfigs;
|
|
141
143
|
if (ssrConfigMap.get(entrypoint.entryName)) {
|
|
144
|
+
var _bundlerConfigs_find, _bundlerConfigs_find_output;
|
|
145
|
+
var chunkLoadingGlobal = (_bundlerConfigs_find = bundlerConfigs === null || bundlerConfigs === void 0 ? void 0 : bundlerConfigs.find(function(config) {
|
|
146
|
+
return config.name === "client";
|
|
147
|
+
})) === null || _bundlerConfigs_find === void 0 ? void 0 : (_bundlerConfigs_find_output = _bundlerConfigs_find.output) === null || _bundlerConfigs_find_output === void 0 ? void 0 : _bundlerConfigs_find_output.chunkLoadingGlobal;
|
|
142
148
|
plugins.push({
|
|
143
149
|
name: PLUGIN_IDENTIFIER,
|
|
144
|
-
options: JSON.stringify(ssrConfigMap.get(entrypoint.entryName))
|
|
150
|
+
options: JSON.stringify(_object_spread_props(_object_spread({}, ssrConfigMap.get(entrypoint.entryName) || {}), {
|
|
151
|
+
chunkLoadingGlobal: chunkLoadingGlobal
|
|
152
|
+
}))
|
|
145
153
|
});
|
|
146
154
|
}
|
|
147
155
|
return {
|
package/dist/esm/ssr/index.js
CHANGED
|
@@ -29,6 +29,9 @@ export var ssr = function(config) {
|
|
|
29
29
|
context: context
|
|
30
30
|
}));
|
|
31
31
|
} else if (renderLevel === RenderLevel.SERVER_RENDER) {
|
|
32
|
+
var loadableReadyOptions = {
|
|
33
|
+
chunkLoadingGlobal: config.chunkLoadingGlobal
|
|
34
|
+
};
|
|
32
35
|
if (isReact18()) {
|
|
33
36
|
loadableReady(function() {
|
|
34
37
|
var SSRApp = function() {
|
|
@@ -41,13 +44,13 @@ export var ssr = function(config) {
|
|
|
41
44
|
};
|
|
42
45
|
SSRApp = hoistNonReactStatics(SSRApp, App);
|
|
43
46
|
ModernHydrate(/* @__PURE__ */ _jsx(SSRApp, {}));
|
|
44
|
-
});
|
|
47
|
+
}, loadableReadyOptions);
|
|
45
48
|
} else {
|
|
46
49
|
loadableReady(function() {
|
|
47
50
|
ModernHydrate(/* @__PURE__ */ _jsx(App, {
|
|
48
51
|
context: hydrateContext
|
|
49
52
|
}), callback);
|
|
50
|
-
});
|
|
53
|
+
}, loadableReadyOptions);
|
|
51
54
|
}
|
|
52
55
|
} else {
|
|
53
56
|
console.warn("unknow render level: ".concat(renderLevel, ", execute render()"));
|
|
@@ -40,6 +40,14 @@ export default () => ({
|
|
|
40
40
|
globalVars: {
|
|
41
41
|
"process.env.IS_REACT18": process.env.IS_REACT18
|
|
42
42
|
}
|
|
43
|
+
},
|
|
44
|
+
tools: {
|
|
45
|
+
styledComponents: {
|
|
46
|
+
// https://github.com/styled-components/babel-plugin-styled-components/issues/287
|
|
47
|
+
topLevelImportPaths: [
|
|
48
|
+
"@modern-js/runtime/styled"
|
|
49
|
+
]
|
|
50
|
+
}
|
|
43
51
|
}
|
|
44
52
|
};
|
|
45
53
|
},
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useContext } from "react";
|
|
2
3
|
import { createBrowserRouter, createHashRouter, RouterProvider, createRoutesFromElements, useMatches, useLocation } from "@modern-js/utils/runtime/router";
|
|
3
4
|
import hoistNonReactStatics from "hoist-non-react-statics";
|
|
4
5
|
import { parsedJSONFromElement } from "@modern-js/utils/runtime-browser";
|
|
6
|
+
import { RuntimeReactContext } from "../../core";
|
|
5
7
|
import { modifyRoutes as modifyRoutesHook } from "./hooks";
|
|
6
8
|
import { deserializeErrors, renderRoutes, urlJoin } from "./utils";
|
|
7
9
|
export let finalRouteConfig = {
|
|
@@ -75,6 +77,8 @@ export const routerPlugin = ({ serverBase = [], supportHtml5History = true, base
|
|
|
75
77
|
basename: _basename,
|
|
76
78
|
hydrationData
|
|
77
79
|
});
|
|
80
|
+
const runtimeContext = useContext(RuntimeReactContext);
|
|
81
|
+
runtimeContext.remixRouter = router;
|
|
78
82
|
return /* @__PURE__ */ _jsx(App, {
|
|
79
83
|
...props,
|
|
80
84
|
children: /* @__PURE__ */ _jsx(RouterProvider, {
|
|
@@ -95,6 +99,22 @@ export const routerPlugin = ({ serverBase = [], supportHtml5History = true, base
|
|
|
95
99
|
return next({
|
|
96
100
|
App: RouteApp
|
|
97
101
|
});
|
|
102
|
+
},
|
|
103
|
+
pickContext: ({ context, pickedContext }, next) => {
|
|
104
|
+
const { remixRouter } = context;
|
|
105
|
+
const router = {
|
|
106
|
+
navigate: remixRouter.navigate,
|
|
107
|
+
get location() {
|
|
108
|
+
return remixRouter.state.location;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
return next({
|
|
112
|
+
context,
|
|
113
|
+
pickedContext: {
|
|
114
|
+
...pickedContext,
|
|
115
|
+
router
|
|
116
|
+
}
|
|
117
|
+
});
|
|
98
118
|
}
|
|
99
119
|
};
|
|
100
120
|
}
|
|
@@ -65,7 +65,7 @@ export const routerPlugin = ({ basename = "", routesConfig, createRoutes }) => {
|
|
|
65
65
|
return routerContext;
|
|
66
66
|
}
|
|
67
67
|
const router = createStaticRouter(routes, routerContext);
|
|
68
|
-
context.
|
|
68
|
+
context.remixRouter = router;
|
|
69
69
|
context.routerContext = routerContext;
|
|
70
70
|
context.routes = routes;
|
|
71
71
|
context.routeManifest = context.ssrContext.routeManifest;
|
|
@@ -83,11 +83,11 @@ export const routerPlugin = ({ basename = "", routesConfig, createRoutes }) => {
|
|
|
83
83
|
}
|
|
84
84
|
const getRouteApp = () => {
|
|
85
85
|
return (props) => {
|
|
86
|
-
const {
|
|
86
|
+
const { remixRouter, routerContext } = useContext(RuntimeReactContext);
|
|
87
87
|
return /* @__PURE__ */ _jsx(App, {
|
|
88
88
|
...props,
|
|
89
89
|
children: /* @__PURE__ */ _jsx(StaticRouterProvider, {
|
|
90
|
-
router,
|
|
90
|
+
router: remixRouter,
|
|
91
91
|
context: routerContext,
|
|
92
92
|
hydrate: false
|
|
93
93
|
})
|
|
@@ -103,6 +103,22 @@ export const routerPlugin = ({ basename = "", routesConfig, createRoutes }) => {
|
|
|
103
103
|
return next({
|
|
104
104
|
App: RouteApp
|
|
105
105
|
});
|
|
106
|
+
},
|
|
107
|
+
pickContext: ({ context, pickedContext }, next) => {
|
|
108
|
+
const { remixRouter } = context;
|
|
109
|
+
const router = {
|
|
110
|
+
navigate: remixRouter.navigate,
|
|
111
|
+
get location() {
|
|
112
|
+
return remixRouter.state.location;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
return next({
|
|
116
|
+
context,
|
|
117
|
+
pickedContext: {
|
|
118
|
+
...pickedContext,
|
|
119
|
+
router
|
|
120
|
+
}
|
|
121
|
+
});
|
|
106
122
|
}
|
|
107
123
|
};
|
|
108
124
|
}
|
|
@@ -114,11 +114,16 @@ export default () => {
|
|
|
114
114
|
imports
|
|
115
115
|
};
|
|
116
116
|
},
|
|
117
|
-
modifyEntryRuntimePlugins({ entrypoint, plugins }) {
|
|
117
|
+
modifyEntryRuntimePlugins({ entrypoint, plugins, bundlerConfigs }) {
|
|
118
118
|
if (ssrConfigMap.get(entrypoint.entryName)) {
|
|
119
|
+
var _bundlerConfigs_find, _bundlerConfigs_find_output;
|
|
120
|
+
const chunkLoadingGlobal = (_bundlerConfigs_find = bundlerConfigs === null || bundlerConfigs === void 0 ? void 0 : bundlerConfigs.find((config) => config.name === "client")) === null || _bundlerConfigs_find === void 0 ? void 0 : (_bundlerConfigs_find_output = _bundlerConfigs_find.output) === null || _bundlerConfigs_find_output === void 0 ? void 0 : _bundlerConfigs_find_output.chunkLoadingGlobal;
|
|
119
121
|
plugins.push({
|
|
120
122
|
name: PLUGIN_IDENTIFIER,
|
|
121
|
-
options: JSON.stringify(
|
|
123
|
+
options: JSON.stringify({
|
|
124
|
+
...ssrConfigMap.get(entrypoint.entryName) || {},
|
|
125
|
+
chunkLoadingGlobal
|
|
126
|
+
})
|
|
122
127
|
});
|
|
123
128
|
}
|
|
124
129
|
return {
|