@modern-js/app-tools 2.41.0 → 2.42.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 (102) hide show
  1. package/dist/cjs/analyze/templates.js +7 -6
  2. package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +3 -1
  3. package/dist/cjs/config/default.js +2 -1
  4. package/dist/esm/analyze/templates.js +6 -6
  5. package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +6 -4
  6. package/dist/esm/config/default.js +2 -1
  7. package/dist/esm-node/analyze/templates.js +7 -6
  8. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +3 -1
  9. package/dist/esm-node/config/default.js +2 -1
  10. package/dist/types/analyze/constants.d.ts +19 -19
  11. package/dist/types/analyze/generateCode.d.ts +9 -16
  12. package/dist/types/analyze/getBundleEntry.d.ts +1 -1
  13. package/dist/types/analyze/getClientRoutes/getRoutes.d.ts +7 -13
  14. package/dist/types/analyze/getClientRoutes/getRoutesLegacy.d.ts +7 -13
  15. package/dist/types/analyze/getClientRoutes/index.d.ts +1 -1
  16. package/dist/types/analyze/getClientRoutes/utils.d.ts +1 -1
  17. package/dist/types/analyze/getFileSystemEntry.d.ts +1 -1
  18. package/dist/types/analyze/getHtmlTemplate.d.ts +4 -7
  19. package/dist/types/analyze/getServerRoutes.d.ts +4 -7
  20. package/dist/types/analyze/index.d.ts +3 -5
  21. package/dist/types/analyze/isDefaultExportFunction.d.ts +1 -1
  22. package/dist/types/analyze/makeLegalIdentifier.d.ts +1 -1
  23. package/dist/types/analyze/nestedRoutes.d.ts +3 -3
  24. package/dist/types/analyze/templates.d.ts +22 -40
  25. package/dist/types/analyze/utils.d.ts +10 -19
  26. package/dist/types/builder/builder-rspack/adapterCopy.d.ts +1 -1
  27. package/dist/types/builder/builder-rspack/index.d.ts +1 -1
  28. package/dist/types/builder/builder-webpack/adapterModern.d.ts +1 -1
  29. package/dist/types/builder/builder-webpack/createCopyPattern.d.ts +20 -20
  30. package/dist/types/builder/builder-webpack/index.d.ts +1 -1
  31. package/dist/types/builder/generator/createBuilderOptions.d.ts +1 -1
  32. package/dist/types/builder/generator/createBuilderProviderConfig.d.ts +1 -1
  33. package/dist/types/builder/generator/getBuilderTargets.d.ts +1 -1
  34. package/dist/types/builder/generator/index.d.ts +2 -2
  35. package/dist/types/builder/index.d.ts +1 -1
  36. package/dist/types/builder/shared/builderPlugins/adapterBasic.d.ts +1 -1
  37. package/dist/types/builder/shared/builderPlugins/adapterHtml.d.ts +1 -1
  38. package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +1 -1
  39. package/dist/types/builder/shared/builderPlugins/index.d.ts +1 -1
  40. package/dist/types/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.d.ts +5 -5
  41. package/dist/types/builder/shared/bundlerPlugins/HtmlBottomTemplate.d.ts +7 -7
  42. package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +24 -31
  43. package/dist/types/builder/shared/bundlerPlugins/index.d.ts +1 -1
  44. package/dist/types/builder/shared/createCopyInfo.d.ts +4 -4
  45. package/dist/types/builder/shared/index.d.ts +1 -1
  46. package/dist/types/builder/shared/loaders/serverModuleLoader.d.ts +1 -1
  47. package/dist/types/builder/shared/types.d.ts +3 -3
  48. package/dist/types/commands/build.d.ts +1 -1
  49. package/dist/types/commands/deploy.d.ts +1 -1
  50. package/dist/types/commands/dev.d.ts +2 -2
  51. package/dist/types/commands/index.d.ts +1 -1
  52. package/dist/types/commands/inspect.d.ts +7 -7
  53. package/dist/types/commands/serve.d.ts +1 -1
  54. package/dist/types/config/default.d.ts +1 -1
  55. package/dist/types/config/index.d.ts +1 -1
  56. package/dist/types/config/initialize/index.d.ts +1 -1
  57. package/dist/types/config/initialize/inits.d.ts +1 -1
  58. package/dist/types/config/legacy/createHtmlConfig.d.ts +1 -1
  59. package/dist/types/config/legacy/createOutputConfig.d.ts +1 -1
  60. package/dist/types/config/legacy/createSourceConfig.d.ts +1 -1
  61. package/dist/types/config/legacy/createToolsConfig.d.ts +1 -1
  62. package/dist/types/config/legacy/index.d.ts +1 -1
  63. package/dist/types/defineConfig.d.ts +1 -1
  64. package/dist/types/exports/server.d.ts +1 -1
  65. package/dist/types/hooks.d.ts +1 -1
  66. package/dist/types/index.d.ts +6 -6
  67. package/dist/types/initialize/index.d.ts +3 -5
  68. package/dist/types/locale/en.d.ts +38 -38
  69. package/dist/types/locale/index.d.ts +75 -75
  70. package/dist/types/locale/zh.d.ts +38 -38
  71. package/dist/types/types/config/deploy.d.ts +21 -21
  72. package/dist/types/types/config/dev.d.ts +10 -10
  73. package/dist/types/types/config/experiments.d.ts +1 -1
  74. package/dist/types/types/config/html.d.ts +1 -1
  75. package/dist/types/types/config/index.d.ts +38 -38
  76. package/dist/types/types/config/output.d.ts +35 -28
  77. package/dist/types/types/config/performance.d.ts +1 -1
  78. package/dist/types/types/config/security.d.ts +1 -1
  79. package/dist/types/types/config/source.d.ts +52 -52
  80. package/dist/types/types/config/testing.d.ts +6 -6
  81. package/dist/types/types/config/tools.d.ts +26 -24
  82. package/dist/types/types/hooks.d.ts +75 -75
  83. package/dist/types/types/index.d.ts +17 -17
  84. package/dist/types/types/legacyConfig/deploy.d.ts +5 -5
  85. package/dist/types/types/legacyConfig/dev.d.ts +9 -9
  86. package/dist/types/types/legacyConfig/index.d.ts +16 -16
  87. package/dist/types/types/legacyConfig/output.d.ts +45 -45
  88. package/dist/types/types/legacyConfig/source.d.ts +22 -22
  89. package/dist/types/types/legacyConfig/testing.d.ts +6 -6
  90. package/dist/types/types/legacyConfig/tools.d.ts +10 -10
  91. package/dist/types/types/utils.d.ts +4 -4
  92. package/dist/types/utils/config.d.ts +7 -13
  93. package/dist/types/utils/createServer.d.ts +5 -5
  94. package/dist/types/utils/env.d.ts +1 -1
  95. package/dist/types/utils/generateWatchFiles.d.ts +1 -1
  96. package/dist/types/utils/getSelectedEntries.d.ts +1 -1
  97. package/dist/types/utils/getServerInternalPlugins.d.ts +1 -1
  98. package/dist/types/utils/printInstructions.d.ts +1 -1
  99. package/dist/types/utils/restart.d.ts +1 -1
  100. package/dist/types/utils/routes.d.ts +1 -1
  101. package/dist/types/utils/types.d.ts +13 -13
  102. package/package.json +24 -24
