@modern-js/runtime 2.49.3-alpha.0 → 2.49.4
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/router/runtime/plugin.js +11 -2
- package/dist/cjs/router/runtime/plugin.node.js +2 -2
- package/dist/cjs/ssr/cli/index.js +9 -13
- package/dist/esm/router/runtime/plugin.js +2 -2
- package/dist/esm/router/runtime/plugin.node.js +2 -2
- package/dist/esm/ssr/cli/index.js +9 -13
- package/dist/esm-node/router/runtime/plugin.js +11 -2
- package/dist/esm-node/router/runtime/plugin.node.js +2 -2
- package/dist/esm-node/ssr/cli/index.js +9 -13
- package/dist/types/router/runtime/plugin.d.ts +1 -1
- package/dist/types/router/runtime/plugin.node.d.ts +1 -1
- package/dist/types/router/runtime/types.d.ts +1 -1
- package/package.json +10 -10
- package/dist/js/modern/cli/index.js +0 -72
- package/dist/js/modern/common.js +0 -4
- package/dist/js/modern/config.js +0 -0
- package/dist/js/modern/core/app-config.js +0 -10
- package/dist/js/modern/core/compatible.js +0 -285
- package/dist/js/modern/core/index.js +0 -16
- package/dist/js/modern/core/loader/index.js +0 -4
- package/dist/js/modern/core/loader/loaderManager.js +0 -165
- package/dist/js/modern/core/loader/useLoader.js +0 -114
- package/dist/js/modern/core/plugin.js +0 -58
- package/dist/js/modern/document/Body.js +0 -23
- package/dist/js/modern/document/DocumentContext.js +0 -9
- package/dist/js/modern/document/DocumentStructrueContext.js +0 -11
- package/dist/js/modern/document/Head.js +0 -27
- package/dist/js/modern/document/Html.js +0 -78
- package/dist/js/modern/document/Links.js +0 -10
- package/dist/js/modern/document/Root.js +0 -33
- package/dist/js/modern/document/Script.js +0 -20
- package/dist/js/modern/document/Scripts.js +0 -10
- package/dist/js/modern/document/cli/index.js +0 -228
- package/dist/js/modern/document/constants.js +0 -49
- package/dist/js/modern/document/index.js +0 -10
- package/dist/js/modern/exports/head.js +0 -6
- package/dist/js/modern/exports/loadable.js +0 -6
- package/dist/js/modern/exports/server.js +0 -4
- package/dist/js/modern/exports/styled.js +0 -6
- package/dist/js/modern/index.js +0 -22
- package/dist/js/modern/router/cli/index.js +0 -120
- package/dist/js/modern/router/index.js +0 -7
- package/dist/js/modern/router/runtime/DefaultNotFound.js +0 -14
- package/dist/js/modern/router/runtime/index.js +0 -9
- package/dist/js/modern/router/runtime/plugin.js +0 -104
- package/dist/js/modern/router/runtime/plugin.node.js +0 -149
- package/dist/js/modern/router/runtime/server.js +0 -1
- package/dist/js/modern/router/runtime/types.js +0 -0
- package/dist/js/modern/router/runtime/utils.js +0 -196
- package/dist/js/modern/router/runtime/withRouter.js +0 -36
- package/dist/js/modern/runtime-context.js +0 -7
- package/dist/js/modern/ssr/cli/babel-plugin-ssr-loader-id.js +0 -130
- package/dist/js/modern/ssr/cli/index.js +0 -172
- package/dist/js/modern/ssr/index.js +0 -159
- package/dist/js/modern/ssr/index.node.js +0 -79
- package/dist/js/modern/ssr/prefetch.js +0 -69
- package/dist/js/modern/ssr/react/index.js +0 -6
- package/dist/js/modern/ssr/react/nossr/index.js +0 -14
- package/dist/js/modern/ssr/react/prerender/index.js +0 -108
- package/dist/js/modern/ssr/react/prerender/type.js +0 -0
- package/dist/js/modern/ssr/react/prerender/util.js +0 -96
- package/dist/js/modern/ssr/react/withCallback/index.js +0 -15
- package/dist/js/modern/ssr/serverRender/helmet.js +0 -44
- package/dist/js/modern/ssr/serverRender/index.js +0 -35
- package/dist/js/modern/ssr/serverRender/renderToStream/buildTemplate.after.js +0 -36
- package/dist/js/modern/ssr/serverRender/renderToStream/buildTemplate.share.js +0 -11
- package/dist/js/modern/ssr/serverRender/renderToStream/bulidTemplate.before.js +0 -61
- package/dist/js/modern/ssr/serverRender/renderToStream/index.js +0 -58
- package/dist/js/modern/ssr/serverRender/renderToStream/loadable.js +0 -24
- package/dist/js/modern/ssr/serverRender/renderToStream/renderToPipe.js +0 -94
- package/dist/js/modern/ssr/serverRender/renderToStream/styledComponent.js +0 -12
- package/dist/js/modern/ssr/serverRender/renderToStream/template.js +0 -22
- package/dist/js/modern/ssr/serverRender/renderToStream/type.js +0 -0
- package/dist/js/modern/ssr/serverRender/renderToString/entry.js +0 -171
- package/dist/js/modern/ssr/serverRender/renderToString/index.js +0 -52
- package/dist/js/modern/ssr/serverRender/renderToString/loadable.js +0 -48
- package/dist/js/modern/ssr/serverRender/renderToString/reduce.js +0 -8
- package/dist/js/modern/ssr/serverRender/renderToString/styledComponent.js +0 -11
- package/dist/js/modern/ssr/serverRender/renderToString/template.js +0 -58
- package/dist/js/modern/ssr/serverRender/renderToString/type.js +0 -9
- package/dist/js/modern/ssr/serverRender/types.js +0 -4
- package/dist/js/modern/ssr/serverRender/utils.js +0 -22
- package/dist/js/modern/ssr/utils.js +0 -81
- package/dist/js/modern/state/cli/index.js +0 -83
- package/dist/js/modern/state/index.js +0 -7
- package/dist/js/modern/state/plugins.js +0 -13
- package/dist/js/modern/state/runtime/index.js +0 -9
- package/dist/js/modern/state/runtime/plugin.js +0 -97
- package/dist/js/modern/state/types.js +0 -0
- package/dist/js/node/cli/index.js +0 -99
- package/dist/js/node/common.js +0 -27
- package/dist/js/node/config.js +0 -15
- package/dist/js/node/core/app-config.js +0 -34
- package/dist/js/node/core/compatible.js +0 -312
- package/dist/js/node/core/index.js +0 -47
- package/dist/js/node/core/loader/index.js +0 -33
- package/dist/js/node/core/loader/loaderManager.js +0 -195
- package/dist/js/node/core/loader/useLoader.js +0 -132
- package/dist/js/node/core/plugin.js +0 -80
- package/dist/js/node/document/Body.js +0 -43
- package/dist/js/node/document/DocumentContext.js +0 -38
- package/dist/js/node/document/DocumentStructrueContext.js +0 -40
- package/dist/js/node/document/Head.js +0 -51
- package/dist/js/node/document/Html.js +0 -101
- package/dist/js/node/document/Links.js +0 -33
- package/dist/js/node/document/Root.js +0 -57
- package/dist/js/node/document/Script.js +0 -40
- package/dist/js/node/document/Scripts.js +0 -33
- package/dist/js/node/document/cli/index.js +0 -240
- package/dist/js/node/document/constants.js +0 -86
- package/dist/js/node/document/index.js +0 -26
- package/dist/js/node/exports/head.js +0 -34
- package/dist/js/node/exports/loadable.js +0 -34
- package/dist/js/node/exports/server.js +0 -27
- package/dist/js/node/exports/styled.js +0 -34
- package/dist/js/node/index.js +0 -44
- package/dist/js/node/router/cli/index.js +0 -135
- package/dist/js/node/router/index.js +0 -37
- package/dist/js/node/router/runtime/DefaultNotFound.js +0 -37
- package/dist/js/node/router/runtime/index.js +0 -33
- package/dist/js/node/router/runtime/plugin.js +0 -127
- package/dist/js/node/router/runtime/plugin.node.js +0 -175
- package/dist/js/node/router/runtime/server.js +0 -17
- package/dist/js/node/router/runtime/types.js +0 -15
- package/dist/js/node/router/runtime/utils.js +0 -221
- package/dist/js/node/router/runtime/withRouter.js +0 -57
- package/dist/js/node/runtime-context.js +0 -31
- package/dist/js/node/ssr/cli/babel-plugin-ssr-loader-id.js +0 -139
- package/dist/js/node/ssr/cli/index.js +0 -190
- package/dist/js/node/ssr/index.js +0 -185
- package/dist/js/node/ssr/index.node.js +0 -107
- package/dist/js/node/ssr/prefetch.js +0 -90
- package/dist/js/node/ssr/react/index.js +0 -30
- package/dist/js/node/ssr/react/nossr/index.js +0 -43
- package/dist/js/node/ssr/react/prerender/index.js +0 -130
- package/dist/js/node/ssr/react/prerender/type.js +0 -15
- package/dist/js/node/ssr/react/prerender/util.js +0 -123
- package/dist/js/node/ssr/react/withCallback/index.js +0 -38
- package/dist/js/node/ssr/serverRender/helmet.js +0 -65
- package/dist/js/node/ssr/serverRender/index.js +0 -56
- package/dist/js/node/ssr/serverRender/renderToStream/buildTemplate.after.js +0 -65
- package/dist/js/node/ssr/serverRender/renderToStream/buildTemplate.share.js +0 -35
- package/dist/js/node/ssr/serverRender/renderToStream/bulidTemplate.before.js +0 -87
- package/dist/js/node/ssr/serverRender/renderToStream/index.js +0 -87
- package/dist/js/node/ssr/serverRender/renderToStream/loadable.js +0 -47
- package/dist/js/node/ssr/serverRender/renderToStream/renderToPipe.js +0 -111
- package/dist/js/node/ssr/serverRender/renderToStream/styledComponent.js +0 -35
- package/dist/js/node/ssr/serverRender/renderToStream/template.js +0 -45
- package/dist/js/node/ssr/serverRender/renderToStream/type.js +0 -15
- package/dist/js/node/ssr/serverRender/renderToString/entry.js +0 -196
- package/dist/js/node/ssr/serverRender/renderToString/index.js +0 -81
- package/dist/js/node/ssr/serverRender/renderToString/loadable.js +0 -71
- package/dist/js/node/ssr/serverRender/renderToString/reduce.js +0 -31
- package/dist/js/node/ssr/serverRender/renderToString/styledComponent.js +0 -34
- package/dist/js/node/ssr/serverRender/renderToString/template.js +0 -82
- package/dist/js/node/ssr/serverRender/renderToString/type.js +0 -32
- package/dist/js/node/ssr/serverRender/types.js +0 -27
- package/dist/js/node/ssr/serverRender/utils.js +0 -46
- package/dist/js/node/ssr/utils.js +0 -106
- package/dist/js/node/state/cli/index.js +0 -100
- package/dist/js/node/state/index.js +0 -37
- package/dist/js/node/state/plugins.js +0 -45
- package/dist/js/node/state/runtime/index.js +0 -40
- package/dist/js/node/state/runtime/plugin.js +0 -121
- package/dist/js/node/state/types.js +0 -15
- package/dist/js/treeshaking/cli/index.js +0 -186
- package/dist/js/treeshaking/common.js +0 -4
- package/dist/js/treeshaking/config.js +0 -1
- package/dist/js/treeshaking/core/app-config.js +0 -9
- package/dist/js/treeshaking/core/compatible.js +0 -485
- package/dist/js/treeshaking/core/index.js +0 -7
- package/dist/js/treeshaking/core/loader/index.js +0 -2
- package/dist/js/treeshaking/core/loader/loaderManager.js +0 -406
- package/dist/js/treeshaking/core/loader/useLoader.js +0 -188
- package/dist/js/treeshaking/core/plugin.js +0 -176
- package/dist/js/treeshaking/document/Body.js +0 -18
- package/dist/js/treeshaking/document/DocumentContext.js +0 -7
- package/dist/js/treeshaking/document/DocumentStructrueContext.js +0 -9
- package/dist/js/treeshaking/document/Head.js +0 -24
- package/dist/js/treeshaking/document/Html.js +0 -99
- package/dist/js/treeshaking/document/Links.js +0 -8
- package/dist/js/treeshaking/document/Root.js +0 -26
- package/dist/js/treeshaking/document/Script.js +0 -15
- package/dist/js/treeshaking/document/Scripts.js +0 -8
- package/dist/js/treeshaking/document/cli/index.js +0 -393
- package/dist/js/treeshaking/document/constants.js +0 -35
- package/dist/js/treeshaking/document/index.js +0 -10
- package/dist/js/treeshaking/exports/head.js +0 -4
- package/dist/js/treeshaking/exports/loadable.js +0 -4
- package/dist/js/treeshaking/exports/server.js +0 -4
- package/dist/js/treeshaking/exports/styled.js +0 -4
- package/dist/js/treeshaking/index.js +0 -3
- package/dist/js/treeshaking/router/cli/index.js +0 -148
- package/dist/js/treeshaking/router/index.js +0 -4
- package/dist/js/treeshaking/router/runtime/DefaultNotFound.js +0 -14
- package/dist/js/treeshaking/router/runtime/index.js +0 -6
- package/dist/js/treeshaking/router/runtime/plugin.js +0 -132
- package/dist/js/treeshaking/router/runtime/plugin.node.js +0 -390
- package/dist/js/treeshaking/router/runtime/server.js +0 -1
- package/dist/js/treeshaking/router/runtime/types.js +0 -1
- package/dist/js/treeshaking/router/runtime/utils.js +0 -260
- package/dist/js/treeshaking/router/runtime/withRouter.js +0 -67
- package/dist/js/treeshaking/runtime-context.js +0 -4
- package/dist/js/treeshaking/ssr/cli/babel-plugin-ssr-loader-id.js +0 -122
- package/dist/js/treeshaking/ssr/cli/index.js +0 -217
- package/dist/js/treeshaking/ssr/index.js +0 -315
- package/dist/js/treeshaking/ssr/index.node.js +0 -240
- package/dist/js/treeshaking/ssr/prefetch.js +0 -199
- package/dist/js/treeshaking/ssr/react/index.js +0 -3
- package/dist/js/treeshaking/ssr/react/nossr/index.js +0 -58
- package/dist/js/treeshaking/ssr/react/prerender/index.js +0 -237
- package/dist/js/treeshaking/ssr/react/prerender/type.js +0 -1
- package/dist/js/treeshaking/ssr/react/prerender/util.js +0 -108
- package/dist/js/treeshaking/ssr/react/withCallback/index.js +0 -16
- package/dist/js/treeshaking/ssr/serverRender/helmet.js +0 -42
- package/dist/js/treeshaking/ssr/serverRender/index.js +0 -169
- package/dist/js/treeshaking/ssr/serverRender/renderToStream/buildTemplate.after.js +0 -34
- package/dist/js/treeshaking/ssr/serverRender/renderToStream/buildTemplate.share.js +0 -7
- package/dist/js/treeshaking/ssr/serverRender/renderToStream/bulidTemplate.before.js +0 -115
- package/dist/js/treeshaking/ssr/serverRender/renderToStream/index.js +0 -165
- package/dist/js/treeshaking/ssr/serverRender/renderToStream/loadable.js +0 -22
- package/dist/js/treeshaking/ssr/serverRender/renderToStream/renderToPipe.js +0 -119
- package/dist/js/treeshaking/ssr/serverRender/renderToStream/styledComponent.js +0 -11
- package/dist/js/treeshaking/ssr/serverRender/renderToStream/template.js +0 -63
- package/dist/js/treeshaking/ssr/serverRender/renderToStream/type.js +0 -1
- package/dist/js/treeshaking/ssr/serverRender/renderToString/entry.js +0 -393
- package/dist/js/treeshaking/ssr/serverRender/renderToString/index.js +0 -165
- package/dist/js/treeshaking/ssr/serverRender/renderToString/loadable.js +0 -56
- package/dist/js/treeshaking/ssr/serverRender/renderToString/reduce.js +0 -10
- package/dist/js/treeshaking/ssr/serverRender/renderToString/styledComponent.js +0 -9
- package/dist/js/treeshaking/ssr/serverRender/renderToString/template.js +0 -156
- package/dist/js/treeshaking/ssr/serverRender/renderToString/type.js +0 -7
- package/dist/js/treeshaking/ssr/serverRender/types.js +0 -2
- package/dist/js/treeshaking/ssr/serverRender/utils.js +0 -69
- package/dist/js/treeshaking/ssr/utils.js +0 -134
- package/dist/js/treeshaking/state/cli/index.js +0 -71
- package/dist/js/treeshaking/state/index.js +0 -4
- package/dist/js/treeshaking/state/plugins.js +0 -14
- package/dist/js/treeshaking/state/runtime/index.js +0 -5
- package/dist/js/treeshaking/state/runtime/plugin.js +0 -198
- package/dist/js/treeshaking/state/types.js +0 -1
|
@@ -55,7 +55,16 @@ function modifyRoutes(modifyFunction) {
|
|
|
55
55
|
console.error("It is not allowed to modify routes config after create router.");
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
const routerPlugin = ({
|
|
58
|
+
const routerPlugin = ({
|
|
59
|
+
serverBase = [],
|
|
60
|
+
supportHtml5History = true,
|
|
61
|
+
basename = "",
|
|
62
|
+
// when the current child app has multiple entries, there is a problem,
|
|
63
|
+
// so we have added a new parameter, the parameter will replace basename and baseUrl after the major version.
|
|
64
|
+
originalBaseUrl = "",
|
|
65
|
+
routesConfig,
|
|
66
|
+
createRoutes
|
|
67
|
+
}) => {
|
|
59
68
|
const select = (pathname) => serverBase.find((baseUrl) => pathname.search(baseUrl) === 0) || "/";
|
|
60
69
|
let routes = [];
|
|
61
70
|
finalRouteConfig = routesConfig;
|
|
@@ -91,7 +100,7 @@ const routerPlugin = ({ serverBase = [], supportHtml5History = true, basename =
|
|
|
91
100
|
const getRouteApp = () => {
|
|
92
101
|
const useCreateRouter = (props) => {
|
|
93
102
|
var _window__SERVER_DATA;
|
|
94
|
-
const baseUrl =
|
|
103
|
+
const baseUrl = originalBaseUrl || ((_window__SERVER_DATA = window._SERVER_DATA) === null || _window__SERVER_DATA === void 0 ? void 0 : _window__SERVER_DATA.router.baseUrl) || select(location.pathname);
|
|
95
104
|
const _basename = baseUrl === "/" ? (0, import_utils.urlJoin)(baseUrl, basename) : baseUrl;
|
|
96
105
|
let hydrationData = window._ROUTER_DATA;
|
|
97
106
|
const runtimeContext = (0, import_react.useContext)(import_core.RuntimeReactContext);
|
|
@@ -71,7 +71,7 @@ function createFetchHeaders(requestHeaders) {
|
|
|
71
71
|
}
|
|
72
72
|
return headers;
|
|
73
73
|
}
|
|
74
|
-
const routerPlugin = ({ basename = "",
|
|
74
|
+
const routerPlugin = ({ basename = "", originalBaseUrl = "", routesConfig, createRoutes }) => {
|
|
75
75
|
return {
|
|
76
76
|
name: "@modern-js/plugin-router",
|
|
77
77
|
registerHook: {
|
|
@@ -86,7 +86,7 @@ const routerPlugin = ({ basename = "", originBaseUrl = "", routesConfig, createR
|
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
const { request, mode: ssrMode, nonce } = context.ssrContext;
|
|
89
|
-
const baseUrl =
|
|
89
|
+
const baseUrl = originalBaseUrl || request.baseUrl;
|
|
90
90
|
const _basename = baseUrl === "/" ? (0, import_utils.urlJoin)(baseUrl, basename) : baseUrl;
|
|
91
91
|
const { reporter, serverTiming } = context.ssrContext;
|
|
92
92
|
const requestContext = (0, import_node.createRequestContext)();
|
|
@@ -65,30 +65,26 @@ const ssrPlugin = () => ({
|
|
|
65
65
|
return {
|
|
66
66
|
config() {
|
|
67
67
|
const appContext = api.useAppContext();
|
|
68
|
-
const userConfig = api.useConfigContext();
|
|
69
68
|
pluginsExportsUtils = (0, import_utils.createRuntimeExportsUtils)(appContext.internalDirectory, "plugins");
|
|
70
69
|
const { bundlerType = "webpack" } = api.useAppContext();
|
|
71
70
|
const babelHandler = (() => {
|
|
72
71
|
if (bundlerType === "webpack") {
|
|
73
72
|
return (config) => {
|
|
74
73
|
var _config_plugins;
|
|
75
|
-
const
|
|
74
|
+
const userConfig = api.useResolvedConfigContext();
|
|
76
75
|
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(import_path.default.join(__dirname, "./babel-plugin-ssr-loader-id"));
|
|
77
|
-
if ((0, import_utils.isUseSSRBundle)(
|
|
76
|
+
if ((0, import_utils.isUseSSRBundle)(userConfig) && checkUseStringSSR(userConfig)) {
|
|
78
77
|
var _config_plugins1;
|
|
79
78
|
(_config_plugins1 = config.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
|
|
80
79
|
}
|
|
81
80
|
};
|
|
82
81
|
} else if (bundlerType === "rspack") {
|
|
83
82
|
return (config) => {
|
|
84
|
-
const
|
|
85
|
-
if ((0, import_utils.isUseSSRBundle)(
|
|
86
|
-
var _config_plugins;
|
|
83
|
+
const userConfig = api.useResolvedConfigContext();
|
|
84
|
+
if ((0, import_utils.isUseSSRBundle)(userConfig) && checkUseStringSSR(userConfig)) {
|
|
85
|
+
var _config_plugins, _config_plugins1;
|
|
87
86
|
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(import_path.default.join(__dirname, "./babel-plugin-ssr-loader-id"));
|
|
88
|
-
|
|
89
|
-
var _config_plugins1;
|
|
90
|
-
(_config_plugins1 = config.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
|
|
91
|
-
}
|
|
87
|
+
(_config_plugins1 = config.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
|
|
92
88
|
}
|
|
93
89
|
};
|
|
94
90
|
}
|
|
@@ -106,8 +102,8 @@ const ssrPlugin = () => ({
|
|
|
106
102
|
},
|
|
107
103
|
tools: {
|
|
108
104
|
bundlerChain(chain, { isServer, isServiceWorker }) {
|
|
109
|
-
const
|
|
110
|
-
if ((0, import_utils.isUseSSRBundle)(
|
|
105
|
+
const userConfig = api.useResolvedConfigContext();
|
|
106
|
+
if ((0, import_utils.isUseSSRBundle)(userConfig) && !isServer && !isServiceWorker && checkUseStringSSR(userConfig)) {
|
|
111
107
|
const LoadableBundlerPlugin = require("./loadable-bundler-plugin.js");
|
|
112
108
|
chain.plugin("loadable").use(LoadableBundlerPlugin, [
|
|
113
109
|
{
|
|
@@ -116,7 +112,7 @@ const ssrPlugin = () => ({
|
|
|
116
112
|
]);
|
|
117
113
|
}
|
|
118
114
|
},
|
|
119
|
-
babel:
|
|
115
|
+
babel: babelHandler
|
|
120
116
|
}
|
|
121
117
|
};
|
|
122
118
|
},
|
|
@@ -23,7 +23,7 @@ function modifyRoutes(modifyFunction) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
var routerPlugin = function(param) {
|
|
26
|
-
var _param_serverBase = param.serverBase, serverBase = _param_serverBase === void 0 ? [] : _param_serverBase, _param_supportHtml5History = param.supportHtml5History, supportHtml5History = _param_supportHtml5History === void 0 ? true : _param_supportHtml5History, _param_basename = param.basename, basename = _param_basename === void 0 ? "" : _param_basename,
|
|
26
|
+
var _param_serverBase = param.serverBase, serverBase = _param_serverBase === void 0 ? [] : _param_serverBase, _param_supportHtml5History = param.supportHtml5History, supportHtml5History = _param_supportHtml5History === void 0 ? true : _param_supportHtml5History, _param_basename = param.basename, basename = _param_basename === void 0 ? "" : _param_basename, _param_originalBaseUrl = param.originalBaseUrl, originalBaseUrl = _param_originalBaseUrl === void 0 ? "" : _param_originalBaseUrl, routesConfig = param.routesConfig, createRoutes = param.createRoutes;
|
|
27
27
|
var select = function(pathname) {
|
|
28
28
|
return serverBase.find(function(baseUrl) {
|
|
29
29
|
return pathname.search(baseUrl) === 0;
|
|
@@ -65,7 +65,7 @@ var routerPlugin = function(param) {
|
|
|
65
65
|
var getRouteApp = function() {
|
|
66
66
|
var useCreateRouter = function(props) {
|
|
67
67
|
var _window__SERVER_DATA;
|
|
68
|
-
var baseUrl =
|
|
68
|
+
var baseUrl = originalBaseUrl || ((_window__SERVER_DATA = window._SERVER_DATA) === null || _window__SERVER_DATA === void 0 ? void 0 : _window__SERVER_DATA.router.baseUrl) || select(location.pathname);
|
|
69
69
|
var _basename = baseUrl === "/" ? urlJoin(baseUrl, basename) : baseUrl;
|
|
70
70
|
var hydrationData = window._ROUTER_DATA;
|
|
71
71
|
var runtimeContext = useContext(RuntimeReactContext);
|
|
@@ -77,7 +77,7 @@ function createFetchHeaders(requestHeaders) {
|
|
|
77
77
|
return headers;
|
|
78
78
|
}
|
|
79
79
|
var routerPlugin = function(param) {
|
|
80
|
-
var _param_basename = param.basename, basename = _param_basename === void 0 ? "" : _param_basename,
|
|
80
|
+
var _param_basename = param.basename, basename = _param_basename === void 0 ? "" : _param_basename, _param_originalBaseUrl = param.originalBaseUrl, originalBaseUrl = _param_originalBaseUrl === void 0 ? "" : _param_originalBaseUrl, routesConfig = param.routesConfig, createRoutes = param.createRoutes;
|
|
81
81
|
return {
|
|
82
82
|
name: "@modern-js/plugin-router",
|
|
83
83
|
registerHook: {
|
|
@@ -101,7 +101,7 @@ var routerPlugin = function(param) {
|
|
|
101
101
|
];
|
|
102
102
|
}
|
|
103
103
|
_context_ssrContext = context.ssrContext, request = _context_ssrContext.request, ssrMode = _context_ssrContext.mode, nonce = _context_ssrContext.nonce;
|
|
104
|
-
baseUrl =
|
|
104
|
+
baseUrl = originalBaseUrl || request.baseUrl;
|
|
105
105
|
_basename = baseUrl === "/" ? urlJoin(baseUrl, basename) : baseUrl;
|
|
106
106
|
_context_ssrContext1 = context.ssrContext, reporter = _context_ssrContext1.reporter, serverTiming = _context_ssrContext1.serverTiming;
|
|
107
107
|
requestContext = createRequestContext();
|
|
@@ -53,30 +53,26 @@ var ssrPlugin = function() {
|
|
|
53
53
|
return {
|
|
54
54
|
config: function config() {
|
|
55
55
|
var appContext = api.useAppContext();
|
|
56
|
-
var userConfig = api.useConfigContext();
|
|
57
56
|
pluginsExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, "plugins");
|
|
58
57
|
var _api_useAppContext = api.useAppContext(), _api_useAppContext_bundlerType = _api_useAppContext.bundlerType, bundlerType = _api_useAppContext_bundlerType === void 0 ? "webpack" : _api_useAppContext_bundlerType;
|
|
59
58
|
var babelHandler = function() {
|
|
60
59
|
if (bundlerType === "webpack") {
|
|
61
60
|
return function(config2) {
|
|
62
61
|
var _config_plugins;
|
|
63
|
-
var
|
|
62
|
+
var userConfig = api.useResolvedConfigContext();
|
|
64
63
|
(_config_plugins = config2.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(path.join(__dirname, "./babel-plugin-ssr-loader-id"));
|
|
65
|
-
if (isUseSSRBundle(
|
|
64
|
+
if (isUseSSRBundle(userConfig) && checkUseStringSSR(userConfig)) {
|
|
66
65
|
var _config_plugins1;
|
|
67
66
|
(_config_plugins1 = config2.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
|
|
68
67
|
}
|
|
69
68
|
};
|
|
70
69
|
} else if (bundlerType === "rspack") {
|
|
71
70
|
return function(config2) {
|
|
72
|
-
var
|
|
73
|
-
if (isUseSSRBundle(
|
|
74
|
-
var _config_plugins;
|
|
71
|
+
var userConfig = api.useResolvedConfigContext();
|
|
72
|
+
if (isUseSSRBundle(userConfig) && checkUseStringSSR(userConfig)) {
|
|
73
|
+
var _config_plugins, _config_plugins1;
|
|
75
74
|
(_config_plugins = config2.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(path.join(__dirname, "./babel-plugin-ssr-loader-id"));
|
|
76
|
-
|
|
77
|
-
var _config_plugins1;
|
|
78
|
-
(_config_plugins1 = config2.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
|
|
79
|
-
}
|
|
75
|
+
(_config_plugins1 = config2.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
|
|
80
76
|
}
|
|
81
77
|
};
|
|
82
78
|
}
|
|
@@ -96,8 +92,8 @@ var ssrPlugin = function() {
|
|
|
96
92
|
tools: {
|
|
97
93
|
bundlerChain: function bundlerChain(chain, param) {
|
|
98
94
|
var isServer = param.isServer, isServiceWorker = param.isServiceWorker;
|
|
99
|
-
var
|
|
100
|
-
if (isUseSSRBundle(
|
|
95
|
+
var userConfig = api.useResolvedConfigContext();
|
|
96
|
+
if (isUseSSRBundle(userConfig) && !isServer && !isServiceWorker && checkUseStringSSR(userConfig)) {
|
|
101
97
|
var LoadableBundlerPlugin = require("./loadable-bundler-plugin.js");
|
|
102
98
|
chain.plugin("loadable").use(LoadableBundlerPlugin, [
|
|
103
99
|
{
|
|
@@ -106,7 +102,7 @@ var ssrPlugin = function() {
|
|
|
106
102
|
]);
|
|
107
103
|
}
|
|
108
104
|
},
|
|
109
|
-
babel:
|
|
105
|
+
babel: babelHandler
|
|
110
106
|
}
|
|
111
107
|
};
|
|
112
108
|
},
|
|
@@ -19,7 +19,16 @@ function modifyRoutes(modifyFunction) {
|
|
|
19
19
|
console.error("It is not allowed to modify routes config after create router.");
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
const routerPlugin = ({
|
|
22
|
+
const routerPlugin = ({
|
|
23
|
+
serverBase = [],
|
|
24
|
+
supportHtml5History = true,
|
|
25
|
+
basename = "",
|
|
26
|
+
// when the current child app has multiple entries, there is a problem,
|
|
27
|
+
// so we have added a new parameter, the parameter will replace basename and baseUrl after the major version.
|
|
28
|
+
originalBaseUrl = "",
|
|
29
|
+
routesConfig,
|
|
30
|
+
createRoutes
|
|
31
|
+
}) => {
|
|
23
32
|
const select = (pathname) => serverBase.find((baseUrl) => pathname.search(baseUrl) === 0) || "/";
|
|
24
33
|
let routes = [];
|
|
25
34
|
finalRouteConfig = routesConfig;
|
|
@@ -55,7 +64,7 @@ const routerPlugin = ({ serverBase = [], supportHtml5History = true, basename =
|
|
|
55
64
|
const getRouteApp = () => {
|
|
56
65
|
const useCreateRouter = (props) => {
|
|
57
66
|
var _window__SERVER_DATA;
|
|
58
|
-
const baseUrl =
|
|
67
|
+
const baseUrl = originalBaseUrl || ((_window__SERVER_DATA = window._SERVER_DATA) === null || _window__SERVER_DATA === void 0 ? void 0 : _window__SERVER_DATA.router.baseUrl) || select(location.pathname);
|
|
59
68
|
const _basename = baseUrl === "/" ? urlJoin(baseUrl, basename) : baseUrl;
|
|
60
69
|
let hydrationData = window._ROUTER_DATA;
|
|
61
70
|
const runtimeContext = useContext(RuntimeReactContext);
|
|
@@ -36,7 +36,7 @@ function createFetchHeaders(requestHeaders) {
|
|
|
36
36
|
}
|
|
37
37
|
return headers;
|
|
38
38
|
}
|
|
39
|
-
const routerPlugin = ({ basename = "",
|
|
39
|
+
const routerPlugin = ({ basename = "", originalBaseUrl = "", routesConfig, createRoutes }) => {
|
|
40
40
|
return {
|
|
41
41
|
name: "@modern-js/plugin-router",
|
|
42
42
|
registerHook: {
|
|
@@ -51,7 +51,7 @@ const routerPlugin = ({ basename = "", originBaseUrl = "", routesConfig, createR
|
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
const { request, mode: ssrMode, nonce } = context.ssrContext;
|
|
54
|
-
const baseUrl =
|
|
54
|
+
const baseUrl = originalBaseUrl || request.baseUrl;
|
|
55
55
|
const _basename = baseUrl === "/" ? urlJoin(baseUrl, basename) : baseUrl;
|
|
56
56
|
const { reporter, serverTiming } = context.ssrContext;
|
|
57
57
|
const requestContext = createRequestContext();
|
|
@@ -31,30 +31,26 @@ const ssrPlugin = () => ({
|
|
|
31
31
|
return {
|
|
32
32
|
config() {
|
|
33
33
|
const appContext = api.useAppContext();
|
|
34
|
-
const userConfig = api.useConfigContext();
|
|
35
34
|
pluginsExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, "plugins");
|
|
36
35
|
const { bundlerType = "webpack" } = api.useAppContext();
|
|
37
36
|
const babelHandler = (() => {
|
|
38
37
|
if (bundlerType === "webpack") {
|
|
39
38
|
return (config) => {
|
|
40
39
|
var _config_plugins;
|
|
41
|
-
const
|
|
40
|
+
const userConfig = api.useResolvedConfigContext();
|
|
42
41
|
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(path.join(__dirname, "./babel-plugin-ssr-loader-id"));
|
|
43
|
-
if (isUseSSRBundle(
|
|
42
|
+
if (isUseSSRBundle(userConfig) && checkUseStringSSR(userConfig)) {
|
|
44
43
|
var _config_plugins1;
|
|
45
44
|
(_config_plugins1 = config.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
|
|
46
45
|
}
|
|
47
46
|
};
|
|
48
47
|
} else if (bundlerType === "rspack") {
|
|
49
48
|
return (config) => {
|
|
50
|
-
const
|
|
51
|
-
if (isUseSSRBundle(
|
|
52
|
-
var _config_plugins;
|
|
49
|
+
const userConfig = api.useResolvedConfigContext();
|
|
50
|
+
if (isUseSSRBundle(userConfig) && checkUseStringSSR(userConfig)) {
|
|
51
|
+
var _config_plugins, _config_plugins1;
|
|
53
52
|
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(path.join(__dirname, "./babel-plugin-ssr-loader-id"));
|
|
54
|
-
|
|
55
|
-
var _config_plugins1;
|
|
56
|
-
(_config_plugins1 = config.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
|
|
57
|
-
}
|
|
53
|
+
(_config_plugins1 = config.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
|
|
58
54
|
}
|
|
59
55
|
};
|
|
60
56
|
}
|
|
@@ -72,8 +68,8 @@ const ssrPlugin = () => ({
|
|
|
72
68
|
},
|
|
73
69
|
tools: {
|
|
74
70
|
bundlerChain(chain, { isServer, isServiceWorker }) {
|
|
75
|
-
const
|
|
76
|
-
if (isUseSSRBundle(
|
|
71
|
+
const userConfig = api.useResolvedConfigContext();
|
|
72
|
+
if (isUseSSRBundle(userConfig) && !isServer && !isServiceWorker && checkUseStringSSR(userConfig)) {
|
|
77
73
|
const LoadableBundlerPlugin = require("./loadable-bundler-plugin.js");
|
|
78
74
|
chain.plugin("loadable").use(LoadableBundlerPlugin, [
|
|
79
75
|
{
|
|
@@ -82,7 +78,7 @@ const ssrPlugin = () => ({
|
|
|
82
78
|
]);
|
|
83
79
|
}
|
|
84
80
|
},
|
|
85
|
-
babel:
|
|
81
|
+
babel: babelHandler
|
|
86
82
|
}
|
|
87
83
|
};
|
|
88
84
|
},
|
|
@@ -3,4 +3,4 @@ import type { RouterConfig, Routes } from './types';
|
|
|
3
3
|
export declare let finalRouteConfig: RouterConfig['routesConfig'];
|
|
4
4
|
export declare let beforeCreateRouter: boolean;
|
|
5
5
|
export declare function modifyRoutes(modifyFunction: (routes: Routes) => Routes): void;
|
|
6
|
-
export declare const routerPlugin: ({ serverBase, supportHtml5History, basename,
|
|
6
|
+
export declare const routerPlugin: ({ serverBase, supportHtml5History, basename, originalBaseUrl, routesConfig, createRoutes, }: RouterConfig) => Plugin;
|
|
@@ -2,5 +2,5 @@ import type { Plugin } from '../../core';
|
|
|
2
2
|
import { SSRServerContext } from '../../ssr/serverRender/types';
|
|
3
3
|
import type { RouterConfig } from './types';
|
|
4
4
|
export declare function createFetchHeaders(requestHeaders: SSRServerContext['request']['headers']): Headers;
|
|
5
|
-
export declare const routerPlugin: ({ basename,
|
|
5
|
+
export declare const routerPlugin: ({ basename, originalBaseUrl, routesConfig, createRoutes, }: RouterConfig) => Plugin;
|
|
6
6
|
export declare const modifyRoutes: () => void;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.49.
|
|
18
|
+
"version": "2.49.4",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=14.17.6"
|
|
21
21
|
},
|
|
@@ -170,10 +170,10 @@
|
|
|
170
170
|
"react-side-effect": "^2.1.1",
|
|
171
171
|
"styled-components": "^5.3.1",
|
|
172
172
|
"@swc/helpers": "0.5.3",
|
|
173
|
-
"@modern-js/plugin": "2.49.
|
|
174
|
-
"@modern-js/types": "2.49.
|
|
175
|
-
"@modern-js/utils": "2.49.
|
|
176
|
-
"@modern-js/runtime-utils": "2.49.
|
|
173
|
+
"@modern-js/plugin": "2.49.4",
|
|
174
|
+
"@modern-js/types": "2.49.4",
|
|
175
|
+
"@modern-js/utils": "2.49.4",
|
|
176
|
+
"@modern-js/runtime-utils": "2.49.4"
|
|
177
177
|
},
|
|
178
178
|
"peerDependencies": {
|
|
179
179
|
"react": ">=17",
|
|
@@ -194,11 +194,11 @@
|
|
|
194
194
|
"ts-jest": "^29.1.0",
|
|
195
195
|
"typescript": "^5",
|
|
196
196
|
"webpack": "^5.91.0",
|
|
197
|
-
"@
|
|
198
|
-
"@modern-js/
|
|
199
|
-
"@modern-js/
|
|
200
|
-
"@scripts/
|
|
201
|
-
"@
|
|
197
|
+
"@modern-js/app-tools": "2.49.4",
|
|
198
|
+
"@modern-js/core": "2.49.4",
|
|
199
|
+
"@modern-js/server-core": "2.49.4",
|
|
200
|
+
"@scripts/build": "2.49.4",
|
|
201
|
+
"@scripts/jest-config": "2.49.4"
|
|
202
202
|
},
|
|
203
203
|
"sideEffects": false,
|
|
204
204
|
"publishConfig": {
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
var __async = (__this, __arguments, generator) => {
|
|
2
|
-
return new Promise((resolve, reject) => {
|
|
3
|
-
var fulfilled = (value) => {
|
|
4
|
-
try {
|
|
5
|
-
step(generator.next(value));
|
|
6
|
-
} catch (e) {
|
|
7
|
-
reject(e);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var rejected = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
step(generator.throw(value));
|
|
13
|
-
} catch (e) {
|
|
14
|
-
reject(e);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
import path from "path";
|
|
22
|
-
import { PLUGIN_SCHEMAS, cleanRequireCache, isReact18 } from "@modern-js/utils";
|
|
23
|
-
import PluginState from "../state/cli";
|
|
24
|
-
import PluginSSR from "../ssr/cli";
|
|
25
|
-
import PluginRouter from "../router/cli";
|
|
26
|
-
import Document from "../document/cli";
|
|
27
|
-
var cli_default = () => ({
|
|
28
|
-
name: "@modern-js/runtime",
|
|
29
|
-
post: [
|
|
30
|
-
"@modern-js/plugin-router",
|
|
31
|
-
"@modern-js/plugin-ssr",
|
|
32
|
-
"@modern-js/plugin-document",
|
|
33
|
-
"@modern-js/plugin-state",
|
|
34
|
-
"@modern-js/plugin-design-token"
|
|
35
|
-
],
|
|
36
|
-
usePlugins: [PluginState(), PluginSSR(), PluginRouter(), Document()],
|
|
37
|
-
setup: (api) => {
|
|
38
|
-
return {
|
|
39
|
-
config() {
|
|
40
|
-
const dir = api.useAppContext().internalDirectory || "";
|
|
41
|
-
process.env.IS_REACT18 = isReact18(path.join(dir, "../../")).toString();
|
|
42
|
-
return {
|
|
43
|
-
runtime: {},
|
|
44
|
-
runtimeByEntries: {},
|
|
45
|
-
source: {
|
|
46
|
-
alias: {
|
|
47
|
-
"styled-components": require.resolve("styled-components")
|
|
48
|
-
},
|
|
49
|
-
globalVars: {
|
|
50
|
-
"process.env.IS_REACT18": process.env.IS_REACT18
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
},
|
|
55
|
-
validateSchema() {
|
|
56
|
-
return PLUGIN_SCHEMAS["@modern-js/runtime"];
|
|
57
|
-
},
|
|
58
|
-
beforeRestart() {
|
|
59
|
-
return __async(this, null, function* () {
|
|
60
|
-
cleanRequireCache([
|
|
61
|
-
require.resolve("../state/cli"),
|
|
62
|
-
require.resolve("../router/cli"),
|
|
63
|
-
require.resolve("../ssr/cli")
|
|
64
|
-
]);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
export {
|
|
71
|
-
cli_default as default
|
|
72
|
-
};
|
package/dist/js/modern/common.js
DELETED
package/dist/js/modern/config.js
DELETED
|
File without changes
|