@modern-js/runtime 2.17.1 → 2.18.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.
Files changed (67) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +6 -0
  3. package/dist/cjs/router/runtime/DeferredDataScripts.node.js +6 -6
  4. package/dist/cjs/router/runtime/index.js +5 -5
  5. package/dist/cjs/router/runtime/plugin.js +2 -2
  6. package/dist/cjs/router/runtime/plugin.node.js +2 -2
  7. package/dist/cjs/router/runtime/utils.js +4 -5
  8. package/dist/cjs/ssr/cli/index.js +30 -15
  9. package/dist/cjs/ssr/cli/loadable-bundler-plugin.js +112 -0
  10. package/dist/cjs/ssr/index.js +3 -3
  11. package/dist/cjs/ssr/prefetch.js +2 -2
  12. package/dist/cjs/ssr/serverRender/renderToStream/buildTemplate.after.js +2 -2
  13. package/dist/cjs/ssr/serverRender/renderToStream/index.js +2 -2
  14. package/dist/cjs/ssr/serverRender/renderToString/entry.js +3 -3
  15. package/dist/cjs/ssr/serverRender/renderToString/index.js +2 -2
  16. package/dist/esm/core/compatible.js +13 -13
  17. package/dist/esm/core/loader/loaderManager.js +7 -7
  18. package/dist/esm/core/loader/useLoader.js +2 -2
  19. package/dist/esm/core/plugin.js +6 -6
  20. package/dist/esm/document/Html.js +5 -5
  21. package/dist/esm/document/cli/index.js +6 -6
  22. package/dist/esm/document/constants.js +1 -1
  23. package/dist/esm/router/cli/index.js +6 -6
  24. package/dist/esm/router/runtime/DeferredDataScripts.node.js +4 -4
  25. package/dist/esm/router/runtime/PrefetchLink.js +7 -7
  26. package/dist/esm/router/runtime/index.js +2 -2
  27. package/dist/esm/router/runtime/plugin.js +10 -10
  28. package/dist/esm/router/runtime/plugin.node.js +8 -8
  29. package/dist/esm/router/runtime/utils.js +7 -8
  30. package/dist/esm/router/runtime/withRouter.js +4 -4
  31. package/dist/esm/ssr/cli/index.js +37 -22
  32. package/dist/esm/ssr/cli/loadable-bundler-plugin.js +209 -0
  33. package/dist/esm/ssr/index.js +14 -14
  34. package/dist/esm/ssr/index.node.js +9 -9
  35. package/dist/esm/ssr/prefetch.js +4 -4
  36. package/dist/esm/ssr/react/prerender/index.js +1 -1
  37. package/dist/esm/ssr/serverRender/renderToStream/buildTemplate.after.js +4 -4
  38. package/dist/esm/ssr/serverRender/renderToStream/index.js +1 -1
  39. package/dist/esm/ssr/serverRender/renderToStream/loadable.js +1 -1
  40. package/dist/esm/ssr/serverRender/renderToStream/renderToPipe.js +1 -1
  41. package/dist/esm/ssr/serverRender/renderToStream/renderToPipe.worker.js +1 -1
  42. package/dist/esm/ssr/serverRender/renderToStream/template.js +2 -2
  43. package/dist/esm/ssr/serverRender/renderToString/entry.js +4 -4
  44. package/dist/esm/ssr/serverRender/renderToString/index.js +3 -3
  45. package/dist/esm/ssr/serverRender/renderToString/loadable.js +1 -1
  46. package/dist/esm/ssr/serverRender/renderToString/template.js +1 -1
  47. package/dist/esm/ssr/utils.js +4 -4
  48. package/dist/esm/state/cli/index.js +4 -4
  49. package/dist/esm/state/runtime/plugin.js +7 -7
  50. package/dist/esm-node/router/runtime/DeferredDataScripts.node.js +1 -1
  51. package/dist/esm-node/router/runtime/index.js +2 -2
  52. package/dist/esm-node/router/runtime/plugin.js +1 -1
  53. package/dist/esm-node/router/runtime/plugin.node.js +1 -1
  54. package/dist/esm-node/router/runtime/utils.js +1 -2
  55. package/dist/esm-node/ssr/cli/index.js +30 -15
  56. package/dist/esm-node/ssr/cli/loadable-bundler-plugin.js +103 -0
  57. package/dist/esm-node/ssr/index.js +1 -1
  58. package/dist/esm-node/ssr/prefetch.js +1 -1
  59. package/dist/esm-node/ssr/serverRender/renderToStream/buildTemplate.after.js +1 -1
  60. package/dist/esm-node/ssr/serverRender/renderToStream/index.js +1 -1
  61. package/dist/esm-node/ssr/serverRender/renderToString/entry.js +1 -1
  62. package/dist/esm-node/ssr/serverRender/renderToString/index.js +1 -1
  63. package/dist/types/router/runtime/index.d.ts +1 -1
  64. package/dist/types/router/runtime/utils.d.ts +1 -1
  65. package/dist/types/runtimeContext.d.ts +1 -1
  66. package/dist/types/ssr/cli/loadable-bundler-plugin.d.ts +10 -0
  67. package/package.json +9 -9