@@ -190,7 +190,8 @@ const routesForServer = ({ routes }) => {
190
190
  ${routesCode}
191
191
  `;
192
192
  };
193
- const createMatchReg = (keyword) => new RegExp(`("${keyword}":\\s)"([^,]+)"`, "g");
193
+ const createMatchReg = (keyword) => new RegExp(`("${keyword}":\\s)"([^
194
+ ]+)"`, "g");
194
195
  const fileSystemRoutes = async ({ routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, splitRouteChunks = true }) => {
195
196
  const components = [];
196
197
  const loadings = [];
@@ -264,18 +265,18 @@ const fileSystemRoutes = async ({ routes, ssrMode, nestedRoutesEntry, entryName,
264
265
  if (route._component) {
265
266
  if (splitRouteChunks) {
266
267
  if (route.isRoot) {
267
- lazyImport = `() => import('${route._component}').then(routeModule => {if(typeof document !== "undefined") window.${import_constants.ROUTE_MODULES}["${route.id}"] = routeModule; return routeModule; }) `;
268
+ lazyImport = `() => import('${route._component}').then(routeModule => handleRouteModule(routeModule, "${route.id}")).catch(handleRouteModuleError) `;
268
269
  rootLayoutCode = `import RootLayout from '${route._component}'`;
269
270
  component = `RootLayout`;
270
271
  } else if (ssrMode === "string") {
271
- lazyImport = `() => import(/* webpackChunkName: "${route.id}" */ '${route._component}').then(routeModule => {if(typeof document !== "undefined") window.${import_constants.ROUTE_MODULES}["${route.id}"] = routeModule; return routeModule; }) `;
272
+ lazyImport = `() => import(/* webpackChunkName: "${route.id}" */ '${route._component}').then(routeModule => handleRouteModule(routeModule, "${route.id}")).catch(handleRouteModuleError) `;
272
273
  component = `loadable(${lazyImport})`;
273
274
  } else {
274
- lazyImport = `() => import(/* webpackChunkName: "${route.id}" */ '${route._component}').then(routeModule => {if(typeof document !== "undefined") window.${import_constants.ROUTE_MODULES}["${route.id}"] = routeModule; return routeModule; }) `;
275
+ lazyImport = `() => import(/* webpackChunkName: "${route.id}" */ '${route._component}').then(routeModule => handleRouteModule(routeModule, "${route.id}")).catch(handleRouteModuleError) `;
275
276
  component = `lazy(${lazyImport})`;
276
277
  }
277
278
  } else {
278
- lazyImport = `() => import(/* webpackMode: "eager" */ '${route._component}').then(routeModule => {if(typeof document !== "undefined") window.${import_constants.ROUTE_MODULES}["${route.id}"] = routeModule; return routeModule; }) `;
279
+ lazyImport = `() => import(/* webpackMode: "eager" */ '${route._component}').then(routeModule => handleRouteModule(routeModule, "${route.id}")).catch(handleRouteModuleError) `;
279
280
  if (ssrMode === "string") {
280
281
  component = `loadable(${lazyImport})`;
281
282
  } else {
@@ -402,7 +403,7 @@ const fileSystemRoutes = async ({ routes, ssrMode, nestedRoutesEntry, entryName,
402
403
  await import_utils.fs.ensureFile(loadersMapFile);
403
404
  await import_utils.fs.writeJSON(loadersMapFile, loadersMap);
404
405
  const importRuntimeRouterCode = `
405
- import { createShouldRevalidate } from '@modern-js/runtime/router';
406
+ import { createShouldRevalidate, handleRouteModule, handleRouteModuleError} from '@modern-js/runtime/router';
406
407
  `;
407
408
  const routeModulesCode = `
408
409
  if(typeof document !== 'undefined'){
@@ -109,12 +109,14 @@ function applyRouterPlugin(chain, pluginName, options, HtmlBundlerPlugin) {
109
109
  const routerConfig = normalizedConfig === null || normalizedConfig === void 0 ? void 0 : (_normalizedConfig_runtime = normalizedConfig.runtime) === null || _normalizedConfig_runtime === void 0 ? void 0 : _normalizedConfig_runtime.router;
110
110
  const routerManifest = Boolean(routerConfig === null || routerConfig === void 0 ? void 0 : routerConfig.manifest);
111
111
  const workerSSR = Boolean((_normalizedConfig_deploy_worker = normalizedConfig.deploy.worker) === null || _normalizedConfig_deploy_worker === void 0 ? void 0 : _normalizedConfig_deploy_worker.ssr);
112
+ const { enableInlineRouteManifests, disableInlineRouteManifests } = normalizedConfig.output;
113
+ const inlineRouteManifests = disableInlineRouteManifests ? !disableInlineRouteManifests : enableInlineRouteManifests;
112
114
  if (existNestedRoutes || routerManifest || workerSSR) {
113
115
  var _normalizedConfig_output_distPath, _normalizedConfig_output, _normalizedConfig_output1, _normalizedConfig_html, _normalizedConfig_security;
114
116
  chain.plugin(pluginName).use(import_bundlerPlugins.RouterPlugin, [
115
117
  {
116
118
  HtmlBundlerPlugin,
117
- enableInlineRouteManifests: normalizedConfig.output.enableInlineRouteManifests,
119
+ enableInlineRouteManifests: inlineRouteManifests,
118
120
  staticJsDir: (_normalizedConfig_output = normalizedConfig.output) === null || _normalizedConfig_output === void 0 ? void 0 : (_normalizedConfig_output_distPath = _normalizedConfig_output.distPath) === null || _normalizedConfig_output_distPath === void 0 ? void 0 : _normalizedConfig_output_distPath.js,
119
121
  disableFilenameHash: (_normalizedConfig_output1 = normalizedConfig.output) === null || _normalizedConfig_output1 === void 0 ? void 0 : _normalizedConfig_output1.disableFilenameHash,
120
122
  scriptLoading: (_normalizedConfig_html = normalizedConfig.html) === null || _normalizedConfig_html === void 0 ? void 0 : _normalizedConfig_html.scriptLoading,
@@ -36,7 +36,8 @@ function createDefaultConfig(appContext, bundler) {
36
36
  const output = {
37
37
  ...defaultBuilderConfig.output,
38
38
  disableNodePolyfill: true,
39
- enableInlineRouteManifests: true
39
+ enableInlineRouteManifests: true,
40
+ disableInlineRouteManifests: false
40
41
  };
41
42
  const source = {
42
43
  ...defaultBuilderConfig.source,
@@ -131,7 +131,7 @@ var routesForServer = function(param) {
131
131
  return "\n ".concat(importLoadersCode, "\n ").concat(routesCode, "\n ");
132
132
  };
133
133
  var createMatchReg = function(keyword) {
134
- return new RegExp('("'.concat(keyword, '":\\s)"([^,]+)"'), "g");
134
+ return new RegExp('("'.concat(keyword, '":\\s)"([^\n]+)"'), "g");
135
135
  };
136
136
  var fileSystemRoutes = function() {
137
137
  var _ref = _async_to_generator(function(param) {
@@ -210,18 +210,18 @@ var fileSystemRoutes = function() {
210
210
  if (route2._component) {
211
211
  if (splitRouteChunks) {
212
212
  if (route2.isRoot) {
213
- lazyImport = "() => import('".concat(route2._component, `').then(routeModule => {if(typeof document !== "undefined") window.`).concat(ROUTE_MODULES, '["').concat(route2.id, '"] = routeModule; return routeModule; }) ');
213
+ lazyImport = "() => import('".concat(route2._component, `').then(routeModule => handleRouteModule(routeModule, "`).concat(route2.id, '")).catch(handleRouteModuleError) ');
214
214
  rootLayoutCode = "import RootLayout from '".concat(route2._component, "'");
215
215
  component2 = "RootLayout";
216
216
  } else if (ssrMode === "string") {
217
- lazyImport = '() => import(/* webpackChunkName: "'.concat(route2.id, `" */ '`).concat(route2._component, `').then(routeModule => {if(typeof document !== "undefined") window.`).concat(ROUTE_MODULES, '["').concat(route2.id, '"] = routeModule; return routeModule; }) ');
217
+ lazyImport = '() => import(/* webpackChunkName: "'.concat(route2.id, `" */ '`).concat(route2._component, `').then(routeModule => handleRouteModule(routeModule, "`).concat(route2.id, '")).catch(handleRouteModuleError) ');
218
218
  component2 = "loadable(".concat(lazyImport, ")");
219
219
  } else {
220
- lazyImport = '() => import(/* webpackChunkName: "'.concat(route2.id, `" */ '`).concat(route2._component, `').then(routeModule => {if(typeof document !== "undefined") window.`).concat(ROUTE_MODULES, '["').concat(route2.id, '"] = routeModule; return routeModule; }) ');
220
+ lazyImport = '() => import(/* webpackChunkName: "'.concat(route2.id, `" */ '`).concat(route2._component, `').then(routeModule => handleRouteModule(routeModule, "`).concat(route2.id, '")).catch(handleRouteModuleError) ');
221
221
  component2 = "lazy(".concat(lazyImport, ")");
222
222
  }
223
223
  } else {
224
- lazyImport = `() => import(/* webpackMode: "eager" */ '`.concat(route2._component, `').then(routeModule => {if(typeof document !== "undefined") window.`).concat(ROUTE_MODULES, '["').concat(route2.id, '"] = routeModule; return routeModule; }) ');
224
+ lazyImport = `() => import(/* webpackMode: "eager" */ '`.concat(route2._component, `').then(routeModule => handleRouteModule(routeModule, "`).concat(route2.id, '")).catch(handleRouteModuleError) ');
225
225
  if (ssrMode === "string") {
226
226
  component2 = "loadable(".concat(lazyImport, ")");
227
227
  } else {
@@ -400,7 +400,7 @@ var fileSystemRoutes = function() {
400
400
  ];
401
401
  case 2:
402
402
  _state.sent();
403
- importRuntimeRouterCode = "\n import { createShouldRevalidate } from '@modern-js/runtime/router';\n ";
403
+ importRuntimeRouterCode = "\n import { createShouldRevalidate, handleRouteModule, handleRouteModuleError} from '@modern-js/runtime/router';\n ";
404
404
  routeModulesCode = "\n if(typeof document !== 'undefined'){\n window.".concat(ROUTE_MODULES, " = {}\n }\n ");
405
405
  return [
406
406
  2,
@@ -127,14 +127,16 @@ function applyRouterPlugin(chain, pluginName, options, HtmlBundlerPlugin) {
127
127
  var routerConfig = normalizedConfig === null || normalizedConfig === void 0 ? void 0 : (_normalizedConfig_runtime = normalizedConfig.runtime) === null || _normalizedConfig_runtime === void 0 ? void 0 : _normalizedConfig_runtime.router;
128
128
  var routerManifest = Boolean(routerConfig === null || routerConfig === void 0 ? void 0 : routerConfig.manifest);
129
129
  var workerSSR = Boolean((_normalizedConfig_deploy_worker = normalizedConfig.deploy.worker) === null || _normalizedConfig_deploy_worker === void 0 ? void 0 : _normalizedConfig_deploy_worker.ssr);
130
+ var _normalizedConfig_output = normalizedConfig.output, enableInlineRouteManifests = _normalizedConfig_output.enableInlineRouteManifests, disableInlineRouteManifests = _normalizedConfig_output.disableInlineRouteManifests;
131
+ var inlineRouteManifests = disableInlineRouteManifests ? !disableInlineRouteManifests : enableInlineRouteManifests;
130
132
  if (existNestedRoutes || routerManifest || workerSSR) {
131
- var _normalizedConfig_output_distPath, _normalizedConfig_output, _normalizedConfig_output1, _normalizedConfig_html, _normalizedConfig_security;
133
+ var _normalizedConfig_output_distPath, _normalizedConfig_output1, _normalizedConfig_output2, _normalizedConfig_html, _normalizedConfig_security;
132
134
  chain.plugin(pluginName).use(RouterPlugin, [
133
135
  {
134
136
  HtmlBundlerPlugin,
135
- enableInlineRouteManifests: normalizedConfig.output.enableInlineRouteManifests,
136
- staticJsDir: (_normalizedConfig_output = normalizedConfig.output) === null || _normalizedConfig_output === void 0 ? void 0 : (_normalizedConfig_output_distPath = _normalizedConfig_output.distPath) === null || _normalizedConfig_output_distPath === void 0 ? void 0 : _normalizedConfig_output_distPath.js,
137
- disableFilenameHash: (_normalizedConfig_output1 = normalizedConfig.output) === null || _normalizedConfig_output1 === void 0 ? void 0 : _normalizedConfig_output1.disableFilenameHash,
137
+ enableInlineRouteManifests: inlineRouteManifests,
138
+ staticJsDir: (_normalizedConfig_output1 = normalizedConfig.output) === null || _normalizedConfig_output1 === void 0 ? void 0 : (_normalizedConfig_output_distPath = _normalizedConfig_output1.distPath) === null || _normalizedConfig_output_distPath === void 0 ? void 0 : _normalizedConfig_output_distPath.js,
139
+ disableFilenameHash: (_normalizedConfig_output2 = normalizedConfig.output) === null || _normalizedConfig_output2 === void 0 ? void 0 : _normalizedConfig_output2.disableFilenameHash,
138
140
  scriptLoading: (_normalizedConfig_html = normalizedConfig.html) === null || _normalizedConfig_html === void 0 ? void 0 : _normalizedConfig_html.scriptLoading,
139
141
  nonce: (_normalizedConfig_security = normalizedConfig.security) === null || _normalizedConfig_security === void 0 ? void 0 : _normalizedConfig_security.nonce
140
142
  }
@@ -13,7 +13,8 @@ function createDefaultConfig(appContext, bundler) {
13
13
  });
14
14
  var output = _object_spread_props(_object_spread({}, defaultBuilderConfig.output), {
15
15
  disableNodePolyfill: true,
16
- enableInlineRouteManifests: true
16
+ enableInlineRouteManifests: true,
17
+ disableInlineRouteManifests: false
17
18
  });
18
19
  var _obj;
19
20
  var source = _object_spread_props(_object_spread({}, defaultBuilderConfig.source), {
@@ -152,7 +152,8 @@ const routesForServer = ({ routes }) => {
152
152
  ${routesCode}
153
153
  `;
154
154
  };
155
- const createMatchReg = (keyword) => new RegExp(`("${keyword}":\\s)"([^,]+)"`, "g");
155
+ const createMatchReg = (keyword) => new RegExp(`("${keyword}":\\s)"([^
156
+ ]+)"`, "g");
156
157
  const fileSystemRoutes = async ({ routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, splitRouteChunks = true }) => {
157
158
  const components = [];
158
159
  const loadings = [];
@@ -226,18 +227,18 @@ const fileSystemRoutes = async ({ routes, ssrMode, nestedRoutesEntry, entryName,
226
227
  if (route._component) {
227
228
  if (splitRouteChunks) {
228
229
  if (route.isRoot) {
229
- lazyImport = `() => import('${route._component}').then(routeModule => {if(typeof document !== "undefined") window.${ROUTE_MODULES}["${route.id}"] = routeModule; return routeModule; }) `;
230
+ lazyImport = `() => import('${route._component}').then(routeModule => handleRouteModule(routeModule, "${route.id}")).catch(handleRouteModuleError) `;
230
231
  rootLayoutCode = `import RootLayout from '${route._component}'`;
231
232
  component = `RootLayout`;
232
233
  } else if (ssrMode === "string") {
233
- lazyImport = `() => import(/* webpackChunkName: "${route.id}" */ '${route._component}').then(routeModule => {if(typeof document !== "undefined") window.${ROUTE_MODULES}["${route.id}"] = routeModule; return routeModule; }) `;
234
+ lazyImport = `() => import(/* webpackChunkName: "${route.id}" */ '${route._component}').then(routeModule => handleRouteModule(routeModule, "${route.id}")).catch(handleRouteModuleError) `;
234
235
  component = `loadable(${lazyImport})`;
235
236
  } else {
236
- lazyImport = `() => import(/* webpackChunkName: "${route.id}" */ '${route._component}').then(routeModule => {if(typeof document !== "undefined") window.${ROUTE_MODULES}["${route.id}"] = routeModule; return routeModule; }) `;
237
+ lazyImport = `() => import(/* webpackChunkName: "${route.id}" */ '${route._component}').then(routeModule => handleRouteModule(routeModule, "${route.id}")).catch(handleRouteModuleError) `;
237
238
  component = `lazy(${lazyImport})`;
238
239
  }
239
240
  } else {
240
- lazyImport = `() => import(/* webpackMode: "eager" */ '${route._component}').then(routeModule => {if(typeof document !== "undefined") window.${ROUTE_MODULES}["${route.id}"] = routeModule; return routeModule; }) `;
241
+ lazyImport = `() => import(/* webpackMode: "eager" */ '${route._component}').then(routeModule => handleRouteModule(routeModule, "${route.id}")).catch(handleRouteModuleError) `;
241
242
  if (ssrMode === "string") {
242
243
  component = `loadable(${lazyImport})`;
243
244
  } else {
@@ -364,7 +365,7 @@ const fileSystemRoutes = async ({ routes, ssrMode, nestedRoutesEntry, entryName,
364
365
  await fs.ensureFile(loadersMapFile);
365
366
  await fs.writeJSON(loadersMapFile, loadersMap);
366
367
  const importRuntimeRouterCode = `
367
- import { createShouldRevalidate } from '@modern-js/runtime/router';
368
+ import { createShouldRevalidate, handleRouteModule, handleRouteModuleError} from '@modern-js/runtime/router';
368
369
  `;
369
370
  const routeModulesCode = `
370
371
  if(typeof document !== 'undefined'){
@@ -76,12 +76,14 @@ function applyRouterPlugin(chain, pluginName, options, HtmlBundlerPlugin) {
76
76
  const routerConfig = normalizedConfig === null || normalizedConfig === void 0 ? void 0 : (_normalizedConfig_runtime = normalizedConfig.runtime) === null || _normalizedConfig_runtime === void 0 ? void 0 : _normalizedConfig_runtime.router;
77
77
  const routerManifest = Boolean(routerConfig === null || routerConfig === void 0 ? void 0 : routerConfig.manifest);
78
78
  const workerSSR = Boolean((_normalizedConfig_deploy_worker = normalizedConfig.deploy.worker) === null || _normalizedConfig_deploy_worker === void 0 ? void 0 : _normalizedConfig_deploy_worker.ssr);
79
+ const { enableInlineRouteManifests, disableInlineRouteManifests } = normalizedConfig.output;
80
+ const inlineRouteManifests = disableInlineRouteManifests ? !disableInlineRouteManifests : enableInlineRouteManifests;
79
81
  if (existNestedRoutes || routerManifest || workerSSR) {
80
82
  var _normalizedConfig_output_distPath, _normalizedConfig_output, _normalizedConfig_output1, _normalizedConfig_html, _normalizedConfig_security;
81
83
  chain.plugin(pluginName).use(RouterPlugin, [
82
84
  {
83
85
  HtmlBundlerPlugin,
84
- enableInlineRouteManifests: normalizedConfig.output.enableInlineRouteManifests,
86
+ enableInlineRouteManifests: inlineRouteManifests,
85
87
  staticJsDir: (_normalizedConfig_output = normalizedConfig.output) === null || _normalizedConfig_output === void 0 ? void 0 : (_normalizedConfig_output_distPath = _normalizedConfig_output.distPath) === null || _normalizedConfig_output_distPath === void 0 ? void 0 : _normalizedConfig_output_distPath.js,
86
88
  disableFilenameHash: (_normalizedConfig_output1 = normalizedConfig.output) === null || _normalizedConfig_output1 === void 0 ? void 0 : _normalizedConfig_output1.disableFilenameHash,
87
89
  scriptLoading: (_normalizedConfig_html = normalizedConfig.html) === null || _normalizedConfig_html === void 0 ? void 0 : _normalizedConfig_html.scriptLoading,
@@ -12,7 +12,8 @@ function createDefaultConfig(appContext, bundler) {
12
12
  const output = {
13
13
  ...defaultBuilderConfig.output,
14
14
  disableNodePolyfill: true,
15
- enableInlineRouteManifests: true
15
+ enableInlineRouteManifests: true,
16
+ disableInlineRouteManifests: false
16
17
  };
17
18
  const source = {
18
19
  ...defaultBuilderConfig.source,
@@ -18,25 +18,25 @@ export declare const HTML_PARTIALS_FOLDER = "html";
18
18
  export declare const HTML_PARTIALS_EXTENSIONS: string[];
19
19
  export declare const FILE_SYSTEM_ROUTES_COMPONENTS_DIR = "internal_components";
20
20
  export declare const NESTED_ROUTE: {
21
- LAYOUT_FILE: string;
22
- LAYOUT_CONFIG_FILE: string;
23
- LAYOUT_LOADER_FILE: string;
24
- LAYOUT_DATA_FILE: string;
25
- LAYOUT_CLIENT_LOADER: string;
26
- PAGE_FILE: string;
27
- PAGE_CONFIG_FILE: string;
28
- PAGE_LOADER_FILE: string;
29
- PAGE_DATA_FILE: string;
30
- PAGE_CLIENT_LOADER: string;
31
- SPLATE_FILE: string;
32
- SPLATE_CONFIG_FILE: string;
33
- SPLATE_LOADER_FILE: string;
34
- SPLATE_DATA_FILE: string;
35
- SPLATE_CLIENT_DATA: string;
36
- LOADING_FILE: string;
37
- ERROR_FILE: string;
38
- LOADER_FILE: string;
21
+ LAYOUT_FILE: string;
22
+ LAYOUT_CONFIG_FILE: string;
23
+ LAYOUT_LOADER_FILE: string;
24
+ LAYOUT_DATA_FILE: string;
25
+ LAYOUT_CLIENT_LOADER: string;
26
+ PAGE_FILE: string;
27
+ PAGE_CONFIG_FILE: string;
28
+ PAGE_LOADER_FILE: string;
29
+ PAGE_DATA_FILE: string;
30
+ PAGE_CLIENT_LOADER: string;
31
+ SPLATE_FILE: string;
32
+ SPLATE_CONFIG_FILE: string;
33
+ SPLATE_LOADER_FILE: string;
34
+ SPLATE_DATA_FILE: string;
35
+ SPLATE_CLIENT_DATA: string;
36
+ LOADING_FILE: string;
37
+ ERROR_FILE: string;
38
+ LOADER_FILE: string;
39
39
  };
40
40
  export declare const APP_CONFIG_NAME = "config";
41
41
  export declare const APP_INIT_EXPORTED = "init";
42
- export declare const APP_INIT_IMPORTED = "appInit";
42
+ export declare const APP_INIT_IMPORTED = "appInit";
@@ -4,20 +4,13 @@ import { BundlerConfig } from '@modern-js/builder-shared';
4
4
  import { AppNormalizedConfig, AppTools, ImportStatement } from '../types';
5
5
  export declare const createImportStatements: (statements: ImportStatement[]) => string;
6
6
  export declare const generateCode: (appContext: IAppContext, config: AppNormalizedConfig<'shared'>, entrypoints: Entrypoint[], api: PluginAPI<AppTools<'shared'>>) => Promise<{
7
- importsStatemets: Map<string, ImportStatement[]>;
7
+ importsStatemets: Map<string, ImportStatement[]>;
8
8
  }>;
9
- export declare const generateIndexCode: ({
10
- appContext,
11
- api,
12
- entrypoints,
13
- config,
14
- importsStatemets,
15
- bundlerConfigs
16
- }: {
17
- appContext: IAppContext;
18
- api: PluginAPI<AppTools<'shared'>>;
19
- entrypoints: Entrypoint[];
20
- config: AppNormalizedConfig<'shared'>;
21
- importsStatemets: Map<string, ImportStatement[]>;
22
- bundlerConfigs?: BundlerConfig[] | undefined;
23
- }) => Promise<void>;
9
+ export declare const generateIndexCode: ({ appContext, api, entrypoints, config, importsStatemets, bundlerConfigs, }: {
10
+ appContext: IAppContext;
11
+ api: PluginAPI<AppTools<'shared'>>;
12
+ entrypoints: Entrypoint[];
13
+ config: AppNormalizedConfig<'shared'>;
14
+ importsStatemets: Map<string, ImportStatement[]>;
15
+ bundlerConfigs?: BundlerConfig[] | undefined;
16
+ }) => Promise<void>;
@@ -1,3 +1,3 @@
1
1
  import type { Entrypoint } from '@modern-js/types';
2
2
  import type { AppNormalizedConfig, IAppContext } from '../types';
3
- export declare const getBundleEntry: (appContext: IAppContext, config: AppNormalizedConfig<'shared'>) => Entrypoint[];
3
+ export declare const getBundleEntry: (appContext: IAppContext, config: AppNormalizedConfig<'shared'>) => Entrypoint[];
@@ -1,14 +1,8 @@
1
1
  import type { Entrypoint, NestedRouteForCli, PageRoute } from '@modern-js/types';
2
- export declare const getClientRoutes: ({
3
- entrypoint,
4
- srcDirectory,
5
- srcAlias,
6
- internalDirectory,
7
- internalDirAlias
8
- }: {
9
- entrypoint: Entrypoint;
10
- srcDirectory: string;
11
- srcAlias: string;
12
- internalDirectory: string;
13
- internalDirAlias: string;
14
- }) => (NestedRouteForCli | PageRoute)[];
2
+ export declare const getClientRoutes: ({ entrypoint, srcDirectory, srcAlias, internalDirectory, internalDirAlias, }: {
3
+ entrypoint: Entrypoint;
4
+ srcDirectory: string;
5
+ srcAlias: string;
6
+ internalDirectory: string;
7
+ internalDirAlias: string;
8
+ }) => (NestedRouteForCli | PageRoute)[];
@@ -1,15 +1,9 @@
1
1
  import type { Entrypoint, RouteLegacy } from '@modern-js/types';
2
2
  export type { RouteLegacy as Route };
3
- export declare const getClientRoutes: ({
4
- entrypoint,
5
- srcDirectory,
6
- srcAlias,
7
- internalDirectory,
8
- internalDirAlias
9
- }: {
10
- entrypoint: Entrypoint;
11
- srcDirectory: string;
12
- srcAlias: string;
13
- internalDirectory: string;
14
- internalDirAlias: string;
15
- }) => RouteLegacy[];
3
+ export declare const getClientRoutes: ({ entrypoint, srcDirectory, srcAlias, internalDirectory, internalDirAlias, }: {
4
+ entrypoint: Entrypoint;
5
+ srcDirectory: string;
6
+ srcAlias: string;
7
+ internalDirectory: string;
8
+ internalDirAlias: string;
9
+ }) => RouteLegacy[];
@@ -1,2 +1,2 @@
1
1
  export { getClientRoutes } from './getRoutes';
2
- export { getClientRoutes as getClientRoutesLegacy } from './getRoutesLegacy';
2
+ export { getClientRoutes as getClientRoutesLegacy } from './getRoutesLegacy';
@@ -2,4 +2,4 @@ declare const debug: import("@modern-js/utils/compiled/debug").Debugger;
2
2
  export { debug };
3
3
  export declare const findLayout: (dir: string) => string | false;
4
4
  export declare const getRouteWeight: (route: string) => number;
5
- export declare const shouldSkip: (file: string) => boolean;
5
+ export declare const shouldSkip: (file: string) => boolean;
@@ -1,4 +1,4 @@
1
1
  import type { Entrypoint } from '@modern-js/types';
2
2
  import type { AppNormalizedConfig, IAppContext } from '../types';
3
3
  export type { Entrypoint };
4
- export declare const getFileSystemEntry: (appContext: IAppContext, config: AppNormalizedConfig<'shared'>) => Entrypoint[];
4
+ export declare const getFileSystemEntry: (appContext: IAppContext, config: AppNormalizedConfig<'shared'>) => Entrypoint[];
@@ -1,9 +1,6 @@
1
1
  import type { Entrypoint, HtmlTemplates } from '@modern-js/types';
2
2
  import type { AppNormalizedConfig, AppTools, IAppContext, PluginAPI } from '../types';
3
- export declare const getHtmlTemplate: (entrypoints: Entrypoint[], api: PluginAPI<AppTools<'shared'>>, {
4
- appContext,
5
- config
6
- }: {
7
- appContext: IAppContext;
8
- config: AppNormalizedConfig<'shared'>;
9
- }) => Promise<HtmlTemplates>;
3
+ export declare const getHtmlTemplate: (entrypoints: Entrypoint[], api: PluginAPI<AppTools<'shared'>>, { appContext, config, }: {
4
+ appContext: IAppContext;
5
+ config: AppNormalizedConfig<'shared'>;
6
+ }) => Promise<HtmlTemplates>;
@@ -1,10 +1,7 @@
1
1
  import type { IAppContext } from '@modern-js/core';
2
2
  import type { Entrypoint, ServerRoute } from '@modern-js/types';
3
3
  import type { AppNormalizedConfig } from '../types';
4
- export declare const getServerRoutes: (entrypoints: Entrypoint[], {
5
- appContext,
6
- config
7
- }: {
8
- appContext: IAppContext;
9
- config: AppNormalizedConfig<'shared'>;
10
- }) => ServerRoute[];
4
+ export declare const getServerRoutes: (entrypoints: Entrypoint[], { appContext, config, }: {
5
+ appContext: IAppContext;
6
+ config: AppNormalizedConfig<'shared'>;
7
+ }) => ServerRoute[];
@@ -1,8 +1,6 @@
1
1
  import type { CliPlugin } from '@modern-js/core';
2
2
  import { AppTools } from '../types';
3
- declare const _default: ({
4
- bundler
5
- }: {
6
- bundler: 'webpack' | 'rspack';
3
+ declare const _default: ({ bundler, }: {
4
+ bundler: 'webpack' | 'rspack';
7
5
  }) => CliPlugin<AppTools<'shared'>>;
8
- export default _default;
6
+ export default _default;
@@ -1 +1 @@
1
- export declare const isDefaultExportFunction: (file: string | false) => boolean;
1
+ export declare const isDefaultExportFunction: (file: string | false) => boolean;
@@ -1 +1 @@
1
- export declare function makeLegalIdentifier(str: string): string;
1
+ export declare function makeLegalIdentifier(str: string): string;
@@ -2,6 +2,6 @@ import type { NestedRouteForCli } from '@modern-js/types';
2
2
  export declare const getRouteId: (componentPath: string, routesDir: string, entryName: string, isMainEntry: boolean) => string;
3
3
  export declare const optimizeRoute: (routeTree: NestedRouteForCli) => NestedRouteForCli[];
4
4
  export declare const walk: (dirname: string, rootDir: string, alias: {
5
- name: string;
6
- basename: string;
7
- }, entryName: string, isMainEntry: boolean, oldVersion: boolean) => Promise<NestedRouteForCli | NestedRouteForCli[] | null>;
5
+ name: string;
6
+ basename: string;
7
+ }, entryName: string, isMainEntry: boolean, oldVersion: boolean) => Promise<NestedRouteForCli | NestedRouteForCli[] | null>;
@@ -1,48 +1,30 @@
1
1
  import type { Entrypoint, NestedRouteForCli, PageRoute, RouteLegacy, SSRMode } from '@modern-js/types';
2
2
  import type { AppNormalizedConfig, IAppContext, RuntimePlugin } from '../types';
3
- export declare const index: ({
4
- mountId,
5
- imports,
6
- renderFunction,
7
- exportStatement
8
- }: {
9
- mountId: string;
10
- imports: string;
11
- exportStatement: string;
12
- renderFunction: string;
3
+ export declare const index: ({ mountId, imports, renderFunction, exportStatement, }: {
4
+ mountId: string;
5
+ imports: string;
6
+ exportStatement: string;
7
+ renderFunction: string;
13
8
  }) => string;
14
- export declare const renderFunction: ({
15
- plugins,
16
- customBootstrap,
17
- fileSystemRoutes
18
- }: {
19
- plugins: RuntimePlugin[];
20
- customBootstrap?: string | false | undefined;
21
- fileSystemRoutes: Entrypoint['fileSystemRoutes'];
9
+ export declare const renderFunction: ({ plugins, customBootstrap, fileSystemRoutes, }: {
10
+ plugins: RuntimePlugin[];
11
+ customBootstrap?: string | false | undefined;
12
+ fileSystemRoutes: Entrypoint['fileSystemRoutes'];
22
13
  }) => string;
23
14
  export declare const html: (partials: {
24
- top: string[];
25
- head: string[];
26
- body: string[];
15
+ top: string[];
16
+ head: string[];
17
+ body: string[];
27
18
  }) => string;
28
- export declare const routesForServer: ({
29
- routes
30
- }: {
31
- routes: (NestedRouteForCli | PageRoute)[];
19
+ export declare const routesForServer: ({ routes, }: {
20
+ routes: (NestedRouteForCli | PageRoute)[];
32
21
  }) => string;
33
- export declare const fileSystemRoutes: ({
34
- routes,
35
- ssrMode,
36
- nestedRoutesEntry,
37
- entryName,
38
- internalDirectory,
39
- splitRouteChunks
40
- }: {
41
- routes: RouteLegacy[] | (NestedRouteForCli | PageRoute)[];
42
- ssrMode?: SSRMode | undefined;
43
- nestedRoutesEntry?: string | undefined;
44
- entryName: string;
45
- internalDirectory: string;
46
- splitRouteChunks?: boolean | undefined;
22
+ export declare const fileSystemRoutes: ({ routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, splitRouteChunks, }: {
23
+ routes: RouteLegacy[] | (NestedRouteForCli | PageRoute)[];
24
+ ssrMode?: SSRMode | undefined;
25
+ nestedRoutesEntry?: string | undefined;
26
+ entryName: string;
27
+ internalDirectory: string;
28
+ splitRouteChunks?: boolean | undefined;
47
29
  }) => Promise<string>;
48
- export declare function ssrLoaderCombinedModule(entrypoints: Entrypoint[], entrypoint: Entrypoint, config: AppNormalizedConfig<'shared'>, appContext: IAppContext): string | null;
30
+ export declare function ssrLoaderCombinedModule(entrypoints: Entrypoint[], entrypoint: Entrypoint, config: AppNormalizedConfig<'shared'>, appContext: IAppContext): string | null;
@@ -1,31 +1,22 @@
1
1
  import type { Entrypoint } from '@modern-js/types';
2
2
  import type { ImportStatement } from '../types';
3
3
  export declare const walkDirectory: (dir: string) => string[];
4
- export declare const getDefaultImports: ({
5
- entrypoint,
6
- srcDirectory,
7
- internalSrcAlias,
8
- internalDirAlias,
9
- internalDirectory
10
- }: {
11
- entrypoint: Entrypoint;
12
- srcDirectory: string;
13
- internalSrcAlias: string;
14
- internalDirAlias: string;
15
- internalDirectory: string;
4
+ export declare const getDefaultImports: ({ entrypoint, srcDirectory, internalSrcAlias, internalDirAlias, internalDirectory, }: {
5
+ entrypoint: Entrypoint;
6
+ srcDirectory: string;
7
+ internalSrcAlias: string;
8
+ internalDirAlias: string;
9
+ internalDirectory: string;
16
10
  }) => ImportStatement[];
17
11
  export declare const isPageComponentFile: (filePath: string) => boolean;
18
12
  export declare const replaceWithAlias: (base: string, filePath: string, alias: string) => string;
19
- export declare const parseModule: ({
20
- source,
21
- filename
22
- }: {
23
- source: string;
24
- filename: string;
13
+ export declare const parseModule: ({ source, filename, }: {
14
+ source: string;
15
+ filename: string;
25
16
  }) => Promise<readonly [imports: readonly import("es-module-lexer").ImportSpecifier[], exports: readonly import("es-module-lexer").ExportSpecifier[], facade: boolean]>;
26
17
  export declare const hasLoader: (filename: string, source?: string) => Promise<boolean>;
27
18
  export declare const hasAction: (filename: string, source?: string) => Promise<boolean>;
28
19
  export declare const getServerLoadersFile: (internalDirectory: string, entryName: string) => string;
29
20
  export declare const getServerCombinedModueFile: (internalDirectory: string, entryName: string) => string;
30
21
  export declare const checkIsBuildCommands: () => boolean;
31
- export declare const isSubDirOrEqual: (parent: string, child: string) => boolean;
22
+ export declare const isSubDirOrEqual: (parent: string, child: string) => boolean;
@@ -1,4 +1,4 @@
1
1
  import { BuilderPlugin } from '@modern-js/builder-shared';
2
2
  import { BuilderPluginAPI } from '@modern-js/builder-rspack-provider';
3
3
  import { BuilderOptions } from '../shared';
4
- export declare const builderPluginAdpaterCopy: (options: BuilderOptions<'rspack'>) => BuilderPlugin<BuilderPluginAPI>;
4
+ export declare const builderPluginAdpaterCopy: (options: BuilderOptions<'rspack'>) => BuilderPlugin<BuilderPluginAPI>;
@@ -1,2 +1,2 @@
1
1
  import { BuilderOptions } from '../shared';
2
- export declare function createRspackBuilderForModern(options: BuilderOptions<'rspack'>): Promise<import("@modern-js/builder-shared").BuilderInstance<import("@modern-js/builder-shared").BuilderProvider>>;
2
+ export declare function createRspackBuilderForModern(options: BuilderOptions<'rspack'>): Promise<import("@modern-js/builder-shared").BuilderInstance<import("@modern-js/builder-shared").BuilderProvider>>;
@@ -4,4 +4,4 @@ import { BuilderOptions } from '../shared';
4
4
  /**
5
5
  * Provides default configuration consistent with modern.js v1
6
6
  */
7
- export declare const builderPluginAdapterModern: (options: BuilderOptions<'webpack'>) => BuilderPlugin<BuilderPluginAPI>;
7
+ export declare const builderPluginAdapterModern: (options: BuilderOptions<'webpack'>) => BuilderPlugin<BuilderPluginAPI>;
@@ -2,25 +2,25 @@
2
2
  import { WebpackChain } from '@modern-js/builder-webpack-provider';
3
3
  import type { AppNormalizedConfig, Bundler, IAppContext } from '../../types';
4
4
  export declare function createPublicPattern(appContext: IAppContext, config: AppNormalizedConfig, chain: WebpackChain): {
5
- info: (file: {
6
- sourceFilename: string;
7
- }) => {
8
- minimized: boolean;
9
- };
10
- from: string;
11
- to: string;
12
- context: string;
13
- noErrorOnMissing: boolean;
14
- transform: (content: Buffer, absoluteFrom: string) => string | Buffer;
5
+ info: (file: {
6
+ sourceFilename: string;
7
+ }) => {
8
+ minimized: boolean;
9
+ };
10
+ from: string;
11
+ to: string;
12
+ context: string;
13
+ noErrorOnMissing: boolean;
14
+ transform: (content: Buffer, absoluteFrom: string) => string | Buffer;
15
15
  };
16
16
  export declare function createUploadPattern<B extends Bundler>(appContext: IAppContext, config: AppNormalizedConfig<B>): {
17
- info: (file: {
18
- sourceFilename: string;
19
- }) => {
20
- minimized: boolean;
21
- };
22
- from: string;
23
- to: string;
24
- context: string;
25
- noErrorOnMissing: boolean;
26
- };
17
+ info: (file: {
18
+ sourceFilename: string;
19
+ }) => {
20
+ minimized: boolean;
21
+ };
22
+ from: string;
23
+ to: string;
24
+ context: string;
25
+ noErrorOnMissing: boolean;
26
+ };