@modern-js/app-tools 2.5.0-alpha.1 → 2.5.1-alpha.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.
Files changed (138) hide show
  1. package/dist/cjs/analyze/generateCode.js +15 -23
  2. package/dist/cjs/analyze/getBundleEntry.js +1 -1
  3. package/dist/cjs/analyze/index.js +0 -4
  4. package/dist/cjs/analyze/templates.js +1 -6
  5. package/dist/cjs/builder/builder-webpack/builderPlugins/compatModern.js +3 -3
  6. package/dist/cjs/builder/builder-webpack/index.js +5 -11
  7. package/dist/cjs/builder/generator/getBuilderTargets.js +1 -1
  8. package/dist/cjs/commands/dev.js +14 -6
  9. package/dist/cjs/config/legacy/createToolsConfig.js +4 -1
  10. package/dist/esm/analyze/generateCode.js +28 -40
  11. package/dist/esm/analyze/getBundleEntry.js +2 -2
  12. package/dist/esm/analyze/index.js +0 -1
  13. package/dist/esm/analyze/templates.js +2 -3
  14. package/dist/esm/builder/builder-webpack/builderPlugins/compatModern.js +2 -2
  15. package/dist/esm/builder/builder-webpack/index.js +7 -11
  16. package/dist/esm/builder/generator/getBuilderTargets.js +1 -1
  17. package/dist/esm/commands/dev.js +8 -3
  18. package/dist/esm/config/legacy/createToolsConfig.js +4 -1
  19. package/dist/esm-node/analyze/generateCode.js +16 -24
  20. package/dist/esm-node/analyze/getBundleEntry.js +3 -2
  21. package/dist/esm-node/analyze/index.js +0 -4
  22. package/dist/esm-node/analyze/templates.js +1 -6
  23. package/dist/esm-node/builder/builder-webpack/builderPlugins/compatModern.js +2 -2
  24. package/dist/esm-node/builder/builder-webpack/index.js +6 -12
  25. package/dist/esm-node/builder/generator/getBuilderTargets.js +1 -1
  26. package/dist/esm-node/commands/dev.js +14 -6
  27. package/dist/esm-node/config/legacy/createToolsConfig.js +4 -1
  28. package/dist/js/modern/analyze/constants.js +1 -3
  29. package/dist/js/modern/analyze/index.js +48 -45
  30. package/dist/js/modern/analyze/nestedRoutes.js +2 -22
  31. package/dist/js/modern/analyze/templates.js +9 -2
  32. package/dist/js/modern/builder/{shared/builderPlugins/adapterModern.js → builderPlugins/compatModern.js} +111 -81
  33. package/dist/js/modern/builder/index.js +133 -13
  34. package/dist/js/modern/builder/loaders/routerLoader.js +17 -0
  35. package/dist/js/modern/builder/{shared/loaders → loaders}/serverModuleLoader.js +0 -0
  36. package/dist/js/modern/builder/{shared/createCopyPattern.js → share.js} +0 -0
  37. package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +30 -0
  38. package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +37 -0
  39. package/dist/js/modern/builder/{builder-webpack/webpackPlugins/RouterPlugin.js → webpackPlugins/routerPlugin.js} +1 -1
  40. package/dist/js/modern/config/default.js +2 -2
  41. package/dist/js/modern/config/index.js +8 -3
  42. package/dist/js/modern/config/{legacy → initial}/createHtmlConfig.js +0 -0
  43. package/dist/js/modern/config/{legacy → initial}/createOutputConfig.js +0 -0
  44. package/dist/js/modern/config/{legacy → initial}/createSourceConfig.js +0 -0
  45. package/dist/js/modern/config/{legacy → initial}/createToolsConfig.js +0 -0
  46. package/dist/js/modern/config/initial/index.js +16 -0
  47. package/dist/js/modern/config/{initialize → initial}/inits.js +2 -4
  48. package/dist/js/modern/config/{legacy/index.js → initial/transformNormalizedConfig.js} +0 -4
  49. package/dist/js/modern/index.js +8 -18
  50. package/dist/js/modern/initialize/index.js +28 -36
  51. package/dist/js/modern/locale/zh.js +1 -1
  52. package/dist/js/node/analyze/constants.js +1 -3
  53. package/dist/js/node/analyze/index.js +49 -46
  54. package/dist/js/node/analyze/nestedRoutes.js +2 -22
  55. package/dist/js/node/analyze/templates.js +9 -2
  56. package/dist/js/node/builder/{shared/builderPlugins/adapterModern.js → builderPlugins/compatModern.js} +115 -86
  57. package/dist/js/node/builder/index.js +123 -14
  58. package/dist/js/node/builder/{generator/getBuilderTargets.js → loaders/routerLoader.js} +16 -13
  59. package/dist/js/node/builder/{shared/loaders → loaders}/serverModuleLoader.js +0 -0
  60. package/dist/js/node/builder/{shared/createCopyPattern.js → share.js} +3 -3
  61. package/dist/js/node/builder/{shared/bundlerPlugins/HtmlAsyncChunkPlugin.js → webpackPlugins/htmlAsyncChunkPlugin.js} +20 -17
  62. package/dist/js/node/builder/{shared/bundlerPlugins/HtmlBottomTemplate.js → webpackPlugins/htmlBottomTemplate.js} +24 -21
  63. package/dist/js/node/builder/{builder-webpack/webpackPlugins/RouterPlugin.js → webpackPlugins/routerPlugin.js} +5 -7
  64. package/dist/js/node/config/default.js +2 -2
  65. package/dist/js/node/config/index.js +19 -4
  66. package/dist/js/node/config/{legacy → initial}/createHtmlConfig.js +0 -0
  67. package/dist/js/node/config/{legacy → initial}/createOutputConfig.js +0 -0
  68. package/dist/js/node/config/{legacy → initial}/createSourceConfig.js +0 -0
  69. package/dist/js/node/config/{legacy → initial}/createToolsConfig.js +0 -0
  70. package/dist/js/node/config/{initialize → initial}/index.js +16 -10
  71. package/dist/js/node/config/{initialize → initial}/inits.js +2 -4
  72. package/dist/js/node/config/{legacy/index.js → initial/transformNormalizedConfig.js} +3 -8
  73. package/dist/js/node/index.js +8 -18
  74. package/dist/js/node/initialize/index.js +28 -35
  75. package/dist/js/node/locale/zh.js +1 -1
  76. package/dist/js/treeshaking/analyze/constants.js +1 -3
  77. package/dist/js/treeshaking/analyze/index.js +130 -135
  78. package/dist/js/treeshaking/analyze/nestedRoutes.js +1 -17
  79. package/dist/js/treeshaking/analyze/templates.js +7 -3
  80. package/dist/js/treeshaking/builder/{shared/builderPlugins/adapterModern.js → builderPlugins/compatModern.js} +156 -103
  81. package/dist/js/treeshaking/builder/index.js +228 -29
  82. package/dist/js/treeshaking/builder/loaders/routerLoader.js +13 -0
  83. package/dist/js/treeshaking/builder/{shared/loaders → loaders}/serverModuleLoader.js +0 -0
  84. package/dist/js/treeshaking/builder/{shared/createCopyPattern.js → share.js} +0 -0
  85. package/dist/js/treeshaking/builder/{shared/bundlerPlugins/HtmlAsyncChunkPlugin.js → webpackPlugins/htmlAsyncChunkPlugin.js} +0 -0
  86. package/dist/js/treeshaking/builder/{shared/bundlerPlugins/HtmlBottomTemplate.js → webpackPlugins/htmlBottomTemplate.js} +0 -0
  87. package/dist/js/treeshaking/builder/{builder-webpack/webpackPlugins/RouterPlugin.js → webpackPlugins/routerPlugin.js} +1 -1
  88. package/dist/js/treeshaking/config/default.js +2 -2
  89. package/dist/js/treeshaking/config/index.js +3 -3
  90. package/dist/js/treeshaking/config/{legacy → initial}/createHtmlConfig.js +0 -0
  91. package/dist/js/treeshaking/config/{legacy → initial}/createOutputConfig.js +0 -0
  92. package/dist/js/treeshaking/config/{legacy → initial}/createSourceConfig.js +0 -0
  93. package/dist/js/treeshaking/config/{legacy → initial}/createToolsConfig.js +0 -0
  94. package/dist/js/treeshaking/config/initial/index.js +12 -0
  95. package/dist/js/treeshaking/config/{initialize → initial}/inits.js +2 -4
  96. package/dist/js/treeshaking/config/{legacy/index.js → initial/transformNormalizedConfig.js} +1 -4
  97. package/dist/js/treeshaking/index.js +12 -19
  98. package/dist/js/treeshaking/initialize/index.js +26 -34
  99. package/dist/js/treeshaking/locale/zh.js +1 -1
  100. package/dist/types/analyze/templates.d.ts +1 -3
  101. package/dist/types/builder/builder-webpack/builderPlugins/compatModern.d.ts +1 -7
  102. package/package.json +14 -14
  103. package/dist/js/modern/builder/builder-rspack/index.js +0 -8
  104. package/dist/js/modern/builder/builder-webpack/builderPlugins/compatModern.js +0 -41
  105. package/dist/js/modern/builder/builder-webpack/index.js +0 -93
  106. package/dist/js/modern/builder/builder-webpack/webpackPlugins/index.js +0 -1
  107. package/dist/js/modern/builder/generator/createBuilderOptions.js +0 -24
  108. package/dist/js/modern/builder/generator/createBuilderProviderConfig.js +0 -39
  109. package/dist/js/modern/builder/generator/getBuilderTargets.js +0 -12
  110. package/dist/js/modern/builder/generator/index.js +0 -53
  111. package/dist/js/modern/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -27
  112. package/dist/js/modern/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -34
  113. package/dist/js/modern/builder/shared/index.js +0 -3
  114. package/dist/js/modern/builder/shared/types.js +0 -0
  115. package/dist/js/modern/config/initialize/index.js +0 -12
  116. package/dist/js/modern/types/utils.js +0 -0
  117. package/dist/js/node/builder/builder-rspack/index.js +0 -31
  118. package/dist/js/node/builder/builder-webpack/builderPlugins/compatModern.js +0 -64
  119. package/dist/js/node/builder/builder-webpack/index.js +0 -118
  120. package/dist/js/node/builder/builder-webpack/webpackPlugins/index.js +0 -17
  121. package/dist/js/node/builder/generator/createBuilderOptions.js +0 -47
  122. package/dist/js/node/builder/generator/createBuilderProviderConfig.js +0 -60
  123. package/dist/js/node/builder/generator/index.js +0 -82
  124. package/dist/js/node/builder/shared/index.js +0 -19
  125. package/dist/js/node/builder/shared/types.js +0 -15
  126. package/dist/js/node/types/utils.js +0 -15
  127. package/dist/js/treeshaking/builder/builder-rspack/index.js +0 -6
  128. package/dist/js/treeshaking/builder/builder-webpack/builderPlugins/compatModern.js +0 -64
  129. package/dist/js/treeshaking/builder/builder-webpack/index.js +0 -301
  130. package/dist/js/treeshaking/builder/builder-webpack/webpackPlugins/index.js +0 -1
  131. package/dist/js/treeshaking/builder/generator/createBuilderOptions.js +0 -41
  132. package/dist/js/treeshaking/builder/generator/createBuilderProviderConfig.js +0 -70
  133. package/dist/js/treeshaking/builder/generator/getBuilderTargets.js +0 -12
  134. package/dist/js/treeshaking/builder/generator/index.js +0 -199
  135. package/dist/js/treeshaking/builder/shared/index.js +0 -3
  136. package/dist/js/treeshaking/builder/shared/types.js +0 -1
  137. package/dist/js/treeshaking/config/initialize/index.js +0 -10
  138. package/dist/js/treeshaking/types/utils.js +0 -1
