@modern-js/app-tools 2.3.1-alpha.1 → 2.4.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 (168) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +14 -18
  3. package/dist/js/modern/analyze/index.js +45 -48
  4. package/dist/js/modern/analyze/nestedRoutes.js +10 -1
  5. package/dist/js/modern/analyze/templates.js +2 -9
  6. package/dist/js/modern/builder/builder-rspack/index.js +8 -0
  7. package/dist/js/modern/builder/builder-webpack/builderPlugins/compatModern.js +41 -0
  8. package/dist/js/modern/builder/builder-webpack/index.js +93 -0
  9. package/dist/js/modern/builder/{webpackPlugins/routerPlugin.js → builder-webpack/webpackPlugins/RouterPlugin.js} +1 -1
  10. package/dist/js/modern/builder/builder-webpack/webpackPlugins/index.js +1 -0
  11. package/dist/js/modern/builder/generator/createBuilderOptions.js +24 -0
  12. package/dist/js/modern/builder/generator/createBuilderProviderConfig.js +39 -0
  13. package/dist/js/modern/builder/generator/getBuilderTargets.js +12 -0
  14. package/dist/js/modern/builder/generator/index.js +53 -0
  15. package/dist/js/modern/builder/index.js +13 -133
  16. package/dist/js/modern/builder/{builderPlugins/compatModern.js → shared/builderPlugins/adapterModern.js} +81 -111
  17. package/dist/js/modern/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +27 -0
  18. package/dist/js/modern/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +34 -0
  19. package/dist/js/modern/builder/{share.js → shared/createCopyPattern.js} +0 -0
  20. package/dist/js/modern/builder/shared/index.js +3 -0
  21. package/dist/js/modern/builder/{loaders → shared/loaders}/serverModuleLoader.js +0 -0
  22. package/dist/js/modern/builder/shared/types.js +0 -0
  23. package/dist/js/modern/config/default.js +2 -2
  24. package/dist/js/modern/config/index.js +3 -8
  25. package/dist/js/modern/config/initialize/index.js +12 -0
  26. package/dist/js/modern/config/{initial → initialize}/inits.js +4 -2
  27. package/dist/js/modern/config/{initial → legacy}/createHtmlConfig.js +0 -0
  28. package/dist/js/modern/config/{initial → legacy}/createOutputConfig.js +0 -0
  29. package/dist/js/modern/config/{initial → legacy}/createSourceConfig.js +0 -0
  30. package/dist/js/modern/config/{initial → legacy}/createToolsConfig.js +0 -0
  31. package/dist/js/modern/config/{initial/transformNormalizedConfig.js → legacy/index.js} +4 -0
  32. package/dist/js/modern/index.js +18 -8
  33. package/dist/js/modern/initialize/index.js +36 -28
  34. package/dist/js/modern/locale/zh.js +1 -1
  35. package/dist/js/modern/types/utils.js +0 -0
  36. package/dist/js/node/analyze/index.js +46 -49
  37. package/dist/js/node/analyze/nestedRoutes.js +10 -1
  38. package/dist/js/node/analyze/templates.js +2 -9
  39. package/dist/js/node/builder/builder-rspack/index.js +31 -0
  40. package/dist/js/node/builder/builder-webpack/builderPlugins/compatModern.js +64 -0
  41. package/dist/js/node/builder/builder-webpack/index.js +118 -0
  42. package/dist/js/node/builder/{webpackPlugins/routerPlugin.js → builder-webpack/webpackPlugins/RouterPlugin.js} +7 -5
  43. package/dist/js/node/builder/builder-webpack/webpackPlugins/index.js +17 -0
  44. package/dist/js/node/builder/generator/createBuilderOptions.js +47 -0
  45. package/dist/js/node/builder/generator/createBuilderProviderConfig.js +60 -0
  46. package/dist/js/node/builder/{loaders/routerLoader.js → generator/getBuilderTargets.js} +13 -16
  47. package/dist/js/node/builder/generator/index.js +82 -0
  48. package/dist/js/node/builder/index.js +14 -123
  49. package/dist/js/node/builder/{builderPlugins/compatModern.js → shared/builderPlugins/adapterModern.js} +86 -115
  50. package/dist/js/node/builder/{webpackPlugins/htmlAsyncChunkPlugin.js → shared/bundlerPlugins/HtmlAsyncChunkPlugin.js} +17 -20
  51. package/dist/js/node/builder/{webpackPlugins/htmlBottomTemplate.js → shared/bundlerPlugins/HtmlBottomTemplate.js} +21 -24
  52. package/dist/js/node/builder/{share.js → shared/createCopyPattern.js} +3 -3
  53. package/dist/js/node/builder/shared/index.js +19 -0
  54. package/dist/js/node/builder/{loaders → shared/loaders}/serverModuleLoader.js +0 -0
  55. package/dist/js/node/builder/shared/types.js +15 -0
  56. package/dist/js/node/config/default.js +2 -2
  57. package/dist/js/node/config/index.js +4 -19
  58. package/dist/js/node/config/{initial → initialize}/index.js +10 -16
  59. package/dist/js/node/config/{initial → initialize}/inits.js +4 -2
  60. package/dist/js/node/config/{initial → legacy}/createHtmlConfig.js +0 -0
  61. package/dist/js/node/config/{initial → legacy}/createOutputConfig.js +0 -0
  62. package/dist/js/node/config/{initial → legacy}/createSourceConfig.js +0 -0
  63. package/dist/js/node/config/{initial → legacy}/createToolsConfig.js +0 -0
  64. package/dist/js/node/config/{initial/transformNormalizedConfig.js → legacy/index.js} +8 -3
  65. package/dist/js/node/index.js +18 -8
  66. package/dist/js/node/initialize/index.js +35 -28
  67. package/dist/js/node/locale/zh.js +1 -1
  68. package/dist/js/node/types/utils.js +15 -0
  69. package/dist/js/treeshaking/analyze/index.js +135 -130
  70. package/dist/js/treeshaking/analyze/nestedRoutes.js +10 -1
  71. package/dist/js/treeshaking/analyze/templates.js +3 -7
  72. package/dist/js/treeshaking/builder/builder-rspack/index.js +6 -0
  73. package/dist/js/treeshaking/builder/builder-webpack/builderPlugins/compatModern.js +64 -0
  74. package/dist/js/treeshaking/builder/builder-webpack/index.js +301 -0
  75. package/dist/js/treeshaking/builder/{webpackPlugins/routerPlugin.js → builder-webpack/webpackPlugins/RouterPlugin.js} +1 -1
  76. package/dist/js/treeshaking/builder/builder-webpack/webpackPlugins/index.js +1 -0
  77. package/dist/js/treeshaking/builder/generator/createBuilderOptions.js +41 -0
  78. package/dist/js/treeshaking/builder/generator/createBuilderProviderConfig.js +70 -0
  79. package/dist/js/treeshaking/builder/generator/getBuilderTargets.js +12 -0
  80. package/dist/js/treeshaking/builder/generator/index.js +199 -0
  81. package/dist/js/treeshaking/builder/index.js +29 -228
  82. package/dist/js/treeshaking/builder/{builderPlugins/compatModern.js → shared/builderPlugins/adapterModern.js} +103 -156
  83. package/dist/js/treeshaking/builder/{webpackPlugins/htmlAsyncChunkPlugin.js → shared/bundlerPlugins/HtmlAsyncChunkPlugin.js} +0 -0
  84. package/dist/js/treeshaking/builder/{webpackPlugins/htmlBottomTemplate.js → shared/bundlerPlugins/HtmlBottomTemplate.js} +0 -0
  85. package/dist/js/treeshaking/builder/{share.js → shared/createCopyPattern.js} +0 -0
  86. package/dist/js/treeshaking/builder/shared/index.js +3 -0
  87. package/dist/js/treeshaking/builder/{loaders → shared/loaders}/serverModuleLoader.js +0 -0
  88. package/dist/js/treeshaking/builder/shared/types.js +1 -0
  89. package/dist/js/treeshaking/config/default.js +2 -2
  90. package/dist/js/treeshaking/config/index.js +3 -3
  91. package/dist/js/treeshaking/config/initialize/index.js +10 -0
  92. package/dist/js/treeshaking/config/{initial → initialize}/inits.js +4 -2
  93. package/dist/js/treeshaking/config/{initial → legacy}/createHtmlConfig.js +0 -0
  94. package/dist/js/treeshaking/config/{initial → legacy}/createOutputConfig.js +0 -0
  95. package/dist/js/treeshaking/config/{initial → legacy}/createSourceConfig.js +0 -0
  96. package/dist/js/treeshaking/config/{initial → legacy}/createToolsConfig.js +0 -0
  97. package/dist/js/treeshaking/config/{initial/transformNormalizedConfig.js → legacy/index.js} +4 -1
  98. package/dist/js/treeshaking/index.js +19 -12
  99. package/dist/js/treeshaking/initialize/index.js +34 -26
  100. package/dist/js/treeshaking/locale/zh.js +1 -1
  101. package/dist/js/treeshaking/types/utils.js +1 -0
  102. package/dist/types/analyze/generateCode.d.ts +1 -1
  103. package/dist/types/analyze/getBundleEntry.d.ts +1 -1
  104. package/dist/types/analyze/getFileSystemEntry.d.ts +1 -1
  105. package/dist/types/analyze/getHtmlTemplate.d.ts +2 -2
  106. package/dist/types/analyze/getServerRoutes.d.ts +1 -1
  107. package/dist/types/analyze/index.d.ts +5 -1
  108. package/dist/types/builder/builder-rspack/index.d.ts +2 -0
  109. package/dist/types/builder/{builderPlugins → builder-webpack/builderPlugins}/compatModern.d.ts +2 -2
  110. package/dist/types/builder/builder-webpack/index.d.ts +4 -0
  111. package/dist/types/builder/{webpackPlugins/routerPlugin.d.ts → builder-webpack/webpackPlugins/RouterPlugin.d.ts} +1 -1
  112. package/dist/types/builder/builder-webpack/webpackPlugins/index.d.ts +1 -0
  113. package/dist/types/builder/generator/createBuilderOptions.d.ts +3 -0
  114. package/dist/types/builder/generator/createBuilderProviderConfig.d.ts +2 -0
  115. package/dist/types/builder/generator/getBuilderTargets.d.ts +3 -0
  116. package/dist/types/builder/generator/index.d.ts +17 -0
  117. package/dist/types/builder/index.d.ts +1 -18
  118. package/dist/types/builder/shared/builderPlugins/adapterModern.d.ts +13 -0
  119. package/dist/types/builder/{webpackPlugins/htmlAsyncChunkPlugin.d.ts → shared/bundlerPlugins/HtmlAsyncChunkPlugin.d.ts} +2 -1
  120. package/dist/types/builder/{webpackPlugins/htmlBottomTemplate.d.ts → shared/bundlerPlugins/HtmlBottomTemplate.d.ts} +2 -1
  121. package/dist/types/builder/{share.d.ts → shared/createCopyPattern.d.ts} +1 -1
  122. package/dist/types/builder/shared/index.d.ts +3 -0
  123. package/dist/types/builder/shared/loaders/serverModuleLoader.d.ts +4 -0
  124. package/dist/types/builder/shared/types.d.ts +16 -0
  125. package/dist/types/commands/build.d.ts +1 -1
  126. package/dist/types/commands/deploy.d.ts +1 -1
  127. package/dist/types/commands/dev.d.ts +1 -1
  128. package/dist/types/commands/inspect.d.ts +1 -1
  129. package/dist/types/commands/serve.d.ts +1 -1
  130. package/dist/types/config/default.d.ts +1 -1
  131. package/dist/types/config/index.d.ts +3 -2
  132. package/dist/types/config/initialize/index.d.ts +2 -0
  133. package/dist/types/config/{initial → initialize}/inits.d.ts +3 -3
  134. package/dist/types/config/{initial → legacy}/createHtmlConfig.d.ts +1 -1
  135. package/dist/types/config/{initial → legacy}/createOutputConfig.d.ts +1 -1
  136. package/dist/types/config/{initial → legacy}/createSourceConfig.d.ts +1 -1
  137. package/dist/types/config/{initial → legacy}/createToolsConfig.d.ts +1 -1
  138. package/dist/types/config/legacy/index.d.ts +3 -0
  139. package/dist/types/defineConfig.d.ts +3 -2
  140. package/dist/types/index.d.ts +7 -3
  141. package/dist/types/initialize/index.d.ts +6 -2
  142. package/dist/types/types/config/deploy.d.ts +1 -2
  143. package/dist/types/types/config/dev.d.ts +2 -3
  144. package/dist/types/types/config/experiments.d.ts +1 -2
  145. package/dist/types/types/config/html.d.ts +5 -3
  146. package/dist/types/types/config/index.d.ts +41 -48
  147. package/dist/types/types/config/output.d.ts +8 -3
  148. package/dist/types/types/config/performance.d.ts +6 -3
  149. package/dist/types/types/config/security.d.ts +3 -3
  150. package/dist/types/types/config/source.d.ts +7 -3
  151. package/dist/types/types/config/tools.d.ts +10 -4
  152. package/dist/types/types/hooks.d.ts +4 -3
  153. package/dist/types/types/index.d.ts +16 -6
  154. package/dist/types/types/utils.d.ts +7 -0
  155. package/dist/types/utils/config.d.ts +1 -1
  156. package/dist/types/utils/getServerInternalPlugins.d.ts +1 -1
  157. package/dist/types/utils/printInstructions.d.ts +1 -1
  158. package/package.json +34 -25
  159. package/dist/js/modern/builder/loaders/routerLoader.js +0 -17
  160. package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -30
  161. package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +0 -37
  162. package/dist/js/modern/config/initial/index.js +0 -16
  163. package/dist/js/treeshaking/builder/loaders/routerLoader.js +0 -13
  164. package/dist/js/treeshaking/config/initial/index.js +0 -12
  165. package/dist/types/builder/loaders/routerLoader.d.ts +0 -3
  166. package/dist/types/builder/loaders/serverModuleLoader.d.ts +0 -3
  167. package/dist/types/config/initial/index.d.ts +0 -4
  168. package/dist/types/config/initial/transformNormalizedConfig.d.ts +0 -2
