@modern-js/runtime 2.60.1-alpha.4 → 2.60.1
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/index.js +4 -4
- package/dist/cjs/document/cli/index.js +5 -0
- package/dist/cjs/router/cli/code/index.js +25 -7
- package/dist/cjs/router/cli/index.js +1 -2
- package/dist/cjs/router/runtime/plugin.js +1 -4
- package/dist/cjs/router/runtime/plugin.node.js +1 -4
- package/dist/esm/cli/index.js +1 -1
- package/dist/esm/document/cli/index.js +5 -0
- package/dist/esm/router/cli/code/index.js +20 -2
- package/dist/esm/router/cli/index.js +1 -2
- package/dist/esm/router/runtime/plugin.js +1 -4
- package/dist/esm/router/runtime/plugin.node.js +1 -4
- package/dist/esm-node/cli/index.js +4 -4
- package/dist/esm-node/document/cli/index.js +5 -0
- package/dist/esm-node/router/cli/code/index.js +20 -2
- package/dist/esm-node/router/cli/index.js +1 -2
- package/dist/esm-node/router/runtime/plugin.js +1 -4
- package/dist/esm-node/router/runtime/plugin.node.js +1 -4
- package/package.json +10 -10
package/dist/cjs/cli/index.js
CHANGED
|
@@ -125,10 +125,10 @@ const runtimePlugin = (params) => ({
|
|
|
125
125
|
* Compatible with the reference path of the old version of the plugin.
|
|
126
126
|
*/
|
|
127
127
|
[`@${metaName}/runtime/plugins`]: pluginsExportsUtils.getPath(),
|
|
128
|
-
"@meta/runtime/browser
|
|
129
|
-
"@meta/runtime/react
|
|
130
|
-
"@meta/runtime/context
|
|
131
|
-
"@meta/runtime
|
|
128
|
+
"@meta/runtime/browser": "@modern-js/runtime/browser",
|
|
129
|
+
"@meta/runtime/react": "@modern-js/runtime/react",
|
|
130
|
+
"@meta/runtime/context": "@modern-js/runtime/context",
|
|
131
|
+
"@meta/runtime": "@modern-js/runtime"
|
|
132
132
|
},
|
|
133
133
|
globalVars: {
|
|
134
134
|
"process.env.IS_REACT18": process.env.IS_REACT18
|
|
@@ -185,6 +185,11 @@ const documentPlugin = () => ({
|
|
|
185
185
|
};
|
|
186
186
|
return {
|
|
187
187
|
config: () => {
|
|
188
|
+
var _userConfig_tools;
|
|
189
|
+
const userConfig = api.useConfigContext();
|
|
190
|
+
if (((_userConfig_tools = userConfig.tools) === null || _userConfig_tools === void 0 ? void 0 : _userConfig_tools.htmlPlugin) === false) {
|
|
191
|
+
return {};
|
|
192
|
+
}
|
|
188
193
|
return {
|
|
189
194
|
tools: {
|
|
190
195
|
htmlPlugin: (options, entry) => {
|
|
@@ -34,14 +34,13 @@ __export(code_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(code_exports);
|
|
35
35
|
var import_path = __toESM(require("path"));
|
|
36
36
|
var import_utils = require("@modern-js/utils");
|
|
37
|
-
var import_utils2 = require("@modern-js/utils");
|
|
38
37
|
var import_lodash = require("@modern-js/utils/lodash");
|
|
39
38
|
var import_constants = require("../../../cli/constants");
|
|
40
39
|
var import_constants2 = require("../constants");
|
|
41
40
|
var import_getClientRoutes = require("./getClientRoutes");
|
|
42
41
|
var import_nestedRoutes = require("./nestedRoutes");
|
|
43
42
|
var templates = __toESM(require("./templates"));
|
|
44
|
-
var
|
|
43
|
+
var import_utils2 = require("./utils");
|
|
45
44
|
const generateCode = async (appContext, config, entrypoints, api) => {
|
|
46
45
|
const { internalDirectory, srcDirectory, internalDirAlias, internalSrcAlias, packageName } = appContext;
|
|
47
46
|
const hookRunners = api.useHookRunners();
|
|
@@ -85,7 +84,7 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
85
84
|
const config2 = api.useResolvedConfigContext();
|
|
86
85
|
const ssrByRouteIds = config2.server.ssrByRouteIds || [];
|
|
87
86
|
const clonedRoutes = (0, import_lodash.cloneDeep)(initialRoutes);
|
|
88
|
-
const markedRoutes = ssrByRouteIds.length > 0 ?
|
|
87
|
+
const markedRoutes = ssrByRouteIds.length > 0 ? markRoutes(clonedRoutes, ssrByRouteIds) : initialRoutes;
|
|
89
88
|
const { routes } = await hookRunners.modifyFileSystemRoutes({
|
|
90
89
|
entrypoint,
|
|
91
90
|
routes: markedRoutes
|
|
@@ -117,9 +116,9 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
117
116
|
});
|
|
118
117
|
if (entrypoint.nestedRoutesEntry && (0, import_utils.isUseSSRBundle)(config2)) {
|
|
119
118
|
var _config_output1;
|
|
120
|
-
const routesServerFile = (0,
|
|
121
|
-
const filtedRoutesForServer = (0,
|
|
122
|
-
const routesForServerLoaderMatches = (0,
|
|
119
|
+
const routesServerFile = (0, import_utils2.getServerLoadersFile)(internalDirectory, entryName);
|
|
120
|
+
const filtedRoutesForServer = (0, import_utils.filterRoutesForServer)(routes);
|
|
121
|
+
const routesForServerLoaderMatches = (0, import_utils.filterRoutesLoader)(routes);
|
|
123
122
|
const code2 = templates.routesForServer({
|
|
124
123
|
routesForServerLoaderMatches
|
|
125
124
|
});
|
|
@@ -138,7 +137,7 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
138
137
|
}
|
|
139
138
|
const serverLoaderCombined = templates.ssrLoaderCombinedModule(entrypoints, entrypoint, config2, appContext);
|
|
140
139
|
if (serverLoaderCombined) {
|
|
141
|
-
const serverLoaderFile = (0,
|
|
140
|
+
const serverLoaderFile = (0, import_utils2.getServerCombinedModueFile)(internalDirectory, entryName);
|
|
142
141
|
await import_utils.fs.outputFile(serverLoaderFile, serverLoaderCombined);
|
|
143
142
|
}
|
|
144
143
|
await import_utils.fs.outputFile(import_path.default.resolve(internalDirectory, `./${entryName}/${import_constants2.FILE_SYSTEM_ROUTES_FILE_NAME}`), code, "utf8");
|
|
@@ -146,6 +145,25 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
146
145
|
}
|
|
147
146
|
}
|
|
148
147
|
};
|
|
148
|
+
function markRoutes(routes, routeIds) {
|
|
149
|
+
return routes.map((route) => {
|
|
150
|
+
if (route.type !== "nested") {
|
|
151
|
+
return route;
|
|
152
|
+
}
|
|
153
|
+
if (route.children && route.children.length > 0) {
|
|
154
|
+
route.children = markRoutes(route.children, routeIds);
|
|
155
|
+
}
|
|
156
|
+
if (route.children && route.children.length > 0) {
|
|
157
|
+
route.inValidSSRRoute = route.children.every((child) => {
|
|
158
|
+
var _child_inValidSSRRoute;
|
|
159
|
+
return (_child_inValidSSRRoute = child.inValidSSRRoute) !== null && _child_inValidSSRRoute !== void 0 ? _child_inValidSSRRoute : false;
|
|
160
|
+
});
|
|
161
|
+
} else if (route.id) {
|
|
162
|
+
route.inValidSSRRoute = !routeIds.includes(route.id);
|
|
163
|
+
}
|
|
164
|
+
return route;
|
|
165
|
+
});
|
|
166
|
+
}
|
|
149
167
|
function generatorRegisterCode(internalDirectory, entryName, code) {
|
|
150
168
|
import_utils.fs.outputFileSync(import_path.default.resolve(internalDirectory, `./${entryName}/${import_constants.ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME}`), code, "utf8");
|
|
151
169
|
}
|
|
@@ -37,7 +37,6 @@ __export(cli_exports, {
|
|
|
37
37
|
module.exports = __toCommonJS(cli_exports);
|
|
38
38
|
var import_node_path = __toESM(require("node:path"));
|
|
39
39
|
var import_utils = require("@modern-js/utils");
|
|
40
|
-
var import_utils2 = require("@modern-js/utils");
|
|
41
40
|
var import_entry = require("./entry");
|
|
42
41
|
var import_handler = require("./handler");
|
|
43
42
|
var import_entry2 = require("./entry");
|
|
@@ -116,7 +115,7 @@ const routerPlugin = () => ({
|
|
|
116
115
|
},
|
|
117
116
|
async modifyFileSystemRoutes({ entrypoint, routes }) {
|
|
118
117
|
nestedRoutes[entrypoint.entryName] = routes;
|
|
119
|
-
nestedRoutesForServer[entrypoint.entryName] = (0,
|
|
118
|
+
nestedRoutesForServer[entrypoint.entryName] = (0, import_utils.filterRoutesForServer)(routes);
|
|
120
119
|
return {
|
|
121
120
|
entrypoint,
|
|
122
121
|
routes
|
|
@@ -139,7 +139,7 @@ const routerPlugin = (userConfig = {}) => {
|
|
|
139
139
|
return (props) => {
|
|
140
140
|
beforeCreateRouter = false;
|
|
141
141
|
const router = useCreateRouter(props);
|
|
142
|
-
|
|
142
|
+
return (
|
|
143
143
|
// To match the node tree about https://github.com/web-infra-dev/modern.js/blob/v2.59.0/packages/runtime/plugin-runtime/src/router/runtime/plugin.node.tsx#L150-L168
|
|
144
144
|
// According to react [useId generation algorithm](https://github.com/facebook/react/pull/22644), `useId` will generate id with the react node react struct.
|
|
145
145
|
// To void hydration failed, we must guarantee that the node tree when browser hydrate must have same struct with node tree when ssr render.
|
|
@@ -153,9 +153,6 @@ const routerPlugin = (userConfig = {}) => {
|
|
|
153
153
|
]
|
|
154
154
|
})
|
|
155
155
|
);
|
|
156
|
-
return App ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, {
|
|
157
|
-
children: routerWrapper
|
|
158
|
-
}) : routerWrapper;
|
|
159
156
|
};
|
|
160
157
|
};
|
|
161
158
|
return getRouteApp();
|
|
@@ -125,7 +125,7 @@ const routerPlugin = (userConfig = {}) => {
|
|
|
125
125
|
const context = (0, import_react.useContext)(import_core.RuntimeReactContext);
|
|
126
126
|
const { remixRouter, routerContext, ssrContext } = context;
|
|
127
127
|
const { nonce, mode } = ssrContext;
|
|
128
|
-
|
|
128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
129
129
|
children: [
|
|
130
130
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_router.StaticRouterProvider, {
|
|
131
131
|
router: remixRouter,
|
|
@@ -141,9 +141,6 @@ const routerPlugin = (userConfig = {}) => {
|
|
|
141
141
|
mode === "stream" && import_common.JSX_SHELL_STREAM_END_MARK
|
|
142
142
|
]
|
|
143
143
|
});
|
|
144
|
-
return App ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, {
|
|
145
|
-
children: routerWrapper
|
|
146
|
-
}) : routerWrapper;
|
|
147
144
|
};
|
|
148
145
|
};
|
|
149
146
|
return getRouteApp();
|
package/dist/esm/cli/index.js
CHANGED
|
@@ -109,7 +109,7 @@ var runtimePlugin = function(params) {
|
|
|
109
109
|
}, /**
|
|
110
110
|
* Compatible with the reference path of the old version of the plugin.
|
|
111
111
|
*/
|
|
112
|
-
_define_property(_obj, "@".concat(metaName, "/runtime/plugins"), pluginsExportsUtils.getPath()), _define_property(_obj, "@meta/runtime/browser
|
|
112
|
+
_define_property(_obj, "@".concat(metaName, "/runtime/plugins"), pluginsExportsUtils.getPath()), _define_property(_obj, "@meta/runtime/browser", "@modern-js/runtime/browser"), _define_property(_obj, "@meta/runtime/react", "@modern-js/runtime/react"), _define_property(_obj, "@meta/runtime/context", "@modern-js/runtime/context"), _define_property(_obj, "@meta/runtime", "@modern-js/runtime"), _obj),
|
|
113
113
|
globalVars: {
|
|
114
114
|
"process.env.IS_REACT18": process.env.IS_REACT18
|
|
115
115
|
}
|
|
@@ -222,6 +222,11 @@ var documentPlugin = function() {
|
|
|
222
222
|
2,
|
|
223
223
|
{
|
|
224
224
|
config: function() {
|
|
225
|
+
var _userConfig_tools;
|
|
226
|
+
var userConfig = api.useConfigContext();
|
|
227
|
+
if (((_userConfig_tools = userConfig.tools) === null || _userConfig_tools === void 0 ? void 0 : _userConfig_tools.htmlPlugin) === false) {
|
|
228
|
+
return {};
|
|
229
|
+
}
|
|
225
230
|
return {
|
|
226
231
|
tools: {
|
|
227
232
|
htmlPlugin: function(options, entry) {
|
|
@@ -2,8 +2,7 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
|
2
2
|
import { _ as _type_of } from "@swc/helpers/_/_type_of";
|
|
3
3
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
4
4
|
import path from "path";
|
|
5
|
-
import { fs, getEntryOptions, isRouterV5, isSSGEntry, isUseSSRBundle, logger } from "@modern-js/utils";
|
|
6
|
-
import { filterRoutesForServer, filterRoutesLoader, markRoutes } from "@modern-js/utils";
|
|
5
|
+
import { fs, filterRoutesForServer, filterRoutesLoader, getEntryOptions, isRouterV5, isSSGEntry, isUseSSRBundle, logger } from "@modern-js/utils";
|
|
7
6
|
import { cloneDeep } from "@modern-js/utils/lodash";
|
|
8
7
|
import { ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME } from "../../../cli/constants";
|
|
9
8
|
import { FILE_SYSTEM_ROUTES_FILE_NAME } from "../constants";
|
|
@@ -241,6 +240,25 @@ var generateCode = function() {
|
|
|
241
240
|
return _ref.apply(this, arguments);
|
|
242
241
|
};
|
|
243
242
|
}();
|
|
243
|
+
function markRoutes(routes, routeIds) {
|
|
244
|
+
return routes.map(function(route) {
|
|
245
|
+
if (route.type !== "nested") {
|
|
246
|
+
return route;
|
|
247
|
+
}
|
|
248
|
+
if (route.children && route.children.length > 0) {
|
|
249
|
+
route.children = markRoutes(route.children, routeIds);
|
|
250
|
+
}
|
|
251
|
+
if (route.children && route.children.length > 0) {
|
|
252
|
+
route.inValidSSRRoute = route.children.every(function(child) {
|
|
253
|
+
var _child_inValidSSRRoute;
|
|
254
|
+
return (_child_inValidSSRRoute = child.inValidSSRRoute) !== null && _child_inValidSSRRoute !== void 0 ? _child_inValidSSRRoute : false;
|
|
255
|
+
});
|
|
256
|
+
} else if (route.id) {
|
|
257
|
+
route.inValidSSRRoute = !routeIds.includes(route.id);
|
|
258
|
+
}
|
|
259
|
+
return route;
|
|
260
|
+
});
|
|
261
|
+
}
|
|
244
262
|
function generatorRegisterCode(internalDirectory, entryName, code) {
|
|
245
263
|
fs.outputFileSync(path.resolve(internalDirectory, "./".concat(entryName, "/").concat(ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME)), code, "utf8");
|
|
246
264
|
}
|
|
@@ -3,8 +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 { fs, NESTED_ROUTE_SPEC_FILE, createRuntimeExportsUtils, getEntryOptions, isRouterV5 as isV5 } from "@modern-js/utils";
|
|
7
|
-
import { filterRoutesForServer } from "@modern-js/utils";
|
|
6
|
+
import { fs, NESTED_ROUTE_SPEC_FILE, createRuntimeExportsUtils, filterRoutesForServer, getEntryOptions, isRouterV5 as isV5 } from "@modern-js/utils";
|
|
8
7
|
import { isRouteEntry } from "./entry";
|
|
9
8
|
import { handleFileChange, handleGeneratorEntryCode, handleModifyEntrypoints } from "./handler";
|
|
10
9
|
import { isRouteEntry as isRouteEntry2 } from "./entry";
|
|
@@ -124,7 +124,7 @@ var routerPlugin = function() {
|
|
|
124
124
|
return function(props) {
|
|
125
125
|
beforeCreateRouter = false;
|
|
126
126
|
var router = useCreateRouter(props);
|
|
127
|
-
|
|
127
|
+
return (
|
|
128
128
|
// To match the node tree about https://github.com/web-infra-dev/modern.js/blob/v2.59.0/packages/runtime/plugin-runtime/src/router/runtime/plugin.node.tsx#L150-L168
|
|
129
129
|
// According to react [useId generation algorithm](https://github.com/facebook/react/pull/22644), `useId` will generate id with the react node react struct.
|
|
130
130
|
// To void hydration failed, we must guarantee that the node tree when browser hydrate must have same struct with node tree when ssr render.
|
|
@@ -138,9 +138,6 @@ var routerPlugin = function() {
|
|
|
138
138
|
]
|
|
139
139
|
})
|
|
140
140
|
);
|
|
141
|
-
return App ? /* @__PURE__ */ _jsx(App, {
|
|
142
|
-
children: routerWrapper
|
|
143
|
-
}) : routerWrapper;
|
|
144
141
|
};
|
|
145
142
|
};
|
|
146
143
|
return getRouteApp();
|
|
@@ -116,7 +116,7 @@ var routerPlugin = function() {
|
|
|
116
116
|
var context = useContext(RuntimeReactContext);
|
|
117
117
|
var remixRouter = context.remixRouter, routerContext = context.routerContext, ssrContext = context.ssrContext;
|
|
118
118
|
var nonce = ssrContext.nonce, mode = ssrContext.mode;
|
|
119
|
-
|
|
119
|
+
return /* @__PURE__ */ _jsxs(_Fragment, {
|
|
120
120
|
children: [
|
|
121
121
|
/* @__PURE__ */ _jsx(StaticRouterProvider, {
|
|
122
122
|
router: remixRouter,
|
|
@@ -132,9 +132,6 @@ var routerPlugin = function() {
|
|
|
132
132
|
mode === "stream" && JSX_SHELL_STREAM_END_MARK
|
|
133
133
|
]
|
|
134
134
|
});
|
|
135
|
-
return App ? /* @__PURE__ */ _jsx(App, {
|
|
136
|
-
children: routerWrapper
|
|
137
|
-
}) : routerWrapper;
|
|
138
135
|
};
|
|
139
136
|
};
|
|
140
137
|
return getRouteApp();
|
|
@@ -86,10 +86,10 @@ const runtimePlugin = (params) => ({
|
|
|
86
86
|
* Compatible with the reference path of the old version of the plugin.
|
|
87
87
|
*/
|
|
88
88
|
[`@${metaName}/runtime/plugins`]: pluginsExportsUtils.getPath(),
|
|
89
|
-
"@meta/runtime/browser
|
|
90
|
-
"@meta/runtime/react
|
|
91
|
-
"@meta/runtime/context
|
|
92
|
-
"@meta/runtime
|
|
89
|
+
"@meta/runtime/browser": "@modern-js/runtime/browser",
|
|
90
|
+
"@meta/runtime/react": "@modern-js/runtime/react",
|
|
91
|
+
"@meta/runtime/context": "@modern-js/runtime/context",
|
|
92
|
+
"@meta/runtime": "@modern-js/runtime"
|
|
93
93
|
},
|
|
94
94
|
globalVars: {
|
|
95
95
|
"process.env.IS_REACT18": process.env.IS_REACT18
|
|
@@ -150,6 +150,11 @@ const documentPlugin = () => ({
|
|
|
150
150
|
};
|
|
151
151
|
return {
|
|
152
152
|
config: () => {
|
|
153
|
+
var _userConfig_tools;
|
|
154
|
+
const userConfig = api.useConfigContext();
|
|
155
|
+
if (((_userConfig_tools = userConfig.tools) === null || _userConfig_tools === void 0 ? void 0 : _userConfig_tools.htmlPlugin) === false) {
|
|
156
|
+
return {};
|
|
157
|
+
}
|
|
153
158
|
return {
|
|
154
159
|
tools: {
|
|
155
160
|
htmlPlugin: (options, entry) => {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import { fs, getEntryOptions, isRouterV5, isSSGEntry, isUseSSRBundle, logger } from "@modern-js/utils";
|
|
3
|
-
import { filterRoutesForServer, filterRoutesLoader, markRoutes } from "@modern-js/utils";
|
|
2
|
+
import { fs, filterRoutesForServer, filterRoutesLoader, getEntryOptions, isRouterV5, isSSGEntry, isUseSSRBundle, logger } from "@modern-js/utils";
|
|
4
3
|
import { cloneDeep } from "@modern-js/utils/lodash";
|
|
5
4
|
import { ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME } from "../../../cli/constants";
|
|
6
5
|
import { FILE_SYSTEM_ROUTES_FILE_NAME } from "../constants";
|
|
@@ -112,6 +111,25 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
112
111
|
}
|
|
113
112
|
}
|
|
114
113
|
};
|
|
114
|
+
function markRoutes(routes, routeIds) {
|
|
115
|
+
return routes.map((route) => {
|
|
116
|
+
if (route.type !== "nested") {
|
|
117
|
+
return route;
|
|
118
|
+
}
|
|
119
|
+
if (route.children && route.children.length > 0) {
|
|
120
|
+
route.children = markRoutes(route.children, routeIds);
|
|
121
|
+
}
|
|
122
|
+
if (route.children && route.children.length > 0) {
|
|
123
|
+
route.inValidSSRRoute = route.children.every((child) => {
|
|
124
|
+
var _child_inValidSSRRoute;
|
|
125
|
+
return (_child_inValidSSRRoute = child.inValidSSRRoute) !== null && _child_inValidSSRRoute !== void 0 ? _child_inValidSSRRoute : false;
|
|
126
|
+
});
|
|
127
|
+
} else if (route.id) {
|
|
128
|
+
route.inValidSSRRoute = !routeIds.includes(route.id);
|
|
129
|
+
}
|
|
130
|
+
return route;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
115
133
|
function generatorRegisterCode(internalDirectory, entryName, code) {
|
|
116
134
|
fs.outputFileSync(path.resolve(internalDirectory, `./${entryName}/${ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME}`), code, "utf8");
|
|
117
135
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { fs, NESTED_ROUTE_SPEC_FILE, createRuntimeExportsUtils, getEntryOptions, isRouterV5 as isV5 } from "@modern-js/utils";
|
|
3
|
-
import { filterRoutesForServer } from "@modern-js/utils";
|
|
2
|
+
import { fs, NESTED_ROUTE_SPEC_FILE, createRuntimeExportsUtils, filterRoutesForServer, getEntryOptions, isRouterV5 as isV5 } from "@modern-js/utils";
|
|
4
3
|
import { isRouteEntry } from "./entry";
|
|
5
4
|
import { handleFileChange, handleGeneratorEntryCode, handleModifyEntrypoints } from "./handler";
|
|
6
5
|
import { isRouteEntry as isRouteEntry2 } from "./entry";
|
|
@@ -113,7 +113,7 @@ const routerPlugin = (userConfig = {}) => {
|
|
|
113
113
|
return (props) => {
|
|
114
114
|
beforeCreateRouter = false;
|
|
115
115
|
const router = useCreateRouter(props);
|
|
116
|
-
|
|
116
|
+
return (
|
|
117
117
|
// To match the node tree about https://github.com/web-infra-dev/modern.js/blob/v2.59.0/packages/runtime/plugin-runtime/src/router/runtime/plugin.node.tsx#L150-L168
|
|
118
118
|
// According to react [useId generation algorithm](https://github.com/facebook/react/pull/22644), `useId` will generate id with the react node react struct.
|
|
119
119
|
// To void hydration failed, we must guarantee that the node tree when browser hydrate must have same struct with node tree when ssr render.
|
|
@@ -127,9 +127,6 @@ const routerPlugin = (userConfig = {}) => {
|
|
|
127
127
|
]
|
|
128
128
|
})
|
|
129
129
|
);
|
|
130
|
-
return App ? /* @__PURE__ */ _jsx(App, {
|
|
131
|
-
children: routerWrapper
|
|
132
|
-
}) : routerWrapper;
|
|
133
130
|
};
|
|
134
131
|
};
|
|
135
132
|
return getRouteApp();
|
|
@@ -91,7 +91,7 @@ const routerPlugin = (userConfig = {}) => {
|
|
|
91
91
|
const context = useContext(RuntimeReactContext);
|
|
92
92
|
const { remixRouter, routerContext, ssrContext } = context;
|
|
93
93
|
const { nonce, mode } = ssrContext;
|
|
94
|
-
|
|
94
|
+
return /* @__PURE__ */ _jsxs(_Fragment, {
|
|
95
95
|
children: [
|
|
96
96
|
/* @__PURE__ */ _jsx(StaticRouterProvider, {
|
|
97
97
|
router: remixRouter,
|
|
@@ -107,9 +107,6 @@ const routerPlugin = (userConfig = {}) => {
|
|
|
107
107
|
mode === "stream" && JSX_SHELL_STREAM_END_MARK
|
|
108
108
|
]
|
|
109
109
|
});
|
|
110
|
-
return App ? /* @__PURE__ */ _jsx(App, {
|
|
111
|
-
children: routerWrapper
|
|
112
|
-
}) : routerWrapper;
|
|
113
110
|
};
|
|
114
111
|
};
|
|
115
112
|
return getRouteApp();
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.60.1
|
|
18
|
+
"version": "2.60.1",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=14.17.6"
|
|
21
21
|
},
|
|
@@ -199,11 +199,11 @@
|
|
|
199
199
|
"react-is": "^18",
|
|
200
200
|
"react-side-effect": "^2.1.1",
|
|
201
201
|
"styled-components": "^5.3.1",
|
|
202
|
-
"@modern-js/plugin": "2.60.
|
|
203
|
-
"@modern-js/
|
|
204
|
-
"@modern-js/utils": "2.60.
|
|
205
|
-
"@modern-js/types": "2.60.
|
|
206
|
-
"@modern-js/
|
|
202
|
+
"@modern-js/plugin-data-loader": "2.60.1",
|
|
203
|
+
"@modern-js/plugin": "2.60.1",
|
|
204
|
+
"@modern-js/runtime-utils": "2.60.1",
|
|
205
|
+
"@modern-js/types": "2.60.1",
|
|
206
|
+
"@modern-js/utils": "2.60.1"
|
|
207
207
|
},
|
|
208
208
|
"peerDependencies": {
|
|
209
209
|
"react": ">=17",
|
|
@@ -226,10 +226,10 @@
|
|
|
226
226
|
"ts-jest": "^29.1.0",
|
|
227
227
|
"typescript": "^5",
|
|
228
228
|
"webpack": "^5.94.0",
|
|
229
|
-
"@modern-js/app-tools": "2.60.
|
|
230
|
-
"@
|
|
231
|
-
"@
|
|
232
|
-
"@scripts/
|
|
229
|
+
"@modern-js/app-tools": "2.60.1",
|
|
230
|
+
"@scripts/jest-config": "2.60.1",
|
|
231
|
+
"@modern-js/core": "2.60.1",
|
|
232
|
+
"@scripts/build": "2.60.1"
|
|
233
233
|
},
|
|
234
234
|
"sideEffects": false,
|
|
235
235
|
"publishConfig": {
|