@@ -59,16 +59,15 @@ __export(initialize_exports, {
59
59
  module.exports = __toCommonJS(initialize_exports);
60
60
  var import_utils = require("@modern-js/utils");
61
61
  var import_schema = require("../schema");
62
+ var import_transformNormalizedConfig = require("../config/initial/transformNormalizedConfig");
62
63
  var import_config = require("../config");
63
- var initialize_default = ({
64
- bundler
65
- }) => ({
64
+ var initialize_default = () => ({
66
65
  name: "@modern-js/plugin-initialize",
67
66
  setup(api) {
68
67
  const config = () => {
69
68
  const appContext = api.useAppContext();
70
69
  const userConfig = api.useConfigContext();
71
- return (0, import_config.checkIsLegacyConfig)(userConfig) ? (0, import_config.createLegacyDefaultConfig)(appContext) : (0, import_config.createDefaultConfig)(appContext, bundler);
70
+ return (0, import_config.checkIsLegacyConfig)(userConfig) ? (0, import_config.createLegacyDefaultConfig)(appContext) : (0, import_config.createDefaultConfig)(appContext);
72
71
  };
73
72
  const validateSchema = () => {
74
73
  const userConfig = api.useConfigContext();
@@ -92,42 +91,36 @@ var initialize_default = ({
92
91
  )
93
92
  });
94
93
  api.setAppContext(appContext);
95
- const normalizedConfig = (0, import_config.checkIsLegacyConfig)(resolved) ? (0, import_config.transformNormalizedConfig)(resolved) : resolved;
96
- resolved._raw = userConfig;
97
- resolved.server = __spreadProps(__spreadValues({}, normalizedConfig.server || {}), {
98
- port
99
- });
100
- resolved.autoLoadPlugins = normalizedConfig.autoLoadPlugins || false;
101
- stabilizeConfig(resolved, normalizedConfig, [
102
- "source",
103
- "bff",
104
- "dev",
105
- "html",
106
- "output",
107
- "tools",
108
- "testing",
109
- "plugins",
110
- "builderPlugins",
111
- "runtime",
112
- "runtimeByEntries",
113
- "deploy",
114
- "performance"
115
- ]);
116
- if (bundler === "webpack") {
117
- resolved.security = normalizedConfig.security || {};
118
- resolved.experiments = normalizedConfig.experiments;
119
- }
120
- return { resolved };
94
+ const normalizedConfig = (0, import_config.checkIsLegacyConfig)(resolved) ? (0, import_transformNormalizedConfig.transformNormalizedConfig)(resolved) : resolved;
95
+ return {
96
+ resolved: {
97
+ _raw: userConfig,
98
+ source: normalizedConfig.source || {},
99
+ server: __spreadProps(__spreadValues({}, normalizedConfig.server || {}), {
100
+ port
101
+ }),
102
+ bff: normalizedConfig.bff || {},
103
+ dev: normalizedConfig.dev || {},
104
+ html: normalizedConfig.html || {},
105
+ output: normalizedConfig.output || {},
106
+ security: normalizedConfig.security || {},
107
+ tools: normalizedConfig.tools || {},
108
+ testing: normalizedConfig.testing || {},
109
+ plugins: normalizedConfig.plugins || [],
110
+ builderPlugins: normalizedConfig.builderPlugins || [],
111
+ runtime: normalizedConfig.runtime || {},
112
+ runtimeByEntries: normalizedConfig.runtimeByEntries || {},
113
+ deploy: normalizedConfig.deploy || {},
114
+ performance: normalizedConfig.performance || {},
115
+ experiments: normalizedConfig.experiments || {},
116
+ autoLoadPlugins: normalizedConfig.autoLoadPlugins || false
117
+ }
118
+ };
121
119
  });
122
120
  }
123
121
  };
124
122
  }
125
123
  });
