@modern-js/runtime 2.11.0 → 2.13.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 +33 -0
- package/dist/cjs/core/compatible.js +6 -2
- package/dist/cjs/router/cli/index.js +8 -0
- package/dist/cjs/router/runtime/PrefetchLink.js +8 -7
- package/dist/cjs/router/runtime/index.js +2 -6
- package/dist/cjs/router/runtime/plugin.js +1 -1
- package/dist/cjs/ssr/cli/index.js +14 -9
- package/dist/esm/core/compatible.js +3 -2
- package/dist/esm/router/cli/index.js +8 -0
- package/dist/esm/router/runtime/PrefetchLink.js +5 -4
- package/dist/esm/router/runtime/index.js +3 -3
- package/dist/esm/router/runtime/plugin.js +1 -1
- package/dist/esm/ssr/cli/index.js +11 -7
- package/dist/esm-node/core/compatible.js +6 -2
- package/dist/esm-node/router/cli/index.js +8 -0
- package/dist/esm-node/router/runtime/PrefetchLink.js +6 -5
- package/dist/esm-node/router/runtime/index.js +1 -5
- package/dist/esm-node/router/runtime/plugin.js +1 -1
- package/dist/esm-node/ssr/cli/index.js +14 -9
- package/dist/types/core/compatible.d.ts +3 -1
- package/dist/types/router/runtime/PrefetchLink.d.ts +5 -5
- package/dist/types/router/runtime/index.d.ts +4 -4
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @modern-js/runtime
|
|
2
2
|
|
|
3
|
+
## 2.13.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- cad9676: fix(runtime): compile react-router to ensure the compatibility
|
|
8
|
+
|
|
9
|
+
fix(runtime): 通过编译 react-router 来保证对低版本浏览器的兼容性
|
|
10
|
+
|
|
11
|
+
- e9b1656: fix: plugin config hook can not get bundlerType, so we can't set babelConfig correctly in ssr plugin
|
|
12
|
+
fix: 插件的 config 钩子不能获得 bundlerType,所以我们在 ssr 插件不能正确的设置 babelConfig
|
|
13
|
+
- 4d413c4: docs: add prefetch docs
|
|
14
|
+
docs: 添加 prefetch 的文档
|
|
15
|
+
- 4220c0e: feat: support global props in createApp and pass garfish props in
|
|
16
|
+
feat: createApp 支持全局属性,garfish 通过这个方式透传 garfish props
|
|
17
|
+
- Updated dependencies [78431f4]
|
|
18
|
+
- @modern-js/plugin@2.13.0
|
|
19
|
+
- @modern-js/types@2.13.0
|
|
20
|
+
- @modern-js/utils@2.13.0
|
|
21
|
+
|
|
22
|
+
## 2.12.0
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- 0b05ec3: fix: the SSR plugin will product some effects, disable the ssr plugin when user doesn't use ssr
|
|
27
|
+
fix: SSR 插件将会尝试一些副作用,如果用户没有使用它时禁用这个插件。
|
|
28
|
+
- 1aa0cb7: fix: beforeCreateRouter should be false after render router
|
|
29
|
+
fix: 在渲染 router 后,beforeCreateRouter 应该为 false
|
|
30
|
+
- Updated dependencies [c2ca6c8]
|
|
31
|
+
- Updated dependencies [6d86e34]
|
|
32
|
+
- @modern-js/utils@2.12.0
|
|
33
|
+
- @modern-js/plugin@2.12.0
|
|
34
|
+
- @modern-js/types@2.12.0
|
|
35
|
+
|
|
3
36
|
## 2.11.0
|
|
4
37
|
|
|
5
38
|
### Patch Changes
|
|
@@ -50,7 +50,10 @@ const getInitialContext = (runner) => ({
|
|
|
50
50
|
isBrowser: true,
|
|
51
51
|
routeManifest: typeof window !== "undefined" && window[import_constants.ROUTE_MANIFEST]
|
|
52
52
|
});
|
|
53
|
-
const createApp = ({
|
|
53
|
+
const createApp = ({
|
|
54
|
+
plugins,
|
|
55
|
+
props: globalProps
|
|
56
|
+
}) => {
|
|
54
57
|
const appRuntime = import_plugin.runtime.clone();
|
|
55
58
|
appRuntime.usePlugin(...plugins);
|
|
56
59
|
return (App) => {
|
|
@@ -94,7 +97,8 @@ const createApp = ({ plugins }) => {
|
|
|
94
97
|
}
|
|
95
98
|
);
|
|
96
99
|
}
|
|
97
|
-
|
|
100
|
+
const mergedProps = { ...props, ...globalProps };
|
|
101
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_runtimeContext.RuntimeReactContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App2, { ...mergedProps }) });
|
|
98
102
|
};
|
|
99
103
|
return (0, import_hoist_non_react_statics.default)(WrapComponent, App2);
|
|
100
104
|
}
|
|
@@ -38,6 +38,14 @@ var cli_default = () => ({
|
|
|
38
38
|
);
|
|
39
39
|
return {
|
|
40
40
|
source: {
|
|
41
|
+
include: [
|
|
42
|
+
// react-router v6 is no longer support ie 11
|
|
43
|
+
// so we need to compile these packages to ensure the compatibility
|
|
44
|
+
// https://github.com/remix-run/react-router/commit/f6df0697e1b2064a2b3a12e8b39577326fdd945b
|
|
45
|
+
/node_modules\/react-router/,
|
|
46
|
+
/node_modules\/react-router-dom/,
|
|
47
|
+
/node_modules\/@remix-run\/router/
|
|
48
|
+
],
|
|
41
49
|
alias: {
|
|
42
50
|
"@modern-js/runtime/plugins": pluginsExportsUtils.getPath()
|
|
43
51
|
}
|
|
@@ -27,8 +27,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
var PrefetchLink_exports = {};
|
|
29
29
|
__export(PrefetchLink_exports, {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
Link: () => Link,
|
|
31
|
+
NavLink: () => NavLink,
|
|
32
32
|
composeEventHandlers: () => composeEventHandlers
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(PrefetchLink_exports);
|
|
@@ -150,9 +150,10 @@ const PrefetchDataLinks = ({ matches, pathname, routeManifest }) => {
|
|
|
150
150
|
const currentMatches = (0, import_react_router_dom.useMatches)();
|
|
151
151
|
const basename = (0, import_react_router_dom.useHref)("/");
|
|
152
152
|
const dataHrefs = (0, import_react.useMemo)(() => {
|
|
153
|
-
return matches == null ? void 0 : matches.filter(
|
|
154
|
-
(match
|
|
155
|
-
|
|
153
|
+
return matches == null ? void 0 : matches.filter((match, index) => {
|
|
154
|
+
if (!match.route.loader || typeof match.route.loader !== "function" || match.route.loader.length === 0) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
156
157
|
const currentMatch = currentMatches[index];
|
|
157
158
|
if (!currentMatch || currentMatch.id !== match.route.id) {
|
|
158
159
|
return true;
|
|
@@ -199,7 +200,7 @@ const NavLink = createPrefetchLink(import_react_router_dom.NavLink);
|
|
|
199
200
|
NavLink.displayName = "NavLink";
|
|
200
201
|
// Annotate the CommonJS export names for ESM import in node:
|
|
201
202
|
0 && (module.exports = {
|
|
202
|
-
|
|
203
|
-
|
|
203
|
+
Link,
|
|
204
|
+
NavLink,
|
|
204
205
|
composeEventHandlers
|
|
205
206
|
});
|
|
@@ -22,13 +22,11 @@ __export(runtime_exports, {
|
|
|
22
22
|
BrowserRouter: () => import_react_router_dom.BrowserRouter,
|
|
23
23
|
Form: () => import_react_router_dom.Form,
|
|
24
24
|
HashRouter: () => import_react_router_dom.HashRouter,
|
|
25
|
-
Link: () =>
|
|
25
|
+
Link: () => import_PrefetchLink.Link,
|
|
26
26
|
MemoryRouter: () => import_react_router_dom.MemoryRouter,
|
|
27
|
-
NavLink: () =>
|
|
27
|
+
NavLink: () => import_PrefetchLink.NavLink,
|
|
28
28
|
Navigate: () => import_react_router_dom.Navigate,
|
|
29
29
|
Outlet: () => import_react_router_dom.Outlet,
|
|
30
|
-
PrefetchLink: () => import_PrefetchLink.PrefetchLink,
|
|
31
|
-
PrefetchNavLink: () => import_PrefetchLink.PrefetchNavLink,
|
|
32
30
|
Route: () => import_react_router_dom.Route,
|
|
33
31
|
Router: () => import_react_router_dom.Router,
|
|
34
32
|
RouterProvider: () => import_react_router_dom.RouterProvider,
|
|
@@ -98,8 +96,6 @@ var runtime_default = import_plugin.routerPlugin;
|
|
|
98
96
|
NavLink,
|
|
99
97
|
Navigate,
|
|
100
98
|
Outlet,
|
|
101
|
-
PrefetchLink,
|
|
102
|
-
PrefetchNavLink,
|
|
103
99
|
Route,
|
|
104
100
|
Router,
|
|
105
101
|
RouterProvider,
|
|
@@ -85,7 +85,7 @@ const routerPlugin = ({
|
|
|
85
85
|
const getRouteApp = () => {
|
|
86
86
|
return (props) => {
|
|
87
87
|
var _a;
|
|
88
|
-
beforeCreateRouter =
|
|
88
|
+
beforeCreateRouter = false;
|
|
89
89
|
routes = createRoutes ? createRoutes() : (0, import_react_router_dom.createRoutesFromElements)(
|
|
90
90
|
(0, import_utils.renderRoutes)({
|
|
91
91
|
routesConfig: finalRouteConfig,
|
|
@@ -61,6 +61,19 @@ var cli_default = () => ({
|
|
|
61
61
|
appContext.internalDirectory,
|
|
62
62
|
"plugins"
|
|
63
63
|
);
|
|
64
|
+
const { bundlerType = "webpack" } = api.useAppContext();
|
|
65
|
+
const babelConfig = bundlerType === "webpack" ? (config) => {
|
|
66
|
+
var _a, _b;
|
|
67
|
+
(_a = config.plugins) == null ? void 0 : _a.push(
|
|
68
|
+
import_path.default.join(__dirname, "./babel-plugin-ssr-loader-id")
|
|
69
|
+
);
|
|
70
|
+
const userConfig = api.useResolvedConfigContext();
|
|
71
|
+
if ((0, import_utils.isUseSSRBundle)(userConfig) && hasStringSSREntry(userConfig)) {
|
|
72
|
+
(_b = config.plugins) == null ? void 0 : _b.push(
|
|
73
|
+
require.resolve("@loadable/babel-plugin")
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
} : void 0;
|
|
64
77
|
return {
|
|
65
78
|
source: {
|
|
66
79
|
alias: {
|
|
@@ -94,15 +107,7 @@ var cli_default = () => ({
|
|
|
94
107
|
];
|
|
95
108
|
});
|
|
96
109
|
},
|
|
97
|
-
babel:
|
|
98
|
-
config.plugins.push(
|
|
99
|
-
import_path.default.join(__dirname, "./babel-plugin-ssr-loader-id")
|
|
100
|
-
);
|
|
101
|
-
const userConfig = api.useResolvedConfigContext();
|
|
102
|
-
if ((0, import_utils.isUseSSRBundle)(userConfig) && hasStringSSREntry(userConfig)) {
|
|
103
|
-
config.plugins.push(require.resolve("@loadable/babel-plugin"));
|
|
104
|
-
}
|
|
105
|
-
}
|
|
110
|
+
babel: babelConfig
|
|
106
111
|
}
|
|
107
112
|
};
|
|
108
113
|
},
|
|
@@ -230,7 +230,7 @@ var getInitialContext = function(runner) {
|
|
|
230
230
|
};
|
|
231
231
|
};
|
|
232
232
|
var createApp = function(param) {
|
|
233
|
-
var plugins = param.plugins;
|
|
233
|
+
var plugins = param.plugins, globalProps = param.props;
|
|
234
234
|
var _appRuntime;
|
|
235
235
|
var appRuntime = runtime.clone();
|
|
236
236
|
(_appRuntime = appRuntime).usePlugin.apply(_appRuntime, _toConsumableArray(plugins));
|
|
@@ -276,9 +276,10 @@ var createApp = function(param) {
|
|
|
276
276
|
}
|
|
277
277
|
});
|
|
278
278
|
}
|
|
279
|
+
var mergedProps = _objectSpread({}, props, globalProps);
|
|
279
280
|
return /* @__PURE__ */ jsx(RuntimeReactContext.Provider, {
|
|
280
281
|
value: contextValue,
|
|
281
|
-
children: /* @__PURE__ */ jsx(App2, _objectSpread({},
|
|
282
|
+
children: /* @__PURE__ */ jsx(App2, _objectSpread({}, mergedProps))
|
|
282
283
|
});
|
|
283
284
|
};
|
|
284
285
|
return hoistNonReactStatics(WrapComponent, App2);
|
|
@@ -68,6 +68,14 @@ var cli_default = function() {
|
|
|
68
68
|
pluginsExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, "plugins");
|
|
69
69
|
return {
|
|
70
70
|
source: {
|
|
71
|
+
include: [
|
|
72
|
+
// react-router v6 is no longer support ie 11
|
|
73
|
+
// so we need to compile these packages to ensure the compatibility
|
|
74
|
+
// https://github.com/remix-run/react-router/commit/f6df0697e1b2064a2b3a12e8b39577326fdd945b
|
|
75
|
+
/node_modules\/react-router/,
|
|
76
|
+
/node_modules\/react-router-dom/,
|
|
77
|
+
/node_modules\/@remix-run\/router/
|
|
78
|
+
],
|
|
71
79
|
alias: {
|
|
72
80
|
"@modern-js/runtime/plugins": pluginsExportsUtils.getPath()
|
|
73
81
|
}
|
|
@@ -390,9 +390,10 @@ var PrefetchDataLinks = function(param) {
|
|
|
390
390
|
var currentMatches = useMatches();
|
|
391
391
|
var basename = useHref("/");
|
|
392
392
|
var dataHrefs = useMemo(function() {
|
|
393
|
-
return matches === null || matches === void 0 ? void 0 : matches.filter(function(match) {
|
|
394
|
-
|
|
395
|
-
|
|
393
|
+
return matches === null || matches === void 0 ? void 0 : matches.filter(function(match, index) {
|
|
394
|
+
if (!match.route.loader || typeof match.route.loader !== "function" || match.route.loader.length === 0) {
|
|
395
|
+
return false;
|
|
396
|
+
}
|
|
396
397
|
var currentMatch = currentMatches[index];
|
|
397
398
|
if (!currentMatch || currentMatch.id !== match.route.id) {
|
|
398
399
|
return true;
|
|
@@ -443,4 +444,4 @@ var Link = createPrefetchLink(RouterLink);
|
|
|
443
444
|
Link.displayName = "Link";
|
|
444
445
|
var NavLink = createPrefetchLink(RouterNavLink);
|
|
445
446
|
NavLink.displayName = "NavLink";
|
|
446
|
-
export { Link
|
|
447
|
+
export { Link, NavLink, composeEventHandlers };
|
|
@@ -2,7 +2,7 @@ import { routerPlugin } from "./plugin";
|
|
|
2
2
|
var runtime_default = routerPlugin;
|
|
3
3
|
import { modifyRoutes } from "./plugin";
|
|
4
4
|
export * from "./withRouter";
|
|
5
|
-
import {
|
|
6
|
-
import { createBrowserRouter, createHashRouter, createMemoryRouter, RouterProvider, BrowserRouter, HashRouter, MemoryRouter, Router, Await, Form,
|
|
5
|
+
import { Link, NavLink } from "./PrefetchLink";
|
|
6
|
+
import { createBrowserRouter, createHashRouter, createMemoryRouter, RouterProvider, BrowserRouter, HashRouter, MemoryRouter, Router, Await, Form, Navigate, Outlet, Route, Routes, ScrollRestoration, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, createRoutesFromChildren, createRoutesFromElements, createSearchParams, generatePath, isRouteErrorResponse, matchPath, matchRoutes, renderMatches, resolvePath } from "react-router-dom";
|
|
7
7
|
import { defer, json, redirect } from "@modern-js/utils/universal/remix-router";
|
|
8
|
-
export { Await, BrowserRouter, Form, HashRouter, Link, MemoryRouter, NavLink, Navigate, Outlet,
|
|
8
|
+
export { Await, BrowserRouter, Form, HashRouter, Link, MemoryRouter, NavLink, Navigate, Outlet, Route, Router, RouterProvider, Routes, ScrollRestoration, createBrowserRouter, createHashRouter, createMemoryRouter, createRoutesFromChildren, createRoutesFromElements, createSearchParams, runtime_default as default, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, modifyRoutes, redirect, renderMatches, resolvePath, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit };
|
|
@@ -105,7 +105,7 @@ var routerPlugin = function(param) {
|
|
|
105
105
|
var getRouteApp = function() {
|
|
106
106
|
return function(props) {
|
|
107
107
|
var _window__SERVER_DATA;
|
|
108
|
-
beforeCreateRouter =
|
|
108
|
+
beforeCreateRouter = false;
|
|
109
109
|
routes = createRoutes ? createRoutes() : createRoutesFromElements(renderRoutes({
|
|
110
110
|
routesConfig: finalRouteConfig,
|
|
111
111
|
props: props
|
|
@@ -110,6 +110,16 @@ var cli_default = function() {
|
|
|
110
110
|
config: function config() {
|
|
111
111
|
var appContext = api.useAppContext();
|
|
112
112
|
pluginsExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, "plugins");
|
|
113
|
+
var _api_useAppContext = api.useAppContext(), _api_useAppContext_bundlerType = _api_useAppContext.bundlerType, bundlerType = _api_useAppContext_bundlerType === void 0 ? "webpack" : _api_useAppContext_bundlerType;
|
|
114
|
+
var babelConfig = bundlerType === "webpack" ? function(config) {
|
|
115
|
+
var _config_plugins;
|
|
116
|
+
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(path.join(__dirname, "./babel-plugin-ssr-loader-id"));
|
|
117
|
+
var userConfig = api.useResolvedConfigContext();
|
|
118
|
+
if (isUseSSRBundle(userConfig) && hasStringSSREntry(userConfig)) {
|
|
119
|
+
var _config_plugins1;
|
|
120
|
+
(_config_plugins1 = config.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
|
|
121
|
+
}
|
|
122
|
+
} : void 0;
|
|
113
123
|
return {
|
|
114
124
|
source: {
|
|
115
125
|
alias: {
|
|
@@ -138,13 +148,7 @@ var cli_default = function() {
|
|
|
138
148
|
].concat(_toConsumableArray(rest));
|
|
139
149
|
});
|
|
140
150
|
},
|
|
141
|
-
babel:
|
|
142
|
-
config.plugins.push(path.join(__dirname, "./babel-plugin-ssr-loader-id"));
|
|
143
|
-
var userConfig = api.useResolvedConfigContext();
|
|
144
|
-
if (isUseSSRBundle(userConfig) && hasStringSSREntry(userConfig)) {
|
|
145
|
-
config.plugins.push(require.resolve("@loadable/babel-plugin"));
|
|
146
|
-
}
|
|
147
|
-
}
|
|
151
|
+
babel: babelConfig
|
|
148
152
|
}
|
|
149
153
|
};
|
|
150
154
|
},
|
|
@@ -18,7 +18,10 @@ const getInitialContext = (runner) => ({
|
|
|
18
18
|
isBrowser: true,
|
|
19
19
|
routeManifest: typeof window !== "undefined" && window[ROUTE_MANIFEST]
|
|
20
20
|
});
|
|
21
|
-
const createApp = ({
|
|
21
|
+
const createApp = ({
|
|
22
|
+
plugins,
|
|
23
|
+
props: globalProps
|
|
24
|
+
}) => {
|
|
22
25
|
const appRuntime = runtime.clone();
|
|
23
26
|
appRuntime.usePlugin(...plugins);
|
|
24
27
|
return (App) => {
|
|
@@ -62,7 +65,8 @@ const createApp = ({ plugins }) => {
|
|
|
62
65
|
}
|
|
63
66
|
);
|
|
64
67
|
}
|
|
65
|
-
|
|
68
|
+
const mergedProps = { ...props, ...globalProps };
|
|
69
|
+
return /* @__PURE__ */ jsx(RuntimeReactContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(App2, { ...mergedProps }) });
|
|
66
70
|
};
|
|
67
71
|
return hoistNonReactStatics(WrapComponent, App2);
|
|
68
72
|
}
|
|
@@ -21,6 +21,14 @@ var cli_default = () => ({
|
|
|
21
21
|
);
|
|
22
22
|
return {
|
|
23
23
|
source: {
|
|
24
|
+
include: [
|
|
25
|
+
// react-router v6 is no longer support ie 11
|
|
26
|
+
// so we need to compile these packages to ensure the compatibility
|
|
27
|
+
// https://github.com/remix-run/react-router/commit/f6df0697e1b2064a2b3a12e8b39577326fdd945b
|
|
28
|
+
/node_modules\/react-router/,
|
|
29
|
+
/node_modules\/react-router-dom/,
|
|
30
|
+
/node_modules\/@remix-run\/router/
|
|
31
|
+
],
|
|
24
32
|
alias: {
|
|
25
33
|
"@modern-js/runtime/plugins": pluginsExportsUtils.getPath()
|
|
26
34
|
}
|
|
@@ -123,9 +123,10 @@ const PrefetchDataLinks = ({ matches, pathname, routeManifest }) => {
|
|
|
123
123
|
const currentMatches = useMatches();
|
|
124
124
|
const basename = useHref("/");
|
|
125
125
|
const dataHrefs = useMemo(() => {
|
|
126
|
-
return matches == null ? void 0 : matches.filter(
|
|
127
|
-
(match
|
|
128
|
-
|
|
126
|
+
return matches == null ? void 0 : matches.filter((match, index) => {
|
|
127
|
+
if (!match.route.loader || typeof match.route.loader !== "function" || match.route.loader.length === 0) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
129
130
|
const currentMatch = currentMatches[index];
|
|
130
131
|
if (!currentMatch || currentMatch.id !== match.route.id) {
|
|
131
132
|
return true;
|
|
@@ -171,7 +172,7 @@ Link.displayName = "Link";
|
|
|
171
172
|
const NavLink = createPrefetchLink(RouterNavLink);
|
|
172
173
|
NavLink.displayName = "NavLink";
|
|
173
174
|
export {
|
|
174
|
-
Link
|
|
175
|
-
NavLink
|
|
175
|
+
Link,
|
|
176
|
+
NavLink,
|
|
176
177
|
composeEventHandlers
|
|
177
178
|
};
|
|
@@ -2,7 +2,7 @@ import { routerPlugin } from "./plugin";
|
|
|
2
2
|
var runtime_default = routerPlugin;
|
|
3
3
|
import { modifyRoutes } from "./plugin";
|
|
4
4
|
export * from "./withRouter";
|
|
5
|
-
import {
|
|
5
|
+
import { Link, NavLink } from "./PrefetchLink";
|
|
6
6
|
import {
|
|
7
7
|
createBrowserRouter,
|
|
8
8
|
createHashRouter,
|
|
@@ -14,8 +14,6 @@ import {
|
|
|
14
14
|
Router,
|
|
15
15
|
Await,
|
|
16
16
|
Form,
|
|
17
|
-
Link,
|
|
18
|
-
NavLink,
|
|
19
17
|
Navigate,
|
|
20
18
|
Outlet,
|
|
21
19
|
Route,
|
|
@@ -69,8 +67,6 @@ export {
|
|
|
69
67
|
NavLink,
|
|
70
68
|
Navigate,
|
|
71
69
|
Outlet,
|
|
72
|
-
PrefetchLink,
|
|
73
|
-
PrefetchNavLink,
|
|
74
70
|
Route,
|
|
75
71
|
Router,
|
|
76
72
|
RouterProvider,
|
|
@@ -57,7 +57,7 @@ const routerPlugin = ({
|
|
|
57
57
|
const getRouteApp = () => {
|
|
58
58
|
return (props) => {
|
|
59
59
|
var _a;
|
|
60
|
-
beforeCreateRouter =
|
|
60
|
+
beforeCreateRouter = false;
|
|
61
61
|
routes = createRoutes ? createRoutes() : createRoutesFromElements(
|
|
62
62
|
renderRoutes({
|
|
63
63
|
routesConfig: finalRouteConfig,
|
|
@@ -36,6 +36,19 @@ var cli_default = () => ({
|
|
|
36
36
|
appContext.internalDirectory,
|
|
37
37
|
"plugins"
|
|
38
38
|
);
|
|
39
|
+
const { bundlerType = "webpack" } = api.useAppContext();
|
|
40
|
+
const babelConfig = bundlerType === "webpack" ? (config) => {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
(_a = config.plugins) == null ? void 0 : _a.push(
|
|
43
|
+
path.join(__dirname, "./babel-plugin-ssr-loader-id")
|
|
44
|
+
);
|
|
45
|
+
const userConfig = api.useResolvedConfigContext();
|
|
46
|
+
if (isUseSSRBundle(userConfig) && hasStringSSREntry(userConfig)) {
|
|
47
|
+
(_b = config.plugins) == null ? void 0 : _b.push(
|
|
48
|
+
require.resolve("@loadable/babel-plugin")
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
} : void 0;
|
|
39
52
|
return {
|
|
40
53
|
source: {
|
|
41
54
|
alias: {
|
|
@@ -69,15 +82,7 @@ var cli_default = () => ({
|
|
|
69
82
|
];
|
|
70
83
|
});
|
|
71
84
|
},
|
|
72
|
-
babel:
|
|
73
|
-
config.plugins.push(
|
|
74
|
-
path.join(__dirname, "./babel-plugin-ssr-loader-id")
|
|
75
|
-
);
|
|
76
|
-
const userConfig = api.useResolvedConfigContext();
|
|
77
|
-
if (isUseSSRBundle(userConfig) && hasStringSSREntry(userConfig)) {
|
|
78
|
-
config.plugins.push(require.resolve("@loadable/babel-plugin"));
|
|
79
|
-
}
|
|
80
|
-
}
|
|
85
|
+
babel: babelConfig
|
|
81
86
|
}
|
|
82
87
|
};
|
|
83
88
|
},
|
|
@@ -5,9 +5,11 @@ import { RuntimeContext, TRuntimeContext } from '../runtimeContext';
|
|
|
5
5
|
import { Plugin } from './plugin';
|
|
6
6
|
export type CreateAppOptions = {
|
|
7
7
|
plugins: Plugin[];
|
|
8
|
+
props?: any;
|
|
8
9
|
};
|
|
9
10
|
export declare const createApp: ({
|
|
10
|
-
plugins
|
|
11
|
+
plugins,
|
|
12
|
+
props: globalProps
|
|
11
13
|
}: CreateAppOptions) => (App?: React.ComponentType<any>) => React.ComponentType<any>;
|
|
12
14
|
type BootStrap<T = unknown> = (App: React.ComponentType, id: string | HTMLElement | RuntimeContext, root?: any, ReactDOM?: {
|
|
13
15
|
render?: Renderer;
|
|
@@ -19,12 +19,12 @@ export declare function composeEventHandlers<EventType extends React.SyntheticEv
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
type PrefetchBehavior = 'intent' | 'render' | 'none';
|
|
22
|
-
export interface
|
|
22
|
+
export interface LinkProps extends RouterLinkProps {
|
|
23
23
|
prefetch?: PrefetchBehavior;
|
|
24
24
|
}
|
|
25
|
-
export interface
|
|
25
|
+
export interface NavLinkProps extends RouterNavLinkProps {
|
|
26
26
|
prefetch?: PrefetchBehavior;
|
|
27
27
|
}
|
|
28
|
-
declare const Link: React.ForwardRefExoticComponent<
|
|
29
|
-
declare const NavLink: React.ForwardRefExoticComponent<
|
|
30
|
-
export { Link
|
|
28
|
+
declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
29
|
+
declare const NavLink: React.ForwardRefExoticComponent<NavLinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
30
|
+
export { Link, NavLink };
|
|
@@ -4,8 +4,8 @@ export type { SingleRouteConfig, RouterConfig };
|
|
|
4
4
|
export default routerPlugin;
|
|
5
5
|
export { modifyRoutes } from './plugin';
|
|
6
6
|
export * from './withRouter';
|
|
7
|
-
export {
|
|
8
|
-
export type {
|
|
9
|
-
export type { FormEncType, FormMethod, GetScrollRestorationKeyFunction, ParamKeyValuePair, SubmitOptions, URLSearchParamsInit, FetcherWithComponents, BrowserRouterProps, HashRouterProps, HistoryRouterProps,
|
|
10
|
-
export { createBrowserRouter, createHashRouter, createMemoryRouter, RouterProvider, BrowserRouter, HashRouter, MemoryRouter, Router, Await, Form,
|
|
7
|
+
export { Link, NavLink } from './PrefetchLink';
|
|
8
|
+
export type { LinkProps, NavLinkProps } from './PrefetchLink';
|
|
9
|
+
export type { FormEncType, FormMethod, GetScrollRestorationKeyFunction, ParamKeyValuePair, SubmitOptions, URLSearchParamsInit, FetcherWithComponents, BrowserRouterProps, HashRouterProps, HistoryRouterProps, FormProps, ScrollRestorationProps, SubmitFunction, ActionFunction, ActionFunctionArgs, AwaitProps, unstable_Blocker, unstable_BlockerFunction, DataRouteMatch, DataRouteObject, Fetcher, Hash, IndexRouteObject, IndexRouteProps, JsonFunction, LayoutRouteProps, LoaderFunction, LoaderFunctionArgs, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigation, Navigator, NonIndexRouteObject, OutletProps, Params, ParamParseKey, Path, PathMatch, Pathname, PathPattern, PathRouteProps, RedirectFunction, RelativeRoutingType, RouteMatch, RouteObject, RouteProps, RouterProps, RouterProviderProps, RoutesProps, Search, ShouldRevalidateFunction, To } from 'react-router-dom';
|
|
10
|
+
export { createBrowserRouter, createHashRouter, createMemoryRouter, RouterProvider, BrowserRouter, HashRouter, MemoryRouter, Router, Await, Form, Navigate, Outlet, Route, Routes, ScrollRestoration, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, createRoutesFromChildren, createRoutesFromElements, createSearchParams, generatePath, isRouteErrorResponse, matchPath, matchRoutes, renderMatches, resolvePath } from 'react-router-dom';
|
|
11
11
|
export { defer, json, redirect } from '@modern-js/utils/universal/remix-router';
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.
|
|
14
|
+
"version": "2.13.0",
|
|
15
15
|
"engines": {
|
|
16
16
|
"node": ">=14.17.6"
|
|
17
17
|
},
|
|
@@ -158,9 +158,9 @@
|
|
|
158
158
|
"react-side-effect": "^2.1.1",
|
|
159
159
|
"redux-logger": "^3.0.6",
|
|
160
160
|
"styled-components": "^5.3.1",
|
|
161
|
-
"@modern-js/plugin": "2.
|
|
162
|
-
"@modern-js/types": "2.
|
|
163
|
-
"@modern-js/utils": "2.
|
|
161
|
+
"@modern-js/plugin": "2.13.0",
|
|
162
|
+
"@modern-js/types": "2.13.0",
|
|
163
|
+
"@modern-js/utils": "2.13.0"
|
|
164
164
|
},
|
|
165
165
|
"peerDependencies": {
|
|
166
166
|
"react": ">=17",
|
|
@@ -181,11 +181,11 @@
|
|
|
181
181
|
"react-dom": "^18",
|
|
182
182
|
"ts-jest": "^29.0.5",
|
|
183
183
|
"typescript": "^4",
|
|
184
|
-
"@modern-js/app-tools": "2.
|
|
185
|
-
"@modern-js/core": "2.
|
|
186
|
-
"@modern-js/server-core": "2.
|
|
187
|
-
"@scripts/build": "2.
|
|
188
|
-
"@scripts/jest-config": "2.
|
|
184
|
+
"@modern-js/app-tools": "2.13.0",
|
|
185
|
+
"@modern-js/core": "2.13.0",
|
|
186
|
+
"@modern-js/server-core": "2.13.0",
|
|
187
|
+
"@scripts/build": "2.13.0",
|
|
188
|
+
"@scripts/jest-config": "2.13.0"
|
|
189
189
|
},
|
|
190
190
|
"sideEffects": false,
|
|
191
191
|
"modernConfig": {},
|