@@ -41,7 +41,7 @@ function _async_to_generator(fn) {
41
41
  function _define_property(obj, key, value) {
42
42
  if (key in obj) {
43
43
  Object.defineProperty(obj, key, {
44
- value,
44
+ value: value,
45
45
  enumerable: true,
46
46
  configurable: true,
47
47
  writable: true
@@ -233,7 +233,7 @@ export default function() {
233
233
  config: {
234
234
  output: config.output
235
235
  },
236
- entryName,
236
+ entryName: entryName,
237
237
  templateParams: templateParameters
238
238
  };
239
239
  }
@@ -253,8 +253,8 @@ export default function() {
253
253
  htmlWebpackPlugin = param.htmlWebpackPlugin;
254
254
  documentParams = getDocParams({
255
255
  config: api.useResolvedConfigContext(),
256
- entryName,
257
- templateParameters
256
+ entryName: entryName,
257
+ templateParameters: templateParameters
258
258
  });
259
259
  tempTsConfigFile = path.join(internalDirectory, "./document/_tempTsconfig.json");
260
260
  userTsConfigFilePath = path.join(appDirectory, "tsconfig.json");
@@ -322,7 +322,7 @@ export default function() {
322
322
  }
323
323
  return {
324
324
  path: args.path,
325
- external
325
+ external: external
326
326
  };
327
327
  });
328
328
  }
@@ -398,7 +398,7 @@ export default function() {
398
398
  hackParameters
399
399
  );
400
400
  var documentHtmlOptions = templateContent ? {
401
- templateContent,
401
+ templateContent: templateContent,
402
402
  inject: false
403
403
  } : {};
404
404
  return _object_spread({}, options, documentHtmlOptions);
@@ -1,7 +1,7 @@
1
1
  function _define_property(obj, key, value) {
2
2
  if (key in obj) {
3
3
  Object.defineProperty(obj, key, {
4
- value,
4
+ value: value,
5
5
  enumerable: true,
6
6
  configurable: true,
7
7
  writable: true
@@ -1,7 +1,7 @@
1
1
  function _define_property(obj, key, value) {
2
2
  if (key in obj) {
3
3
  Object.defineProperty(obj, key, {
4
- value,
4
+ value: value,
5
5
  enumerable: true,
6
6
  configurable: true,
7
7
  writable: true
@@ -107,8 +107,8 @@ export default function() {
107
107
  throw new Error("should enable runtime.router for entry ".concat(entryName));
108
108
  }
109
109
  return {
110
- entrypoint,
111
- imports
110
+ entrypoint: entrypoint,
111
+ imports: imports
112
112
  };
113
113
  },
114
114
  modifyEntryRuntimePlugins: function modifyEntryRuntimePlugins(param) {
@@ -128,15 +128,15 @@ export default function() {
128
128
  plugins.push({
129
129
  name: PLUGIN_IDENTIFIER,
130
130
  options: JSON.stringify(_object_spread_props(_object_spread({
131
- serverBase
131
+ serverBase: serverBase
132
132
  }, runtimeConfig.router), {
133
133
  routesConfig: fileSystemRoutes ? "{ ".concat(ROUTES_IDENTIFIER, ", globalApp: App }") : void 0
134
134
  })).replace(/"routesConfig"\s*:\s*"((\S|\s)+)"/g, '"routesConfig": $1,')
135
135
  });
136
136
  }
137
137
  return {
138
- entrypoint,
139
- plugins
138
+ entrypoint: entrypoint,
139
+ plugins: plugins
140
140
  };
141
141
  },
142
142
  addRuntimeExports: function addRuntimeExports() {
@@ -59,7 +59,7 @@ function _unsupported_iterable_to_array(o, minLen) {
59
59
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
60
60
  import { Suspense, useEffect, useRef, useMemo, useContext } from "react";
61
61
  import { Await, UNSAFE_DataRouterContext as DataRouterContext, useAsyncError } from "react-router-dom";
62
- import { serializeJson } from "@modern-js/utils/universal/serialize";
62
+ import { serializeJson } from "@modern-js/utils/runtime-node";
63
63
  import { JSX_SHELL_STREAM_END_MARK } from "../../common";
64
64
  import { serializeErrors } from "./utils";
65
65
  var setupFnStr = "function s(r,e){_ROUTER_DATA.r=_ROUTER_DATA.r||{},_ROUTER_DATA.r[r]=_ROUTER_DATA.r[r]||{};return new Promise((function(A,R){_ROUTER_DATA.r[r][e]={resolve:A,reject:R}}))};";
@@ -97,7 +97,7 @@ var DeferredDataScripts = function() {
97
97
  deferredDataScripts.push(/* @__PURE__ */ _jsx(DeferredDataScript, {
98
98
  data: deferredData.data[key],
99
99
  dataKey: key,
100
- routeId
100
+ routeId: routeId
101
101
  }, "".concat(routeId, " | ").concat(key)));
102
102
  return "".concat(JSON.stringify(key), ": _ROUTER_DATA.s(").concat(JSON.stringify(routeId), ",").concat(JSON.stringify(key), ") ");
103
103
  } else {
@@ -146,8 +146,8 @@ var DeferredDataScript = function(param) {
146
146
  children: typeof document === "undefined" && data && dataKey && routeId ? /* @__PURE__ */ _jsx(Await, {
147
147
  resolve: data,
148
148
  errorElement: /* @__PURE__ */ _jsx(ErrorDeferredDataScript, {
149
- routeId,
150
- dataKey
149
+ routeId: routeId,
150
+ dataKey: dataKey
151
151
  }),
152
152
  children: function(data2) {
153
153
  return /* @__PURE__ */ _jsx("script", {
@@ -41,7 +41,7 @@ function _async_to_generator(fn) {
41
41
  function _define_property(obj, key, value) {
42
42
  if (key in obj) {
43
43
  Object.defineProperty(obj, key, {
44
- value,
44
+ value: value,
45
45
  enumerable: true,
46
46
  configurable: true,
47
47
  writable: true
@@ -380,7 +380,7 @@ var createDataHref = function(href) {
380
380
  return /* @__PURE__ */ _jsx("link", {
381
381
  rel: "prefetch",
382
382
  as: "fetch",
383
- href
383
+ href: href
384
384
  }, href);
385
385
  };
386
386
  var getDataHref = function(route, pathname, basename) {
@@ -404,9 +404,9 @@ var PrefetchPageLinks = function(param) {
404
404
  return null;
405
405
  }
406
406
  return /* @__PURE__ */ _jsx(PrefetchDataLinks, {
407
- matches,
408
- pathname,
409
- routeManifest
407
+ matches: matches,
408
+ pathname: pathname,
409
+ routeManifest: routeManifest
410
410
  });
411
411
  };
412
412
  var PrefetchDataLinks = function(param) {
@@ -455,10 +455,10 @@ var createPrefetchLink = function(Link2) {
455
455
  children: [
456
456
  /* @__PURE__ */ _jsx(Link2, _object_spread({
457
457
  ref: forwardedRef,
458
- to
458
+ to: to
459
459
  }, props, prefetchHandlers)),
460
460
  shouldPrefetch && __webpack_chunk_load__ && !isAbsolute ? /* @__PURE__ */ _jsx(PrefetchPageLinks, {
461
- pathname
461
+ pathname: pathname
462
462
  }) : null
463
463
  ]
464
464
  });
@@ -5,7 +5,7 @@ export { modifyRoutes } from "./plugin";
5
5
  export * from "./withRouter";
6
6
  export { Link, NavLink } from "./PrefetchLink";
7
7
  export var useRouteLoaderData = function(routeId) {
8
- var realRouteId = routeId.replace(/\((.*?)\)/g, "[$1]");
8
+ var realRouteId = routeId.replace(/\[(.*?)\]/g, "($1)");
9
9
  return useRouteData(realRouteId);
10
10
  };
11
11
  export {
@@ -63,4 +63,4 @@ export {
63
63
  unstable_useBlocker,
64
64
  unstable_usePrompt
65
65
  } from "react-router-dom";
66
- export { defer, json, redirect } from "@modern-js/utils/universal/remix-router";
66
+ export { defer, json, redirect } from "@modern-js/utils/runtime/router";
@@ -1,7 +1,7 @@
1
1
  function _define_property(obj, key, value) {
2
2
  if (key in obj) {
3
3
  Object.defineProperty(obj, key, {
4
- value,
4
+ value: value,
5
5
  enumerable: true,
6
6
  configurable: true,
7
7
  writable: true
@@ -53,7 +53,7 @@ function _object_spread_props(target, source) {
53
53
  import { jsx as _jsx } from "react/jsx-runtime";
54
54
  import { createBrowserRouter, createHashRouter, RouterProvider, createRoutesFromElements, useMatches, useLocation } from "react-router-dom";
55
55
  import hoistNonReactStatics from "hoist-non-react-statics";
56
- import { parsedJSONFromElement } from "@modern-js/utils/runtime";
56
+ import { parsedJSONFromElement } from "@modern-js/utils/runtime-browser";
57
57
  import { modifyRoutes as modifyRoutesHook } from "./hooks";
58
58
  import { deserializeErrors, renderRoutes, urlJoin } from "./utils";
59
59
  export var finalRouteConfig = {
@@ -89,8 +89,8 @@ export var routerPlugin = function(param) {
89
89
  init: function init(param2, next) {
90
90
  var context = param2.context;
91
91
  context.router = {
92
- useMatches,
93
- useLocation
92
+ useMatches: useMatches,
93
+ useLocation: useLocation
94
94
  };
95
95
  Object.defineProperty(context, "routes", {
96
96
  get: function get() {
@@ -98,14 +98,14 @@ export var routerPlugin = function(param) {
98
98
  }
99
99
  });
100
100
  return next({
101
- context
101
+ context: context
102
102
  });
103
103
  },
104
104
  hoc: function(param2, next) {
105
105
  var App = param2.App;
106
106
  if (!finalRouteConfig && !createRoutes) {
107
107
  return next({
108
- App
108
+ App: App
109
109
  });
110
110
  }
111
111
  var getRouteApp = function() {
@@ -114,7 +114,7 @@ export var routerPlugin = function(param) {
114
114
  beforeCreateRouter = false;
115
115
  routes = createRoutes ? createRoutes() : createRoutesFromElements(renderRoutes({
116
116
  routesConfig: finalRouteConfig,
117
- props
117
+ props: props
118
118
  }));
119
119
  var runner = api.useHookRunners();
120
120
  routes = runner.modifyRoutes(routes);
@@ -128,14 +128,14 @@ export var routerPlugin = function(param) {
128
128
  }
129
129
  var router = supportHtml5History ? createBrowserRouter(routes, {
130
130
  basename: _basename,
131
- hydrationData
131
+ hydrationData: hydrationData
132
132
  }) : createHashRouter(routes, {
133
133
  basename: _basename,
134
- hydrationData
134
+ hydrationData: hydrationData
135
135
  });
136
136
  return /* @__PURE__ */ _jsx(App, _object_spread_props(_object_spread({}, props), {
137
137
  children: /* @__PURE__ */ _jsx(RouterProvider, {
138
- router
138
+ router: router
139
139
  })
140
140
  }));
141
141
  };
@@ -41,7 +41,7 @@ function _async_to_generator(fn) {
41
41
  function _define_property(obj, key, value) {
42
42
  if (key in obj) {
43
43
  Object.defineProperty(obj, key, {
44
- value,
44
+ value: value,
45
45
  enumerable: true,
46
46
  configurable: true,
47
47
  writable: true
@@ -248,7 +248,7 @@ var __generator = function(thisArg, body) {
248
248
  };
249
249
  import { jsx as _jsx } from "react/jsx-runtime";
250
250
  import { useContext } from "react";
251
- import { createStaticHandler } from "@modern-js/utils/universal/remix-router";
251
+ import { createStaticHandler } from "@modern-js/utils/runtime/router";
252
252
  import { createStaticRouter, StaticRouterProvider } from "react-router-dom/server";
253
253
  import hoistNonReactStatics from "hoist-non-react-statics";
254
254
  import { createRoutesFromElements } from "react-router-dom";
@@ -337,7 +337,7 @@ export var routerPlugin = function(param) {
337
337
  return [
338
338
  2,
339
339
  next({
340
- context
340
+ context: context
341
341
  })
342
342
  ];
343
343
  }
@@ -345,8 +345,8 @@ export var routerPlugin = function(param) {
345
345
  baseUrl = request.baseUrl;
346
346
  _basename = baseUrl === "/" ? urlJoin(baseUrl, basename) : baseUrl;
347
347
  routes = createRoutes ? createRoutes() : createRoutesFromElements(renderRoutes({
348
- routesConfig,
349
- ssrMode
348
+ routesConfig: routesConfig,
349
+ ssrMode: ssrMode
350
350
  }));
351
351
  query = createStaticHandler(routes, {
352
352
  basename: _basename
@@ -374,7 +374,7 @@ export var routerPlugin = function(param) {
374
374
  return [
375
375
  2,
376
376
  next({
377
- context
377
+ context: context
378
378
  })
379
379
  ];
380
380
  }
@@ -385,7 +385,7 @@ export var routerPlugin = function(param) {
385
385
  var App = param2.App;
386
386
  if (!routesConfig) {
387
387
  return next({
388
- App
388
+ App: App
389
389
  });
390
390
  }
391
391
  var getRouteApp = function() {
@@ -393,7 +393,7 @@ export var routerPlugin = function(param) {
393
393
  var _useContext = useContext(RuntimeReactContext), router = _useContext.router, routerContext = _useContext.routerContext;
394
394
  return /* @__PURE__ */ _jsx(App, _object_spread_props(_object_spread({}, props), {
395
395
  children: /* @__PURE__ */ _jsx(StaticRouterProvider, {
396
- router,
396
+ router: router,
397
397
  context: routerContext,
398
398
  hydrate: false
399
399
  })
@@ -12,7 +12,7 @@ function _array_with_holes(arr) {
12
12
  function _define_property(obj, key, value) {
13
13
  if (key in obj) {
14
14
  Object.defineProperty(obj, key, {
15
- value,
15
+ value: value,
16
16
  enumerable: true,
17
17
  configurable: true,
18
18
  writable: true
@@ -149,8 +149,7 @@ function _unsupported_iterable_to_array(o, minLen) {
149
149
  }
150
150
  import { jsx as _jsx } from "react/jsx-runtime";
151
151
  import { Route } from "react-router-dom";
152
- import { ErrorResponse, isRouteErrorResponse } from "@modern-js/utils/universal/remix-router";
153
- import { renderNestedRoute } from "@modern-js/utils/universal/nestedRoutes";
152
+ import { ErrorResponse, isRouteErrorResponse, renderNestedRoute } from "@modern-js/utils/runtime/router";
154
153
  import { DefaultNotFound } from "./DefaultNotFound";
155
154
  import DeferredDataScripts from "./DeferredDataScripts";
156
155
  export function getRouteComponents(routes, param) {
@@ -164,7 +163,7 @@ export function getRouteComponents(routes, param) {
164
163
  return /* @__PURE__ */ _jsx(Component, _object_spread({}, props2));
165
164
  }
166
165
  return /* @__PURE__ */ _jsx(GlobalLayout, _object_spread({
167
- Component
166
+ Component: Component
168
167
  }, props2));
169
168
  };
170
169
  var routeElements = [];
@@ -175,7 +174,7 @@ export function getRouteComponents(routes, param) {
175
174
  if (route.type === "nested") {
176
175
  var routeElement = renderNestedRoute(route, {
177
176
  DeferredDataComponent: ssrMode === "stream" ? DeferredDataScripts : void 0,
178
- props
177
+ props: props
179
178
  });
180
179
  routeElements.push(routeElement);
181
180
  } else {
@@ -218,9 +217,9 @@ export function renderRoutes(param) {
218
217
  return null;
219
218
  }
220
219
  var routeElements = getRouteComponents(routes, {
221
- globalApp,
222
- ssrMode,
223
- props
220
+ globalApp: globalApp,
221
+ ssrMode: ssrMode,
222
+ props: props
224
223
  });
225
224
  return routeElements;
226
225
  }
@@ -1,7 +1,7 @@
1
1
  function _define_property(obj, key, value) {
2
2
  if (key in obj) {
3
3
  Object.defineProperty(obj, key, {
4
- value,
4
+ value: value,
5
5
  enumerable: true,
6
6
  configurable: true,
7
7
  writable: true
@@ -58,9 +58,9 @@ export var withRouter = function(Component) {
58
58
  var params = useParams();
59
59
  var navigate = useNavigate();
60
60
  return /* @__PURE__ */ _jsx(Component, _object_spread_props(_object_spread({}, props), {
61
- location,
62
- params,
63
- navigate
61
+ location: location,
62
+ params: params,
63
+ navigate: navigate
64
64
  }));
65
65
  };
66
66
  };
@@ -48,21 +48,36 @@ export default function() {
48
48
  config: function config() {
49
49
  var appContext = api.useAppContext();
50
50
  pluginsExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, "plugins");
51
+ var userConfig = api.useResolvedConfigContext();
51
52
  var _api_useAppContext = api.useAppContext(), _api_useAppContext_bundlerType = _api_useAppContext.bundlerType, bundlerType = _api_useAppContext_bundlerType === void 0 ? "webpack" : _api_useAppContext_bundlerType;
52
- var babelConfig = bundlerType === "webpack" ? function(config2) {
53
- var _config_plugins;
54
- (_config_plugins = config2.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(path.join(__dirname, "./babel-plugin-ssr-loader-id"));
55
- var userConfig = api.useResolvedConfigContext();
56
- if (isUseSSRBundle(userConfig) && hasStringSSREntry(userConfig)) {
57
- var _config_plugins1;
58
- (_config_plugins1 = config2.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
53
+ var babelConfig = function() {
54
+ if (bundlerType === "webpack") {
55
+ return function(config2) {
56
+ var _config_plugins;
57
+ (_config_plugins = config2.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(path.join(__dirname, "./babel-plugin-ssr-loader-id"));
58
+ if (isUseSSRBundle(userConfig) && hasStringSSREntry(userConfig)) {
59
+ var _config_plugins1;
60
+ (_config_plugins1 = config2.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
61
+ }
62
+ };
63
+ } else if (bundlerType === "rspack") {
64
+ if (isUseSSRBundle(userConfig)) {
65
+ return function(config2) {
66
+ var _config_plugins;
67
+ (_config_plugins = config2.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(path.join(__dirname, "./babel-plugin-ssr-loader-id"));
68
+ if (hasStringSSREntry(userConfig)) {
69
+ var _config_plugins1;
70
+ (_config_plugins1 = config2.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
71
+ }
72
+ };
73
+ }
59
74
  }
60
- } : void 0;
75
+ }();
61
76
  return {
62
77
  source: {
63
78
  alias: {
64
- // ensure that all packages use the same storage in @modern-js/utils/ssr
65
- "@modern-js/utils/ssr": require.resolve("@modern-js/utils/ssr"),
79
+ // ensure that all packages use the same storage in @modern-js/utils/runtime-node
80
+ "@modern-js/utils/runtime-node": require.resolve("@modern-js/utils/runtime-node"),
66
81
  "@modern-js/runtime/plugins": pluginsExportsUtils.getPath()
67
82
  },
68
83
  globalVars: function(values, param) {
@@ -71,12 +86,12 @@ export default function() {
71
86
  }
72
87
  },
73
88
  tools: {
74
- webpackChain: function(chain, param) {
89
+ bundlerChain: function bundlerChain(chain, param) {
75
90
  var isServer = param.isServer, isServiceWorker = param.isServiceWorker, CHAIN_ID = param.CHAIN_ID;
76
- var userConfig = api.useResolvedConfigContext();
77
- if (isUseSSRBundle(userConfig) && !isServer && !isServiceWorker && hasStringSSREntry(userConfig)) {
78
- var LoadableWebpackPlugin = require("@loadable/webpack-plugin");
79
- chain.plugin(CHAIN_ID.PLUGIN.LOADABLE).use(LoadableWebpackPlugin, [
91
+ var userConfig2 = api.useResolvedConfigContext();
92
+ if (isUseSSRBundle(userConfig2) && !isServer && !isServiceWorker && hasStringSSREntry(userConfig2)) {
93
+ var LoadableBundlerPlugin = require("./loadable-bundler-plugin.js");
94
+ chain.plugin(CHAIN_ID.PLUGIN.LOADABLE).use(LoadableBundlerPlugin, [
80
95
  {
81
96
  filename: LOADABLE_STATS_FILE
82
97
  }
@@ -117,8 +132,8 @@ export default function() {
117
132
  });
118
133
  }
119
134
  return {
120
- entrypoint,
121
- imports
135
+ entrypoint: entrypoint,
136
+ imports: imports
122
137
  };
123
138
  },
124
139
  modifyEntryRuntimePlugins: function modifyEntryRuntimePlugins(param) {
@@ -130,15 +145,15 @@ export default function() {
130
145
  });
131
146
  }
132
147
  return {
133
- entrypoint,
134
- plugins
148
+ entrypoint: entrypoint,
149
+ plugins: plugins
135
150
  };
136
151
  },
137
152
  modifyEntryExport: function modifyEntryExport(param) {
138
153
  var entrypoint = param.entrypoint, exportStatement = param.exportStatement;
139
154
  if (ssrConfigMap.get(entrypoint.entryName)) {
140
155
  return {
141
- entrypoint,
156
+ entrypoint: entrypoint,
142
157
  exportStatement: [
143
158
  "export function ".concat(SERVER_RENDER_FUNCTION_NAME, "(context) {\n return bootstrap(AppWrapper, context)\n }"),
144
159
  exportStatement
@@ -146,8 +161,8 @@ export default function() {
146
161
  };
147
162
  }
148
163
  return {
149
- entrypoint,
150
- exportStatement
164
+ entrypoint: entrypoint,
165
+ exportStatement: exportStatement
151
166
  };
152
167
  }
153
168
  };