126
- function stabilizeConfig(resolve, config, keys) {
127
- keys.forEach((key) => {
128
- resolve[key] = config[key] || {};
129
- });
130
- }
131
124
  function getServerPort(config) {
132
125
  return __async(this, null, function* () {
133
126
  const prodPort = config.server.port || 8080;
@@ -39,7 +39,7 @@ const ZH_LOCALE = {
39
39
  serve: { describe: "应用启动命令" },
40
40
  deploy: { describe: "部署应用命令" },
41
41
  new: {
42
- describe: "Web App 项目中执行生成器",
42
+ describe: "MWA 项目中执行生成器",
43
43
  debug: "开启 Debug 模式,打印调试日志信息",
44
44
  config: "生成器运行默认配置(JSON 字符串)",
45
45
  distTag: "生成器使用特殊的 npm Tag 版本",
@@ -32,9 +32,7 @@ var NESTED_ROUTE = {
32
32
  PAGE_LOADER_FILE: "page.loader",
33
33
  LOADING_FILE: "loading",
34
34
  ERROR_FILE: "error",
35
- LOADER_FILE: "loader",
36
- SPLATE_FILE: "$",
37
- SPLATE_LOADER_FILE: "$.loader"
35
+ LOADER_FILE: "loader"
38
36
  };
39
37
  var APP_CONFIG_NAME = "config";
40
38
  var APP_INIT_EXPORTED = "init";
@@ -223,17 +223,16 @@ var __generator = this && this.__generator || function(thisArg, body) {
223
223
  import * as path from "path";
224
224
  import { createDebugger, findExists, fs, getEntryOptions, isApiOnly, minimist, getCommand, isDevCommand } from "@modern-js/utils";
225
225
  import { cloneDeep } from "@modern-js/utils/lodash";
226
+ import { createBuilderForModern } from "../builder";
226
227
  import { printInstructions } from "../utils/printInstructions";
227
228
  import { generateRoutes } from "../utils/routes";
228
229
  import { emitResolvedConfig } from "../utils/config";
229
230
  import { getSelectedEntries } from "../utils/getSelectedEntries";
230
231
  import { initialNormalizedConfig } from "../config";
231
- import { createBuilderGenerator } from "../builder";
232
232
  import { getServerLoadersFile, isPageComponentFile, parseModule, replaceWithAlias } from "./utils";
233
233
  import { APP_CONFIG_NAME, APP_INIT_EXPORTED, APP_INIT_IMPORTED } from "./constants";
234
234
  var debug = createDebugger("plugin-analyze");
235
- var analyze_default = function(param) {
236
- var bundler = param.bundler;
235
+ var analyze_default = function() {
237
236
  return {
238
237
  name: "@modern-js/plugin-analyze",
239
238
  setup: function(api) {
@@ -243,7 +242,7 @@ var analyze_default = function(param) {
243
242
  return {
244
243
  prepare: function prepare() {
245
244
  return _asyncToGenerator(function() {
246
- var ref, appContext, resolvedConfig, hookRunners, apiOnly, ref1, routes2, ref2, getBundleEntry, getServerRoutes, generateCode, getHtmlTemplate, entrypoints, initialRoutes, routes, htmlTemplates, checkedEntries, entry, command, buildCommands, normalizedConfig, createBuilderForModern, builder;
245
+ var ref, appContext, resolvedConfig, hookRunners, apiOnly, ref1, routes2, ref2, getBundleEntry, getServerRoutes, generateCode, getHtmlTemplate, entrypoints, initialRoutes, routes, htmlTemplates, checkedEntries, entry, command, buildCommands, normalizedConfig, builder;
247
246
  return __generator(this, function(_state) {
248
247
  switch(_state.label){
249
248
  case 0:
@@ -385,153 +384,149 @@ var analyze_default = function(param) {
385
384
  ];
386
385
  if (!buildCommands.includes(command)) return [
387
386
  3,
388
- 14
387
+ 13
389
388
  ];
390
389
  normalizedConfig = api.useResolvedConfigContext();
391
- return [
392
- 4,
393
- createBuilderGenerator(bundler)
394
- ];
395
- case 12:
396
- createBuilderForModern = _state.sent();
397
390
  return [
398
391
  4,
399
392
  createBuilderForModern({
400
393
  normalizedConfig: normalizedConfig,
401
394
  appContext: appContext,
402
- onBeforeBuild: function onBeforeBuild(param) {
403
- var bundlerConfigs = param.bundlerConfigs;
404
- return _asyncToGenerator(function() {
405
- var hookRunners2;
406
- return __generator(this, function(_state) {
407
- switch(_state.label){
408
- case 0:
409
- hookRunners2 = api.useHookRunners();
410
- return [
411
- 4,
412
- generateRoutes(appContext)
413
- ];
414
- case 1:
415
- _state.sent();
416
- return [
417
- 4,
418
- hookRunners2.beforeBuild({
419
- bundlerConfigs: bundlerConfigs
420
- })
421
- ];
422
- case 2:
423
- _state.sent();
424
- return [
425
- 2
426
- ];
427
- }
428
- });
429
- })();
430
- },
431
- onAfterBuild: function onAfterBuild(param) {
432
- var stats = param.stats;
433
- return _asyncToGenerator(function() {
434
- var hookRunners2;
435
- return __generator(this, function(_state) {
436
- switch(_state.label){
437
- case 0:
438
- hookRunners2 = api.useHookRunners();
439
- return [
440
- 4,
441
- hookRunners2.afterBuild({
442
- stats: stats
443
- })
444
- ];
445
- case 1:
446
- _state.sent();
447
- return [
448
- 4,
449
- emitResolvedConfig(appContext.appDirectory, normalizedConfig)
450
- ];
451
- case 2:
452
- _state.sent();
453
- return [
454
- 2
455
- ];
456
- }
457
- });
458
- })();
459
- },
460
- onDevCompileDone: function onDevCompileDone(param) {
461
- var isFirstCompile = param.isFirstCompile;
462
- return _asyncToGenerator(function() {
463
- var hookRunners2;
464
- return __generator(this, function(_state) {
465
- hookRunners2 = api.useHookRunners();
466
- if (process.stdout.isTTY || isFirstCompile) {
467
- hookRunners2.afterDev();
468
- if (isFirstCompile) {
469
- printInstructions(hookRunners2, appContext, normalizedConfig);
395
+ compatPluginConfig: {
396
+ onBeforeBuild: function onBeforeBuild(param) {
397
+ var bundlerConfigs = param.bundlerConfigs;
398
+ return _asyncToGenerator(function() {
399
+ var hookRunners2;
400
+ return __generator(this, function(_state) {
401
+ switch(_state.label){
402
+ case 0:
403
+ hookRunners2 = api.useHookRunners();
404
+ return [
405
+ 4,
406
+ generateRoutes(appContext)
407
+ ];
408
+ case 1:
409
+ _state.sent();
410
+ return [
411
+ 4,
412
+ hookRunners2.beforeBuild({
413
+ bundlerConfigs: bundlerConfigs
414
+ })
415
+ ];
416
+ case 2:
417
+ _state.sent();
418
+ return [
419
+ 2
420
+ ];
421
+ }
422
+ });
423
+ })();
424
+ },
425
+ onAfterBuild: function onAfterBuild(param) {
426
+ var stats = param.stats;
427
+ return _asyncToGenerator(function() {
428
+ var hookRunners2;
429
+ return __generator(this, function(_state) {
430
+ switch(_state.label){
431
+ case 0:
432
+ hookRunners2 = api.useHookRunners();
433
+ return [
434
+ 4,
435
+ hookRunners2.afterBuild({
436
+ stats: stats
437
+ })
438
+ ];
439
+ case 1:
440
+ _state.sent();
441
+ return [
442
+ 4,
443
+ emitResolvedConfig(appContext.appDirectory, normalizedConfig)
444
+ ];
445
+ case 2:
446
+ _state.sent();
447
+ return [
448
+ 2
449
+ ];
450
+ }
451
+ });
452
+ })();
453
+ },
454
+ onDevCompileDone: function onDevCompileDone(param) {
455
+ var isFirstCompile = param.isFirstCompile;
456
+ return _asyncToGenerator(function() {
457
+ var hookRunners2;
458
+ return __generator(this, function(_state) {
459
+ hookRunners2 = api.useHookRunners();
460
+ if (process.stdout.isTTY || isFirstCompile) {
461
+ hookRunners2.afterDev();
462
+ if (isFirstCompile) {
463
+ printInstructions(hookRunners2, appContext, normalizedConfig);
464
+ }
470
465
  }
471
- }
472
- return [
473
- 2
474
- ];
475
- });
476
- })();
477
- },
478
- onBeforeCreateCompiler: function onBeforeCreateCompiler(param) {
479
- var bundlerConfigs = param.bundlerConfigs;
480
- return _asyncToGenerator(function() {
481
- var hookRunners2;
482
- return __generator(this, function(_state) {
483
- switch(_state.label){
484
- case 0:
485
- hookRunners2 = api.useHookRunners();
486
- return [
487
- 4,
488
- hookRunners2.beforeCreateCompiler({
489
- bundlerConfigs: bundlerConfigs
490
- })
491
- ];
492
- case 1:
493
- _state.sent();
494
- return [
495
- 2
496
- ];
497
- }
498
- });
499
- })();
500
- },
501
- onAfterCreateCompiler: function onAfterCreateCompiler(param) {
502
- var compiler = param.compiler;
503
- return _asyncToGenerator(function() {
504
- var hookRunners2;
505
- return __generator(this, function(_state) {
506
- switch(_state.label){
507
- case 0:
508
- hookRunners2 = api.useHookRunners();
509
- return [
510
- 4,
511
- hookRunners2.afterCreateCompiler({
512
- compiler: compiler
513
- })
514
- ];
515
- case 1:
516
- _state.sent();
517
- return [
518
- 2
519
- ];
520
- }
521
- });
522
- })();
466
+ return [
467
+ 2
468
+ ];
469
+ });
470
+ })();
471
+ },
472
+ onBeforeCreateCompiler: function onBeforeCreateCompiler(param) {
473
+ var bundlerConfigs = param.bundlerConfigs;
474
+ return _asyncToGenerator(function() {
475
+ var hookRunners2;
476
+ return __generator(this, function(_state) {
477
+ switch(_state.label){
478
+ case 0:
479
+ hookRunners2 = api.useHookRunners();
480
+ return [
481
+ 4,
482
+ hookRunners2.beforeCreateCompiler({
483
+ bundlerConfigs: bundlerConfigs
484
+ })
485
+ ];
486
+ case 1:
487
+ _state.sent();
488
+ return [
489
+ 2
490
+ ];
491
+ }
492
+ });
493
+ })();
494
+ },
495
+ onAfterCreateCompiler: function onAfterCreateCompiler(param) {
496
+ var compiler = param.compiler;
497
+ return _asyncToGenerator(function() {
498
+ var hookRunners2;
499
+ return __generator(this, function(_state) {
500
+ switch(_state.label){
501
+ case 0:
502
+ hookRunners2 = api.useHookRunners();
503
+ return [
504
+ 4,
505
+ hookRunners2.afterCreateCompiler({
506
+ compiler: compiler
507
+ })
508
+ ];
509
+ case 1:
510
+ _state.sent();
511
+ return [
512
+ 2
513
+ ];
514
+ }
515
+ });
516
+ })();
517
+ }
523
518
  }
524
519
  })
525
520
  ];
526
- case 13:
521
+ case 12:
527
522
  builder = _state.sent();
528
523
  builder.addPlugins(resolvedConfig.builderPlugins);
529
524
  appContext = _objectSpreadProps(_objectSpread({}, appContext), {
530
525
  builder: builder
531
526
  });
532
527
  api.setAppContext(appContext);
533
- _state.label = 14;
534
- case 14:
528
+ _state.label = 13;
529
+ case 13:
535
530
  return [
536
531
  2
537
532
  ];
@@ -565,7 +560,7 @@ var analyze_default = function(param) {
565
560
  resolvedConfig: function resolvedConfig(param) {
566
561
  var resolved = param.resolved;
567
562
  var appContext = api.useAppContext();
568
- var config = initialNormalizedConfig(resolved, appContext, bundler);
563
+ var config = initialNormalizedConfig(resolved, appContext);
569
564
  return {
570
565
  resolved: config
571
566
  };
@@ -197,7 +197,7 @@ var createRoute = function(routeInfo, rootDir, filename, entryName) {
197
197
  };
198
198
  var walk = function() {
199
199
  var _ref = _asyncToGenerator(function(dirname, rootDir, alias, entryName) {
200
- var ref, isDirectory, relativeDir, pathSegments, lastSegment, isRoot, isPathlessLayout, isWithoutLayoutPath, routePath, route, pageLoaderFile, pageRoute, splatLoaderFile, splatRoute, items, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, item, itemPath, extname, itemWithoutExt, isDirectory2, childRoute, ref1, ref2, ref3, err, finalRoute;
200
+ var ref, isDirectory, relativeDir, pathSegments, lastSegment, isRoot, isPathlessLayout, isWithoutLayoutPath, routePath, route, pageLoaderFile, pageRoute, items, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, item, itemPath, extname, itemWithoutExt, isDirectory2, childRoute, ref1, ref2, err, finalRoute;
201
201
  return __generator(this, function(_state) {
202
202
  switch(_state.label){
203
203
  case 0:
@@ -242,8 +242,6 @@ var walk = function() {
242
242
  };
243
243
  pageLoaderFile = "";
244
244
  pageRoute = null;
245
- splatLoaderFile = "";
246
- splatRoute = null;
247
245
  return [
248
246
  4,
249
247
  fs.readdir(dirname)
@@ -319,20 +317,6 @@ var walk = function() {
319
317
  }
320
318
  (ref2 = route.children) === null || ref2 === void 0 ? void 0 : ref2.push(pageRoute);
321
319
  }
322
- if (itemWithoutExt === NESTED_ROUTE.SPLATE_LOADER_FILE) {
323
- splatLoaderFile = itemPath;
324
- }
325
- if (itemWithoutExt === NESTED_ROUTE.SPLATE_FILE) {
326
- ;
327
- splatRoute = createRoute({
328
- _component: replaceWithAlias(alias.basename, itemPath, alias.name),
329
- path: "*"
330
- }, rootDir, itemPath, entryName);
331
- if (splatLoaderFile) {
332
- splatRoute.loader = splatLoaderFile;
333
- }
334
- (ref3 = route.children) === null || ref3 === void 0 ? void 0 : ref3.push(splatRoute);
335
- }
336
320
  if (itemWithoutExt === NESTED_ROUTE.LOADING_FILE) {
337
321
  route.loading = replaceWithAlias(alias.basename, itemPath, alias.name);
338
322
  }
@@ -296,7 +296,7 @@ var routesForServer = function(param) {
296
296
  };
297
297
  var fileSystemRoutes = function() {
298
298
  var _ref = _asyncToGenerator(function(param) {
299
- var routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, loadings, errors, loaders, loadersMap, loadersMapFile, importLazyCode, rootLayoutCode, getDataLoaderPath, traverseRouteTree, routeComponentsCode, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, route, newRoute, component, finalRoute, importLoadingCode, importErrorComponentsCode, importLoadersCode, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _value, key, loaderInfo;
299
+ var routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, loadings, errors, loaders, loadersMap, loadersMapFile, importLazyCode, rootLayoutCode, componentLoaderPath, getDataLoaderPath, traverseRouteTree, routeComponentsCode, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, route, newRoute, component, finalRoute, importLoadingCode, importErrorComponentsCode, importLoadersCode, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _value, key, loaderInfo;
300
300
  return __generator(this, function(_state) {
301
301
  switch(_state.label){
302
302
  case 0:
@@ -308,6 +308,7 @@ var fileSystemRoutes = function() {
308
308
  loadersMapFile = path.join(internalDirectory, entryName, TEMP_LOADERS_DIR, "map.json");
309
309
  importLazyCode = '\n import { lazy } from "react";\n import loadable, { lazy as loadableLazy } from "@modern-js/runtime/loadable"\n ';
310
310
  rootLayoutCode = "";
311
+ componentLoaderPath = "";
311
312
  getDataLoaderPath = function(loaderId) {
312
313
  if (!ssrMode) {
313
314
  return "";
@@ -318,6 +319,9 @@ var fileSystemRoutes = function() {
318
319
  }
319
320
  return dataLoaderPath;
320
321
  };
322
+ if (ssrMode) {
323
+ componentLoaderPath = "".concat(path.join(__dirname, "../builder/loaders/routerLoader"), "!");
324
+ }
321
325
  traverseRouteTree = function(route) {
322
326
  var children;
323
327
  if ("children" in route && route.children) {
@@ -353,10 +357,10 @@ var fileSystemRoutes = function() {
353
357
  rootLayoutCode = "import RootLayout from '".concat(route._component, "'");
354
358
  component = "RootLayout";
355
359
  } else if (ssrMode === "string") {
356
- lazyImport = '() => import(/* webpackChunkName: "'.concat(route.id, "\" */ '").concat(route._component, "')");
360
+ lazyImport = '() => import(/* webpackChunkName: "'.concat(route.id, "\" */ '").concat(componentLoaderPath).concat(route._component, "')");
357
361
  component = "loadable(".concat(lazyImport, ")");
358
362
  } else {
359
- lazyImport = '() => import(/* webpackChunkName: "'.concat(route.id, "\" */ '").concat(route._component, "')");
363
+ lazyImport = '() => import(/* webpackChunkName: "'.concat(route.id, "\" */ '").concat(componentLoaderPath).concat(route._component, "')");
360
364
  component = "lazy(".concat(lazyImport, ")");
361
365
  }
362
366
  }