@@ -223,16 +223,17 @@ 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";
227
226
  import { printInstructions } from "../utils/printInstructions";
228
227
  import { generateRoutes } from "../utils/routes";
229
228
  import { emitResolvedConfig } from "../utils/config";
230
229
  import { getSelectedEntries } from "../utils/getSelectedEntries";
231
230
  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() {
235
+ var analyze_default = function(param) {
236
+ var bundler = param.bundler;
236
237
  return {
237
238
  name: "@modern-js/plugin-analyze",
238
239
  setup: function(api) {
@@ -242,7 +243,7 @@ var analyze_default = function() {
242
243
  return {
243
244
  prepare: function prepare() {
244
245
  return _asyncToGenerator(function() {
245
- var ref, appContext, resolvedConfig, hookRunners, apiOnly, ref1, routes2, ref2, getBundleEntry, getServerRoutes, generateCode, getHtmlTemplate, entrypoints, initialRoutes, routes, htmlTemplates, checkedEntries, entry, command, buildCommands, normalizedConfig, builder;
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;
246
247
  return __generator(this, function(_state) {
247
248
  switch(_state.label){
248
249
  case 0:
@@ -384,149 +385,153 @@ var analyze_default = function() {
384
385
  ];
385
386
  if (!buildCommands.includes(command)) return [
386
387
  3,
387
- 13
388
+ 14
388
389
  ];
389
390
  normalizedConfig = api.useResolvedConfigContext();
391
+ return [
392
+ 4,
393
+ createBuilderGenerator(bundler)
394
+ ];
395
+ case 12:
396
+ createBuilderForModern = _state.sent();
390
397
  return [
391
398
  4,
392
399
  createBuilderForModern({
393
400
  normalizedConfig: normalizedConfig,
394
401
  appContext: appContext,
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
- }
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);
465
470
  }
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
- }
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
+ })();
518
523
  }
519
524
  })
520
525
  ];
521
- case 12:
526
+ case 13:
522
527
  builder = _state.sent();
523
528
  builder.addPlugins(resolvedConfig.builderPlugins);
524
529
  appContext = _objectSpreadProps(_objectSpread({}, appContext), {
525
530
  builder: builder
526
531
  });
527
532
  api.setAppContext(appContext);
528
- _state.label = 13;
529
- case 13:
533
+ _state.label = 14;
534
+ case 14:
530
535
  return [
531
536
  2
532
537
  ];
@@ -560,7 +565,7 @@ var analyze_default = function() {
560
565
  resolvedConfig: function resolvedConfig(param) {
561
566
  var resolved = param.resolved;
562
567
  var appContext = api.useAppContext();
563
- var config = initialNormalizedConfig(resolved, appContext);
568
+ var config = initialNormalizedConfig(resolved, appContext, bundler);
564
569
  return {
565
570
  resolved: config
566
571
  };
@@ -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, splatLoaderFile, splatRoute, items, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, item, itemPath, extname, itemWithoutExt, isDirectory2, childRoute, ref1, ref2, ref3, err, finalRoute, childRoute1, path2;
201
201
  return __generator(this, function(_state) {
202
202
  switch(_state.label){
203
203
  case 0:
@@ -386,6 +386,15 @@ var walk = function() {
386
386
  null
387
387
  ];
388
388
  }
389
+ if (finalRoute.children && finalRoute.children.length === 1 && !finalRoute._component) {
390
+ childRoute1 = finalRoute.children[0];
391
+ if (childRoute1.path === "*") {
392
+ path2 = "".concat(finalRoute.path || "", "/").concat(childRoute1.path || "");
393
+ finalRoute = _objectSpreadProps(_objectSpread({}, childRoute1), {
394
+ path: path2
395
+ });
396
+ }
397
+ }
389
398
  return [
390
399
  2,
391
400
  finalRoute
@@ -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, componentLoaderPath, 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, 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,7 +308,6 @@ 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 = "";
312
311
  getDataLoaderPath = function(loaderId) {
313
312
  if (!ssrMode) {
314
313
  return "";
@@ -319,9 +318,6 @@ var fileSystemRoutes = function() {
319
318
  }
320
319
  return dataLoaderPath;
321
320
  };
322
- if (ssrMode) {
323
- componentLoaderPath = "".concat(path.join(__dirname, "../builder/loaders/routerLoader"), "!");
324
- }
325
321
  traverseRouteTree = function(route) {
326
322
  var children;
327
323
  if ("children" in route && route.children) {
@@ -357,10 +353,10 @@ var fileSystemRoutes = function() {
357
353
  rootLayoutCode = "import RootLayout from '".concat(route._component, "'");
358
354
  component = "RootLayout";
359
355
  } else if (ssrMode === "string") {
360
- lazyImport = '() => import(/* webpackChunkName: "'.concat(route.id, "\" */ '").concat(componentLoaderPath).concat(route._component, "')");
356
+ lazyImport = '() => import(/* webpackChunkName: "'.concat(route.id, "\" */ '").concat(route._component, "')");
361
357
  component = "loadable(".concat(lazyImport, ")");
362
358
  } else {
363
- lazyImport = '() => import(/* webpackChunkName: "'.concat(route.id, "\" */ '").concat(componentLoaderPath).concat(route._component, "')");
359
+ lazyImport = '() => import(/* webpackChunkName: "'.concat(route.id, "\" */ '").concat(route._component, "')");
364
360
  component = "lazy(".concat(lazyImport, ")");
365
361
  }
366
362
  }
@@ -0,0 +1,6 @@
1
+ import { builderRspackProvider } from "@modern-js/builder-rspack-provider";
2
+ import { generateBuilder } from "../generator";
3
+ function createRspackBuilderForModern(options) {
4
+ return generateBuilder(options, builderRspackProvider);
5
+ }
6
+ export { createRspackBuilderForModern };
@@ -0,0 +1,64 @@
1
+ function _arrayLikeToArray(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _arrayWithoutHoles(arr) {
7
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
8
+ }
9
+ function _iterableToArray(iter) {
10
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
11
+ }
12
+ function _nonIterableSpread() {
13
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
14
+ }
15
+ function _toConsumableArray(arr) {
16
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
17
+ }
18
+ function _unsupportedIterableToArray(o, minLen) {
19
+ if (!o) return;
20
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
21
+ var n = Object.prototype.toString.call(o).slice(8, -1);
22
+ if (n === "Object" && o.constructor) n = o.constructor.name;
23
+ if (n === "Map" || n === "Set") return Array.from(n);
24
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
25
+ }
26
+ import { join } from "path";
27
+ import { createCopyPattern } from "../../shared";
28
+ import { RouterPlugin } from "../webpackPlugins";
29
+ var PluginCompatModern = function(options) {
30
+ return {
31
+ name: "builder-plugin-compat-modern",
32
+ setup: function setup(api) {
33
+ var modernConfig = options.normalizedConfig, appContext = options.appContext;
34
+ api.modifyWebpackChain(function(chain, param) {
35
+ var CHAIN_ID = param.CHAIN_ID;
36
+ var ref;
37
+ chain.resolve.modules.add("node_modules").add(join(api.context.rootPath, "node_modules"));
38
+ if (chain.plugins.has(CHAIN_ID.PLUGIN.COPY)) {
39
+ var defaultCopyPattern = createCopyPattern(appContext, modernConfig, "public", chain);
40
+ chain.plugin(CHAIN_ID.PLUGIN.COPY).tap(function(args) {
41
+ var ref;
42
+ return [
43
+ {
44
+ patterns: _toConsumableArray(((ref = args[0]) === null || ref === void 0 ? void 0 : ref.patterns) || []).concat([
45
+ defaultCopyPattern
46
+ ])
47
+ }
48
+ ];
49
+ });
50
+ }
51
+ var entrypoints = appContext.entrypoints;
52
+ var existNestedRoutes = entrypoints.some(function(entrypoint) {
53
+ return entrypoint.nestedRoutesEntry;
54
+ });
55
+ var routerConfig = modernConfig === null || modernConfig === void 0 ? void 0 : (ref = modernConfig.runtime) === null || ref === void 0 ? void 0 : ref.router;
56
+ var routerManifest = Boolean(routerConfig === null || routerConfig === void 0 ? void 0 : routerConfig.manifest);
57
+ if (existNestedRoutes || routerManifest) {
58
+ chain.plugin("route-plugin").use(RouterPlugin);
59
+ }
60
+ });
61
+ }
62
+ };
63
+ };
64
+ export { PluginCompatModern };