@modern-js/runtime 2.60.1-alpha.1 → 2.60.1-alpha.2
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/core/server/react/nossr/index.js +5 -6
- package/dist/cjs/router/cli/code/index.js +4 -22
- package/dist/cjs/router/cli/index.js +2 -1
- package/dist/cjs/router/runtime/plugin.js +4 -1
- package/dist/cjs/router/runtime/plugin.node.js +4 -1
- package/dist/esm/cli/index.js +1 -1
- package/dist/esm/core/server/react/nossr/index.js +5 -6
- package/dist/esm/router/cli/code/index.js +2 -20
- package/dist/esm/router/cli/index.js +2 -1
- package/dist/esm/router/runtime/plugin.js +4 -1
- package/dist/esm/router/runtime/plugin.node.js +4 -1
- package/dist/esm-node/cli/index.js +4 -4
- package/dist/esm-node/core/server/react/nossr/index.js +5 -6
- package/dist/esm-node/router/cli/code/index.js +2 -20
- package/dist/esm-node/router/cli/index.js +2 -1
- package/dist/esm-node/router/runtime/plugin.js +4 -1
- package/dist/esm-node/router/runtime/plugin.node.js +4 -1
- package/dist/types/core/server/react/nossr/index.d.ts +4 -5
- package/package.json +7 -6
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": "@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"
|
|
128
|
+
"@meta/runtime/browser": require.resolve("@modern-js/runtime/browser"),
|
|
129
|
+
"@meta/runtime/react": require.resolve("@modern-js/runtime/react"),
|
|
130
|
+
"@meta/runtime/context": require.resolve("@modern-js/runtime/context"),
|
|
131
|
+
"@meta/runtime": require.resolve("@modern-js/runtime")
|
|
132
132
|
},
|
|
133
133
|
globalVars: {
|
|
134
134
|
"process.env.IS_REACT18": process.env.IS_REACT18
|
|
@@ -32,14 +32,13 @@ __export(nossr_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(nossr_exports);
|
|
34
34
|
var import_react = __toESM(require("react"));
|
|
35
|
-
|
|
35
|
+
var import_react2 = require("react");
|
|
36
36
|
const NoSSR = (props) => {
|
|
37
|
-
const [isMounted, setMounted] = (0,
|
|
38
|
-
(0,
|
|
39
|
-
csr = true;
|
|
37
|
+
const [isMounted, setMounted] = (0, import_react2.useState)(false);
|
|
38
|
+
(0, import_react2.useEffect)(() => {
|
|
40
39
|
setMounted(true);
|
|
41
|
-
});
|
|
42
|
-
const { children, fallback = null } = props;
|
|
40
|
+
}, []);
|
|
41
|
+
const { children, fallback = null } = props || {};
|
|
43
42
|
return import_react.default.createElement(import_react.default.Fragment, null, isMounted ? children : fallback);
|
|
44
43
|
};
|
|
45
44
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -35,6 +35,7 @@ module.exports = __toCommonJS(code_exports);
|
|
|
35
35
|
var import_path = __toESM(require("path"));
|
|
36
36
|
var import_utils = require("@modern-js/utils");
|
|
37
37
|
var import_lodash = require("@modern-js/utils/lodash");
|
|
38
|
+
var import_route = require("@modern-js/utils/universal/route");
|
|
38
39
|
var import_constants = require("../../../cli/constants");
|
|
39
40
|
var import_constants2 = require("../constants");
|
|
40
41
|
var import_getClientRoutes = require("./getClientRoutes");
|
|
@@ -84,7 +85,7 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
84
85
|
const config2 = api.useResolvedConfigContext();
|
|
85
86
|
const ssrByRouteIds = config2.server.ssrByRouteIds || [];
|
|
86
87
|
const clonedRoutes = (0, import_lodash.cloneDeep)(initialRoutes);
|
|
87
|
-
const markedRoutes = ssrByRouteIds.length > 0 ? markRoutes(clonedRoutes, ssrByRouteIds) : initialRoutes;
|
|
88
|
+
const markedRoutes = ssrByRouteIds.length > 0 ? (0, import_route.markRoutes)(clonedRoutes, ssrByRouteIds) : initialRoutes;
|
|
88
89
|
const { routes } = await hookRunners.modifyFileSystemRoutes({
|
|
89
90
|
entrypoint,
|
|
90
91
|
routes: markedRoutes
|
|
@@ -117,8 +118,8 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
117
118
|
if (entrypoint.nestedRoutesEntry && (0, import_utils.isUseSSRBundle)(config2)) {
|
|
118
119
|
var _config_output1;
|
|
119
120
|
const routesServerFile = (0, import_utils2.getServerLoadersFile)(internalDirectory, entryName);
|
|
120
|
-
const filtedRoutesForServer = (0,
|
|
121
|
-
const routesForServerLoaderMatches = (0,
|
|
121
|
+
const filtedRoutesForServer = (0, import_route.filterRoutesForServer)(routes);
|
|
122
|
+
const routesForServerLoaderMatches = (0, import_route.filterRoutesLoader)(routes);
|
|
122
123
|
const code2 = templates.routesForServer({
|
|
123
124
|
routesForServerLoaderMatches
|
|
124
125
|
});
|
|
@@ -145,25 +146,6 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
148
|
};
|
|
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
|
-
}
|
|
167
149
|
function generatorRegisterCode(internalDirectory, entryName, code) {
|
|
168
150
|
import_utils.fs.outputFileSync(import_path.default.resolve(internalDirectory, `./${entryName}/${import_constants.ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME}`), code, "utf8");
|
|
169
151
|
}
|
|
@@ -37,6 +37,7 @@ __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_route = require("@modern-js/utils/universal/route");
|
|
40
41
|
var import_entry = require("./entry");
|
|
41
42
|
var import_handler = require("./handler");
|
|
42
43
|
var import_entry2 = require("./entry");
|
|
@@ -115,7 +116,7 @@ const routerPlugin = () => ({
|
|
|
115
116
|
},
|
|
116
117
|
async modifyFileSystemRoutes({ entrypoint, routes }) {
|
|
117
118
|
nestedRoutes[entrypoint.entryName] = routes;
|
|
118
|
-
nestedRoutesForServer[entrypoint.entryName] = (0,
|
|
119
|
+
nestedRoutesForServer[entrypoint.entryName] = (0, import_route.filterRoutesForServer)(routes);
|
|
119
120
|
return {
|
|
120
121
|
entrypoint,
|
|
121
122
|
routes
|
|
@@ -139,7 +139,7 @@ const routerPlugin = (userConfig = {}) => {
|
|
|
139
139
|
return (props) => {
|
|
140
140
|
beforeCreateRouter = false;
|
|
141
141
|
const router = useCreateRouter(props);
|
|
142
|
-
|
|
142
|
+
const routerWrapper = (
|
|
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,6 +153,9 @@ const routerPlugin = (userConfig = {}) => {
|
|
|
153
153
|
]
|
|
154
154
|
})
|
|
155
155
|
);
|
|
156
|
+
return App ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, {
|
|
157
|
+
children: routerWrapper
|
|
158
|
+
}) : routerWrapper;
|
|
156
159
|
};
|
|
157
160
|
};
|
|
158
161
|
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
|
+
const routerWrapper = /* @__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,6 +141,9 @@ 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;
|
|
144
147
|
};
|
|
145
148
|
};
|
|
146
149
|
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", "@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),
|
|
112
|
+
_define_property(_obj, "@".concat(metaName, "/runtime/plugins"), pluginsExportsUtils.getPath()), _define_property(_obj, "@meta/runtime/browser", require.resolve("@modern-js/runtime/browser")), _define_property(_obj, "@meta/runtime/react", require.resolve("@modern-js/runtime/react")), _define_property(_obj, "@meta/runtime/context", require.resolve("@modern-js/runtime/context")), _define_property(_obj, "@meta/runtime", require.resolve("@modern-js/runtime")), _obj),
|
|
113
113
|
globalVars: {
|
|
114
114
|
"process.env.IS_REACT18": process.env.IS_REACT18
|
|
115
115
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
2
|
-
import React
|
|
3
|
-
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
4
|
var NoSSR = function(props) {
|
|
5
|
-
var _useState = _sliced_to_array(useState(
|
|
5
|
+
var _useState = _sliced_to_array(useState(false), 2), isMounted = _useState[0], setMounted = _useState[1];
|
|
6
6
|
useEffect(function() {
|
|
7
|
-
csr = true;
|
|
8
7
|
setMounted(true);
|
|
9
|
-
});
|
|
10
|
-
var children =
|
|
8
|
+
}, []);
|
|
9
|
+
var _ref = props || {}, children = _ref.children, _ref_fallback = _ref.fallback, fallback = _ref_fallback === void 0 ? null : _ref_fallback;
|
|
11
10
|
return React.createElement(React.Fragment, null, isMounted ? children : fallback);
|
|
12
11
|
};
|
|
13
12
|
export {
|
|
@@ -2,8 +2,9 @@ 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,
|
|
5
|
+
import { fs, getEntryOptions, isRouterV5, isSSGEntry, isUseSSRBundle, logger } from "@modern-js/utils";
|
|
6
6
|
import { cloneDeep } from "@modern-js/utils/lodash";
|
|
7
|
+
import { filterRoutesForServer, filterRoutesLoader, markRoutes } from "@modern-js/utils/universal/route";
|
|
7
8
|
import { ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME } from "../../../cli/constants";
|
|
8
9
|
import { FILE_SYSTEM_ROUTES_FILE_NAME } from "../constants";
|
|
9
10
|
import { getClientRoutes, getClientRoutesLegacy } from "./getClientRoutes";
|
|
@@ -240,25 +241,6 @@ var generateCode = function() {
|
|
|
240
241
|
return _ref.apply(this, arguments);
|
|
241
242
|
};
|
|
242
243
|
}();
|
|
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
|
-
}
|
|
262
244
|
function generatorRegisterCode(internalDirectory, entryName, code) {
|
|
263
245
|
fs.outputFileSync(path.resolve(internalDirectory, "./".concat(entryName, "/").concat(ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME)), code, "utf8");
|
|
264
246
|
}
|
|
@@ -3,7 +3,8 @@ 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,
|
|
6
|
+
import { fs, NESTED_ROUTE_SPEC_FILE, createRuntimeExportsUtils, getEntryOptions, isRouterV5 as isV5 } from "@modern-js/utils";
|
|
7
|
+
import { filterRoutesForServer } from "@modern-js/utils/universal/route";
|
|
7
8
|
import { isRouteEntry } from "./entry";
|
|
8
9
|
import { handleFileChange, handleGeneratorEntryCode, handleModifyEntrypoints } from "./handler";
|
|
9
10
|
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
|
+
var routerWrapper = (
|
|
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,6 +138,9 @@ var routerPlugin = function() {
|
|
|
138
138
|
]
|
|
139
139
|
})
|
|
140
140
|
);
|
|
141
|
+
return App ? /* @__PURE__ */ _jsx(App, {
|
|
142
|
+
children: routerWrapper
|
|
143
|
+
}) : routerWrapper;
|
|
141
144
|
};
|
|
142
145
|
};
|
|
143
146
|
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
|
+
var routerWrapper = /* @__PURE__ */ _jsxs(_Fragment, {
|
|
120
120
|
children: [
|
|
121
121
|
/* @__PURE__ */ _jsx(StaticRouterProvider, {
|
|
122
122
|
router: remixRouter,
|
|
@@ -132,6 +132,9 @@ 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;
|
|
135
138
|
};
|
|
136
139
|
};
|
|
137
140
|
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": "@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"
|
|
89
|
+
"@meta/runtime/browser": require.resolve("@modern-js/runtime/browser"),
|
|
90
|
+
"@meta/runtime/react": require.resolve("@modern-js/runtime/react"),
|
|
91
|
+
"@meta/runtime/context": require.resolve("@modern-js/runtime/context"),
|
|
92
|
+
"@meta/runtime": require.resolve("@modern-js/runtime")
|
|
93
93
|
},
|
|
94
94
|
globalVars: {
|
|
95
95
|
"process.env.IS_REACT18": process.env.IS_REACT18
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import React
|
|
2
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
3
|
const NoSSR = (props) => {
|
|
4
|
-
const [isMounted, setMounted] = useState(
|
|
4
|
+
const [isMounted, setMounted] = useState(false);
|
|
5
5
|
useEffect(() => {
|
|
6
|
-
csr = true;
|
|
7
6
|
setMounted(true);
|
|
8
|
-
});
|
|
9
|
-
const { children, fallback = null } = props;
|
|
7
|
+
}, []);
|
|
8
|
+
const { children, fallback = null } = props || {};
|
|
10
9
|
return React.createElement(React.Fragment, null, isMounted ? children : fallback);
|
|
11
10
|
};
|
|
12
11
|
export {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import { fs,
|
|
2
|
+
import { fs, getEntryOptions, isRouterV5, isSSGEntry, isUseSSRBundle, logger } from "@modern-js/utils";
|
|
3
3
|
import { cloneDeep } from "@modern-js/utils/lodash";
|
|
4
|
+
import { filterRoutesForServer, filterRoutesLoader, markRoutes } from "@modern-js/utils/universal/route";
|
|
4
5
|
import { ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME } from "../../../cli/constants";
|
|
5
6
|
import { FILE_SYSTEM_ROUTES_FILE_NAME } from "../constants";
|
|
6
7
|
import { getClientRoutes, getClientRoutesLegacy } from "./getClientRoutes";
|
|
@@ -111,25 +112,6 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
114
|
};
|
|
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
|
-
}
|
|
133
115
|
function generatorRegisterCode(internalDirectory, entryName, code) {
|
|
134
116
|
fs.outputFileSync(path.resolve(internalDirectory, `./${entryName}/${ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME}`), code, "utf8");
|
|
135
117
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { fs, NESTED_ROUTE_SPEC_FILE, createRuntimeExportsUtils,
|
|
2
|
+
import { fs, NESTED_ROUTE_SPEC_FILE, createRuntimeExportsUtils, getEntryOptions, isRouterV5 as isV5 } from "@modern-js/utils";
|
|
3
|
+
import { filterRoutesForServer } from "@modern-js/utils/universal/route";
|
|
3
4
|
import { isRouteEntry } from "./entry";
|
|
4
5
|
import { handleFileChange, handleGeneratorEntryCode, handleModifyEntrypoints } from "./handler";
|
|
5
6
|
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
|
+
const routerWrapper = (
|
|
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,6 +127,9 @@ const routerPlugin = (userConfig = {}) => {
|
|
|
127
127
|
]
|
|
128
128
|
})
|
|
129
129
|
);
|
|
130
|
+
return App ? /* @__PURE__ */ _jsx(App, {
|
|
131
|
+
children: routerWrapper
|
|
132
|
+
}) : routerWrapper;
|
|
130
133
|
};
|
|
131
134
|
};
|
|
132
135
|
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
|
+
const routerWrapper = /* @__PURE__ */ _jsxs(_Fragment, {
|
|
95
95
|
children: [
|
|
96
96
|
/* @__PURE__ */ _jsx(StaticRouterProvider, {
|
|
97
97
|
router: remixRouter,
|
|
@@ -107,6 +107,9 @@ 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;
|
|
110
113
|
};
|
|
111
114
|
};
|
|
112
115
|
return getRouteApp();
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import React
|
|
2
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ReactElement } from 'react';
|
|
3
|
+
export declare const NoSSR: (props?: React.PropsWithChildren<{
|
|
3
4
|
fallback?: ReactElement | string;
|
|
4
|
-
}>) =>
|
|
5
|
-
children?: React.ReactNode;
|
|
6
|
-
}>;
|
|
5
|
+
}>) => ReactElement | null;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.60.1-alpha.
|
|
18
|
+
"version": "2.60.1-alpha.2",
|
|
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.0",
|
|
202
203
|
"@modern-js/runtime-utils": "2.60.0",
|
|
203
204
|
"@modern-js/types": "2.60.0",
|
|
204
|
-
"@modern-js/utils": "2.60.0",
|
|
205
205
|
"@modern-js/plugin-data-loader": "2.60.0",
|
|
206
|
-
"@modern-js/
|
|
206
|
+
"@modern-js/utils": "2.60.0"
|
|
207
207
|
},
|
|
208
208
|
"peerDependencies": {
|
|
209
209
|
"react": ">=17",
|
|
@@ -226,15 +226,16 @@
|
|
|
226
226
|
"ts-jest": "^29.1.0",
|
|
227
227
|
"typescript": "^5",
|
|
228
228
|
"webpack": "^5.94.0",
|
|
229
|
-
"@scripts/build": "2.60.0",
|
|
230
229
|
"@modern-js/app-tools": "2.60.0",
|
|
231
230
|
"@scripts/jest-config": "2.60.0",
|
|
232
|
-
"@modern-js/core": "2.60.0"
|
|
231
|
+
"@modern-js/core": "2.60.0",
|
|
232
|
+
"@scripts/build": "2.60.0"
|
|
233
233
|
},
|
|
234
234
|
"sideEffects": false,
|
|
235
235
|
"publishConfig": {
|
|
236
236
|
"registry": "https://registry.npmjs.org/",
|
|
237
|
-
"access": "public"
|
|
237
|
+
"access": "public",
|
|
238
|
+
"provenance": true
|
|
238
239
|
},
|
|
239
240
|
"scripts": {
|
|
240
241
|
"dev": "modern-lib build --watch",
|