@modern-js/app-tools 2.3.1-alpha.2 → 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 (159) 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/builder/builder-rspack/index.js +8 -0
  5. package/dist/js/modern/builder/builder-webpack/builderPlugins/compatModern.js +41 -0
  6. package/dist/js/modern/builder/builder-webpack/index.js +93 -0
  7. package/dist/js/modern/builder/{webpackPlugins/routerPlugin.js → builder-webpack/webpackPlugins/RouterPlugin.js} +1 -1
  8. package/dist/js/modern/builder/builder-webpack/webpackPlugins/index.js +1 -0
  9. package/dist/js/modern/builder/generator/createBuilderOptions.js +24 -0
  10. package/dist/js/modern/builder/generator/createBuilderProviderConfig.js +39 -0
  11. package/dist/js/modern/builder/generator/getBuilderTargets.js +12 -0
  12. package/dist/js/modern/builder/generator/index.js +53 -0
  13. package/dist/js/modern/builder/index.js +13 -133
  14. package/dist/js/modern/builder/{builderPlugins/compatModern.js → shared/builderPlugins/adapterModern.js} +81 -111
  15. package/dist/js/modern/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +27 -0
  16. package/dist/js/modern/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +34 -0
  17. package/dist/js/modern/builder/{share.js → shared/createCopyPattern.js} +0 -0
  18. package/dist/js/modern/builder/shared/index.js +3 -0
  19. package/dist/js/modern/builder/{loaders → shared/loaders}/serverModuleLoader.js +0 -0
  20. package/dist/js/modern/builder/shared/types.js +0 -0
  21. package/dist/js/modern/config/default.js +2 -2
  22. package/dist/js/modern/config/index.js +3 -8
  23. package/dist/js/modern/config/initialize/index.js +12 -0
  24. package/dist/js/modern/config/{initial → initialize}/inits.js +4 -2
  25. package/dist/js/modern/config/{initial → legacy}/createHtmlConfig.js +0 -0
  26. package/dist/js/modern/config/{initial → legacy}/createOutputConfig.js +0 -0
  27. package/dist/js/modern/config/{initial → legacy}/createSourceConfig.js +0 -0
  28. package/dist/js/modern/config/{initial → legacy}/createToolsConfig.js +0 -0
  29. package/dist/js/modern/config/{initial/transformNormalizedConfig.js → legacy/index.js} +4 -0
  30. package/dist/js/modern/index.js +18 -8
  31. package/dist/js/modern/initialize/index.js +36 -28
  32. package/dist/js/modern/locale/zh.js +1 -1
  33. package/dist/js/modern/types/utils.js +0 -0
  34. package/dist/js/node/analyze/index.js +46 -49
  35. package/dist/js/node/builder/builder-rspack/index.js +31 -0
  36. package/dist/js/node/builder/builder-webpack/builderPlugins/compatModern.js +64 -0
  37. package/dist/js/node/builder/builder-webpack/index.js +118 -0
  38. package/dist/js/node/builder/{webpackPlugins/routerPlugin.js → builder-webpack/webpackPlugins/RouterPlugin.js} +7 -5
  39. package/dist/js/node/builder/builder-webpack/webpackPlugins/index.js +17 -0
  40. package/dist/js/node/builder/generator/createBuilderOptions.js +47 -0
  41. package/dist/js/node/builder/generator/createBuilderProviderConfig.js +60 -0
  42. package/dist/js/node/builder/generator/getBuilderTargets.js +35 -0
  43. package/dist/js/node/builder/generator/index.js +82 -0
  44. package/dist/js/node/builder/index.js +14 -123
  45. package/dist/js/node/builder/{builderPlugins/compatModern.js → shared/builderPlugins/adapterModern.js} +86 -115
  46. package/dist/js/node/builder/{webpackPlugins/htmlAsyncChunkPlugin.js → shared/bundlerPlugins/HtmlAsyncChunkPlugin.js} +17 -20
  47. package/dist/js/node/builder/{webpackPlugins/htmlBottomTemplate.js → shared/bundlerPlugins/HtmlBottomTemplate.js} +21 -24
  48. package/dist/js/node/builder/{share.js → shared/createCopyPattern.js} +3 -3
  49. package/dist/js/node/builder/shared/index.js +19 -0
  50. package/dist/js/node/builder/{loaders → shared/loaders}/serverModuleLoader.js +0 -0
  51. package/dist/js/node/builder/shared/types.js +15 -0
  52. package/dist/js/node/config/default.js +2 -2
  53. package/dist/js/node/config/index.js +4 -19
  54. package/dist/js/node/config/{initial → initialize}/index.js +10 -16
  55. package/dist/js/node/config/{initial → initialize}/inits.js +4 -2
  56. package/dist/js/node/config/{initial → legacy}/createHtmlConfig.js +0 -0
  57. package/dist/js/node/config/{initial → legacy}/createOutputConfig.js +0 -0
  58. package/dist/js/node/config/{initial → legacy}/createSourceConfig.js +0 -0
  59. package/dist/js/node/config/{initial → legacy}/createToolsConfig.js +0 -0
  60. package/dist/js/node/config/{initial/transformNormalizedConfig.js → legacy/index.js} +8 -3
  61. package/dist/js/node/index.js +18 -8
  62. package/dist/js/node/initialize/index.js +35 -28
  63. package/dist/js/node/locale/zh.js +1 -1
  64. package/dist/js/node/types/utils.js +15 -0
  65. package/dist/js/treeshaking/analyze/index.js +135 -130
  66. package/dist/js/treeshaking/builder/builder-rspack/index.js +6 -0
  67. package/dist/js/treeshaking/builder/builder-webpack/builderPlugins/compatModern.js +64 -0
  68. package/dist/js/treeshaking/builder/builder-webpack/index.js +301 -0
  69. package/dist/js/treeshaking/builder/{webpackPlugins/routerPlugin.js → builder-webpack/webpackPlugins/RouterPlugin.js} +1 -1
  70. package/dist/js/treeshaking/builder/builder-webpack/webpackPlugins/index.js +1 -0
  71. package/dist/js/treeshaking/builder/generator/createBuilderOptions.js +41 -0
  72. package/dist/js/treeshaking/builder/generator/createBuilderProviderConfig.js +70 -0
  73. package/dist/js/treeshaking/builder/generator/getBuilderTargets.js +12 -0
  74. package/dist/js/treeshaking/builder/generator/index.js +199 -0
  75. package/dist/js/treeshaking/builder/index.js +29 -228
  76. package/dist/js/treeshaking/builder/{builderPlugins/compatModern.js → shared/builderPlugins/adapterModern.js} +103 -156
  77. package/dist/js/treeshaking/builder/{webpackPlugins/htmlAsyncChunkPlugin.js → shared/bundlerPlugins/HtmlAsyncChunkPlugin.js} +0 -0
  78. package/dist/js/treeshaking/builder/{webpackPlugins/htmlBottomTemplate.js → shared/bundlerPlugins/HtmlBottomTemplate.js} +0 -0
  79. package/dist/js/treeshaking/builder/{share.js → shared/createCopyPattern.js} +0 -0
  80. package/dist/js/treeshaking/builder/shared/index.js +3 -0
  81. package/dist/js/treeshaking/builder/{loaders → shared/loaders}/serverModuleLoader.js +0 -0
  82. package/dist/js/treeshaking/builder/shared/types.js +1 -0
  83. package/dist/js/treeshaking/config/default.js +2 -2
  84. package/dist/js/treeshaking/config/index.js +3 -3
  85. package/dist/js/treeshaking/config/initialize/index.js +10 -0
  86. package/dist/js/treeshaking/config/{initial → initialize}/inits.js +4 -2
  87. package/dist/js/treeshaking/config/{initial → legacy}/createHtmlConfig.js +0 -0
  88. package/dist/js/treeshaking/config/{initial → legacy}/createOutputConfig.js +0 -0
  89. package/dist/js/treeshaking/config/{initial → legacy}/createSourceConfig.js +0 -0
  90. package/dist/js/treeshaking/config/{initial → legacy}/createToolsConfig.js +0 -0
  91. package/dist/js/treeshaking/config/{initial/transformNormalizedConfig.js → legacy/index.js} +4 -1
  92. package/dist/js/treeshaking/index.js +19 -12
  93. package/dist/js/treeshaking/initialize/index.js +34 -26
  94. package/dist/js/treeshaking/locale/zh.js +1 -1
  95. package/dist/js/treeshaking/types/utils.js +1 -0
  96. package/dist/types/analyze/generateCode.d.ts +1 -1
  97. package/dist/types/analyze/getBundleEntry.d.ts +1 -1
  98. package/dist/types/analyze/getFileSystemEntry.d.ts +1 -1
  99. package/dist/types/analyze/getHtmlTemplate.d.ts +2 -2
  100. package/dist/types/analyze/getServerRoutes.d.ts +1 -1
  101. package/dist/types/analyze/index.d.ts +5 -1
  102. package/dist/types/builder/builder-rspack/index.d.ts +2 -0
  103. package/dist/types/builder/{builderPlugins → builder-webpack/builderPlugins}/compatModern.d.ts +2 -2
  104. package/dist/types/builder/builder-webpack/index.d.ts +4 -0
  105. package/dist/types/builder/{webpackPlugins/routerPlugin.d.ts → builder-webpack/webpackPlugins/RouterPlugin.d.ts} +1 -1
  106. package/dist/types/builder/builder-webpack/webpackPlugins/index.d.ts +1 -0
  107. package/dist/types/builder/generator/createBuilderOptions.d.ts +3 -0
  108. package/dist/types/builder/generator/createBuilderProviderConfig.d.ts +2 -0
  109. package/dist/types/builder/generator/getBuilderTargets.d.ts +3 -0
  110. package/dist/types/builder/generator/index.d.ts +17 -0
  111. package/dist/types/builder/index.d.ts +1 -18
  112. package/dist/types/builder/shared/builderPlugins/adapterModern.d.ts +13 -0
  113. package/dist/types/builder/{webpackPlugins/htmlAsyncChunkPlugin.d.ts → shared/bundlerPlugins/HtmlAsyncChunkPlugin.d.ts} +2 -1
  114. package/dist/types/builder/{webpackPlugins/htmlBottomTemplate.d.ts → shared/bundlerPlugins/HtmlBottomTemplate.d.ts} +2 -1
  115. package/dist/types/builder/{share.d.ts → shared/createCopyPattern.d.ts} +1 -1
  116. package/dist/types/builder/shared/index.d.ts +3 -0
  117. package/dist/types/builder/shared/loaders/serverModuleLoader.d.ts +4 -0
  118. package/dist/types/builder/shared/types.d.ts +16 -0
  119. package/dist/types/commands/build.d.ts +1 -1
  120. package/dist/types/commands/deploy.d.ts +1 -1
  121. package/dist/types/commands/dev.d.ts +1 -1
  122. package/dist/types/commands/inspect.d.ts +1 -1
  123. package/dist/types/commands/serve.d.ts +1 -1
  124. package/dist/types/config/default.d.ts +1 -1
  125. package/dist/types/config/index.d.ts +3 -2
  126. package/dist/types/config/initialize/index.d.ts +2 -0
  127. package/dist/types/config/{initial → initialize}/inits.d.ts +3 -3
  128. package/dist/types/config/{initial → legacy}/createHtmlConfig.d.ts +1 -1
  129. package/dist/types/config/{initial → legacy}/createOutputConfig.d.ts +1 -1
  130. package/dist/types/config/{initial → legacy}/createSourceConfig.d.ts +1 -1
  131. package/dist/types/config/{initial → legacy}/createToolsConfig.d.ts +1 -1
  132. package/dist/types/config/legacy/index.d.ts +3 -0
  133. package/dist/types/defineConfig.d.ts +2 -2
  134. package/dist/types/index.d.ts +7 -3
  135. package/dist/types/initialize/index.d.ts +6 -2
  136. package/dist/types/types/config/deploy.d.ts +1 -2
  137. package/dist/types/types/config/dev.d.ts +2 -3
  138. package/dist/types/types/config/experiments.d.ts +1 -2
  139. package/dist/types/types/config/html.d.ts +5 -3
  140. package/dist/types/types/config/index.d.ts +41 -48
  141. package/dist/types/types/config/output.d.ts +8 -3
  142. package/dist/types/types/config/performance.d.ts +6 -3
  143. package/dist/types/types/config/security.d.ts +3 -3
  144. package/dist/types/types/config/source.d.ts +7 -3
  145. package/dist/types/types/config/tools.d.ts +10 -4
  146. package/dist/types/types/hooks.d.ts +4 -3
  147. package/dist/types/types/index.d.ts +16 -6
  148. package/dist/types/types/utils.d.ts +7 -0
  149. package/dist/types/utils/config.d.ts +1 -1
  150. package/dist/types/utils/getServerInternalPlugins.d.ts +1 -1
  151. package/dist/types/utils/printInstructions.d.ts +1 -1
  152. package/package.json +34 -25
  153. package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -30
  154. package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +0 -37
  155. package/dist/js/modern/config/initial/index.js +0 -16
  156. package/dist/js/treeshaking/config/initial/index.js +0 -12
  157. package/dist/types/builder/loaders/serverModuleLoader.d.ts +0 -3
  158. package/dist/types/config/initial/index.d.ts +0 -4
  159. package/dist/types/config/initial/transformNormalizedConfig.d.ts +0 -2
@@ -0,0 +1,10 @@
1
+ import { initHtmlConfig, initSourceConfig, initToolsConfig } from "./inits";
2
+ function initialNormalizedConfig(config, appContext, bundler) {
3
+ initHtmlConfig(config, appContext);
4
+ initSourceConfig(config, appContext, bundler);
5
+ if (bundler === "webpack") {
6
+ initToolsConfig(config);
7
+ }
8
+ return config;
9
+ }
10
+ export { initialNormalizedConfig };
@@ -105,7 +105,7 @@ function initHtmlConfig(config, appContext) {
105
105
  config.html.favicon = createBuilderFavicon(config, appContext);
106
106
  return config.html;
107
107
  }
108
- function initSourceConfig(config, appContext) {
108
+ function initSourceConfig(config, appContext, bundler) {
109
109
  var createBuilderGlobalVars = function createBuilderGlobalVars(config2, appContext2) {
110
110
  var _source = config2.source, _globalVars = _source.globalVars, globalVars = _globalVars === void 0 ? {} : _globalVars;
111
111
  var publicEnv = getAutoInjectEnv(appContext2);
@@ -176,8 +176,10 @@ function initSourceConfig(config, appContext) {
176
176
  }
177
177
  };
178
178
  config.source.include = createBuilderInclude(config, appContext);
179
- config.source.moduleScopes = createBuilderModuleScope(config);
180
179
  config.source.globalVars = createBuilderGlobalVars(config, appContext);
180
+ if (bundler === "webpack") {
181
+ config.source.moduleScopes = createBuilderModuleScope(config);
182
+ }
181
183
  }
182
184
  function initToolsConfig(config) {
183
185
  var defaultTsChecker = {
@@ -32,4 +32,7 @@ function transformNormalizedConfig(config) {
32
32
  }
33
33
  };
34
34
  }
35
- export { transformNormalizedConfig };
35
+ function checkIsLegacyConfig(config) {
36
+ return Boolean(config.legacy);
37
+ }
38
+ export { checkIsLegacyConfig, transformNormalizedConfig };
@@ -439,6 +439,9 @@ var buildCommand = function() {
439
439
  };
440
440
  }();
441
441
  var src_default = function() {
442
+ var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
443
+ bundler: "webpack"
444
+ };
442
445
  return {
443
446
  name: "@modern-js/app-tools",
444
447
  post: [
@@ -453,8 +456,12 @@ var src_default = function() {
453
456
  ],
454
457
  registerHook: hooks,
455
458
  usePlugins: [
456
- initializePlugin(),
457
- analyzePlugin(),
459
+ initializePlugin({
460
+ bundler: (options === null || options === void 0 ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
461
+ }),
462
+ analyzePlugin({
463
+ bundler: (options === null || options === void 0 ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
464
+ }),
458
465
  lintPlugin()
459
466
  ],
460
467
  setup: function(api) {
@@ -505,7 +512,7 @@ var src_default = function() {
505
512
  });
506
513
  }));
507
514
  program.command("deploy").usage("[options]").option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).description(i18n.t(localeKeys.command.deploy.describe)).action(function() {
508
- var _ref = _asyncToGenerator(function(options) {
515
+ var _ref = _asyncToGenerator(function(options2) {
509
516
  var build, deploy;
510
517
  return __generator(this, function(_state) {
511
518
  switch(_state.label){
@@ -530,7 +537,7 @@ var src_default = function() {
530
537
  deploy = _state.sent().deploy;
531
538
  return [
532
539
  4,
533
- deploy(api, options)
540
+ deploy(api, options2)
534
541
  ];
535
542
  case 4:
536
543
  _state.sent();
@@ -541,12 +548,12 @@ var src_default = function() {
541
548
  }
542
549
  });
543
550
  });
544
- return function(options) {
551
+ return function(options2) {
545
552
  return _ref.apply(this, arguments);
546
553
  };
547
554
  }());
548
555
  program.command("new").usage("[options]").description(i18n.t(localeKeys.command.new.describe)).option("--lang <lang>", i18n.t(localeKeys.command.new.lang)).option("-d, --debug", i18n.t(localeKeys.command.new.debug), false).option("-c, --config <config>", i18n.t(localeKeys.command.new.config)).option("--dist-tag <tag>", i18n.t(localeKeys.command.new.distTag)).option("--registry", i18n.t(localeKeys.command.new.registry)).action(function() {
549
- var _ref = _asyncToGenerator(function(options) {
556
+ var _ref = _asyncToGenerator(function(options2) {
550
557
  var MWANewAction;
551
558
  return __generator(this, function(_state) {
552
559
  switch(_state.label){
@@ -559,8 +566,8 @@ var src_default = function() {
559
566
  MWANewAction = _state.sent().MWANewAction;
560
567
  return [
561
568
  4,
562
- MWANewAction(_objectSpreadProps(_objectSpread({}, options), {
563
- locale: options.lang || locale
569
+ MWANewAction(_objectSpreadProps(_objectSpread({}, options2), {
570
+ locale: options2.lang || locale
564
571
  }))
565
572
  ];
566
573
  case 2:
@@ -571,12 +578,12 @@ var src_default = function() {
571
578
  }
572
579
  });
573
580
  });
574
- return function(options) {
581
+ return function(options2) {
575
582
  return _ref.apply(this, arguments);
576
583
  };
577
584
  }());
578
585
  program.command("inspect").description("inspect internal webpack config").option("--env <env>", i18n.t(localeKeys.command.inspect.env), "development").option("--output <output>", i18n.t(localeKeys.command.inspect.output), "/").option("--verbose", i18n.t(localeKeys.command.inspect.verbose)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).action(function() {
579
- var _ref = _asyncToGenerator(function(options) {
586
+ var _ref = _asyncToGenerator(function(options2) {
580
587
  var inspect;
581
588
  return __generator(this, function(_state) {
582
589
  switch(_state.label){
@@ -587,14 +594,14 @@ var src_default = function() {
587
594
  ];
588
595
  case 1:
589
596
  inspect = _state.sent().inspect;
590
- inspect(api, options);
597
+ inspect(api, options2);
591
598
  return [
592
599
  2
593
600
  ];
594
601
  }
595
602
  });
596
603
  });
597
- return function(options) {
604
+ return function(options2) {
598
605
  return _ref.apply(this, arguments);
599
606
  };
600
607
  }());
@@ -176,16 +176,16 @@ var __generator = this && this.__generator || function(thisArg, body) {
176
176
  };
177
177
  import { ensureAbsolutePath, getPort, isDev, isDevCommand } from "@modern-js/utils";
178
178
  import { legacySchema, schema } from "../schema";
179
- import { transformNormalizedConfig } from "../config/initial/transformNormalizedConfig";
180
- import { checkIsLegacyConfig, createDefaultConfig, createLegacyDefaultConfig } from "../config";
181
- var initialize_default = function() {
179
+ import { checkIsLegacyConfig, createDefaultConfig, createLegacyDefaultConfig, transformNormalizedConfig } from "../config";
180
+ var initialize_default = function(param) {
181
+ var bundler = param.bundler;
182
182
  return {
183
183
  name: "@modern-js/plugin-initialize",
184
184
  setup: function setup(api) {
185
185
  var config = function() {
186
186
  var appContext = api.useAppContext();
187
187
  var userConfig = api.useConfigContext();
188
- return checkIsLegacyConfig(userConfig) ? createLegacyDefaultConfig(appContext) : createDefaultConfig(appContext);
188
+ return checkIsLegacyConfig(userConfig) ? createLegacyDefaultConfig(appContext) : createDefaultConfig(appContext, bundler);
189
189
  };
190
190
  var validateSchema = function() {
191
191
  var userConfig = api.useConfigContext();
@@ -216,31 +216,34 @@ var initialize_default = function() {
216
216
  });
217
217
  api.setAppContext(appContext);
218
218
  normalizedConfig = checkIsLegacyConfig(resolved) ? transformNormalizedConfig(resolved) : resolved;
219
+ resolved._raw = userConfig;
220
+ resolved.server = _objectSpreadProps(_objectSpread({}, normalizedConfig.server || {}), {
221
+ port: port
222
+ });
223
+ resolved.autoLoadPlugins = normalizedConfig.autoLoadPlugins || false;
224
+ stabilizeConfig(resolved, normalizedConfig, [
225
+ "source",
226
+ "bff",
227
+ "dev",
228
+ "html",
229
+ "output",
230
+ "tools",
231
+ "testing",
232
+ "plugins",
233
+ "builderPlugins",
234
+ "runtime",
235
+ "runtimeByEntries",
236
+ "deploy",
237
+ "performance"
238
+ ]);
239
+ if (bundler === "webpack") {
240
+ resolved.security = normalizedConfig.security || {};
241
+ resolved.experiments = normalizedConfig.experiments;
242
+ }
219
243
  return [
220
244
  2,
221
245
  {
222
- resolved: {
223
- _raw: userConfig,
224
- source: normalizedConfig.source || {},
225
- server: _objectSpreadProps(_objectSpread({}, normalizedConfig.server || {}), {
226
- port: port
227
- }),
228
- bff: normalizedConfig.bff || {},
229
- dev: normalizedConfig.dev || {},
230
- html: normalizedConfig.html || {},
231
- output: normalizedConfig.output || {},
232
- security: normalizedConfig.security || {},
233
- tools: normalizedConfig.tools || {},
234
- testing: normalizedConfig.testing || {},
235
- plugins: normalizedConfig.plugins || [],
236
- builderPlugins: normalizedConfig.builderPlugins || [],
237
- runtime: normalizedConfig.runtime || {},
238
- runtimeByEntries: normalizedConfig.runtimeByEntries || {},
239
- deploy: normalizedConfig.deploy || {},
240
- performance: normalizedConfig.performance || {},
241
- experiments: normalizedConfig.experiments || {},
242
- autoLoadPlugins: normalizedConfig.autoLoadPlugins || false
243
- }
246
+ resolved: resolved
244
247
  }
245
248
  ];
246
249
  }
@@ -251,6 +254,11 @@ var initialize_default = function() {
251
254
  }
252
255
  };
253
256
  };
257
+ function stabilizeConfig(resolve, config, keys) {
258
+ keys.forEach(function(key) {
259
+ resolve[key] = config[key] || {};
260
+ });
261
+ }
254
262
  function getServerPort(config) {
255
263
  return _getServerPort.apply(this, arguments);
256
264
  }
@@ -21,7 +21,7 @@ var ZH_LOCALE = {
21
21
  describe: "部署应用命令"
22
22
  },
23
23
  new: {
24
- describe: "MWA 项目中执行生成器",
24
+ describe: "Web App 项目中执行生成器",
25
25
  debug: "开启 Debug 模式,打印调试日志信息",
26
26
  config: "生成器运行默认配置(JSON 字符串)",
27
27
  distTag: "生成器使用特殊的 npm Tag 版本",
@@ -0,0 +1 @@
1
+ "use strict";
@@ -2,4 +2,4 @@ import { IAppContext, PluginAPI } from '@modern-js/core';
2
2
  import type { Entrypoint } from '@modern-js/types';
3
3
  import { AppNormalizedConfig, AppTools, ImportStatement } from '../types';
4
4
  export declare const createImportStatements: (statements: ImportStatement[]) => string;
5
- export declare const generateCode: (appContext: IAppContext, config: AppNormalizedConfig, entrypoints: Entrypoint[], api: PluginAPI<AppTools>) => Promise<void>;
5
+ export declare const generateCode: (appContext: IAppContext, config: AppNormalizedConfig<'shared'>, entrypoints: Entrypoint[], api: PluginAPI<AppTools<'shared'>>) => 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) => Entrypoint[];
3
+ export declare const getBundleEntry: (appContext: IAppContext, config: AppNormalizedConfig<'shared'>) => Entrypoint[];
@@ -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) => Entrypoint[];
4
+ export declare const getFileSystemEntry: (appContext: IAppContext, config: AppNormalizedConfig<'shared'>) => Entrypoint[];
@@ -1,9 +1,9 @@
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>, {
3
+ export declare const getHtmlTemplate: (entrypoints: Entrypoint[], api: PluginAPI<AppTools<'shared'>>, {
4
4
  appContext,
5
5
  config
6
6
  }: {
7
7
  appContext: IAppContext;
8
- config: AppNormalizedConfig;
8
+ config: AppNormalizedConfig<'shared'>;
9
9
  }) => Promise<HtmlTemplates>;
@@ -6,5 +6,5 @@ export declare const getServerRoutes: (entrypoints: Entrypoint[], {
6
6
  config
7
7
  }: {
8
8
  appContext: IAppContext;
9
- config: AppNormalizedConfig;
9
+ config: AppNormalizedConfig<'shared'>;
10
10
  }) => ServerRoute[];
@@ -1,6 +1,10 @@
1
1
  import type { CliPlugin } from '@modern-js/core';
2
2
  import { AppTools } from '../types';
3
3
 
4
- declare const _default: () => CliPlugin<AppTools>;
4
+ declare const _default: ({
5
+ bundler
6
+ }: {
7
+ bundler: 'webpack' | 'rspack';
8
+ }) => CliPlugin<AppTools<'shared'>>;
5
9
 
6
10
  export default _default;
@@ -0,0 +1,2 @@
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<Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>>>>;
@@ -1,6 +1,6 @@
1
1
  import { BuilderPlugin } from '@modern-js/builder-shared';
2
2
  import type { BuilderPluginAPI } from '@modern-js/builder-webpack-provider';
3
- import type { IAppContext, AppNormalizedConfig } from '../../types';
3
+ import { BuilderOptions } from '../../shared';
4
4
  type Parameter<T extends (arg: any) => void> = Parameters<T>[0];
5
5
  type FnParameter<T extends {
6
6
  [p: string]: (arg: any) => void;
@@ -10,5 +10,5 @@ export type PluginCompatModernOptions = FnParameter<Partial<Pick<BuilderPluginAP
10
10
  * Provides default configuration consistent with modern.js v1
11
11
  */
12
12
 
13
- export declare const PluginCompatModern: (appContext: IAppContext, modernConfig: AppNormalizedConfig, options?: PluginCompatModernOptions) => BuilderPlugin<BuilderPluginAPI>;
13
+ export declare const PluginCompatModern: (options: BuilderOptions<'webpack'>) => BuilderPlugin<BuilderPluginAPI>;
14
14
  export {};
@@ -0,0 +1,4 @@
1
+ import { BuilderInstance } from '@modern-js/builder';
2
+ import { BuilderWebpackProvider } from '@modern-js/builder-webpack-provider';
3
+ import { BuilderOptions } from '../shared';
4
+ export declare function createWebpackBuilderForModern(options: BuilderOptions<'webpack'>): Promise<BuilderInstance<BuilderWebpackProvider>>;
@@ -1,4 +1,4 @@
1
1
  import type { Compiler } from 'webpack';
2
- export default class RouterPlugin {
2
+ export declare class RouterPlugin {
3
3
  apply(compiler: Compiler): void;
4
4
  }
@@ -0,0 +1 @@
1
+ export * from './RouterPlugin';
@@ -0,0 +1,3 @@
1
+ import type { BuilderTarget, CreateBuilderOptions } from '@modern-js/builder-shared';
2
+ import type { IAppContext } from '@modern-js/core';
3
+ export declare function createBuilderOptions(target: BuilderTarget | BuilderTarget[], appContext: IAppContext): CreateBuilderOptions;
@@ -0,0 +1,2 @@
1
+ import type { AppNormalizedConfig, Bundler, IAppContext } from '../../types';
2
+ export declare function createBuilderProviderConfig<B extends Bundler>(resolveConfig: AppNormalizedConfig<B>, appContext: IAppContext, modifyBuilderConfig?: (config: AppNormalizedConfig<B>) => void): AppNormalizedConfig<B>;
@@ -0,0 +1,3 @@
1
+ import type { BuilderTarget } from '@modern-js/builder-shared';
2
+ import type { AppNormalizedConfig } from '../../types';
3
+ export declare function getBuilderTargets(normalizedConfig: AppNormalizedConfig<'shared'>): BuilderTarget[];
@@ -0,0 +1,17 @@
1
+ import type { BuilderProvider, BuilderInstance } from '@modern-js/builder-shared';
2
+ import { BuilderOptions, ModifyBuilderConfig, ModifyBuilderInstance } from '../shared';
3
+ import { Bundler } from '../../types';
4
+ export type GenerateProvider = (c: {
5
+ builderConfig: any;
6
+ }) => BuilderProvider;
7
+ /**
8
+ * @param options BuilderOptions
9
+ * @param generateProvider GenerateProvider
10
+ * @param utils - ModifyBuilderConfig, ModifyBuilderInstance
11
+ * @returns BuilderInstance
12
+ */
13
+
14
+ export declare function generateBuilder<B extends Bundler>(options: BuilderOptions<B>, generateProvider: GenerateProvider, utils?: {
15
+ modifyBuilderConfig?: ModifyBuilderConfig<B>;
16
+ modifyBuilderInstance?: ModifyBuilderInstance;
17
+ }): Promise<BuilderInstance<BuilderProvider<Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>>>>;
@@ -1,18 +1 @@
1
- import { BuilderInstance, BuilderTarget, CreateBuilderOptions } from '@modern-js/builder';
2
- import { BuilderConfig, BuilderWebpackProvider } from '@modern-js/builder-webpack-provider';
3
- import type { IAppContext } from '@modern-js/core';
4
- import type { AppNormalizedConfig } from '../types';
5
- import { PluginCompatModernOptions } from './builderPlugins/compatModern';
6
- export type BuilderOptions = {
7
- target?: BuilderTarget | BuilderTarget[];
8
- normalizedConfig: AppNormalizedConfig;
9
- appContext: IAppContext;
10
- compatPluginConfig?: PluginCompatModernOptions;
11
- };
12
- export declare function createBuilderForModern({
13
- normalizedConfig,
14
- appContext,
15
- compatPluginConfig
16
- }: BuilderOptions): Promise<BuilderInstance<BuilderWebpackProvider>>;
17
- export declare function createBuilderProviderConfig(normalizedConfig: AppNormalizedConfig, appContext: IAppContext): BuilderConfig;
18
- export declare function createBuilderOptions(target: BuilderTarget | BuilderTarget[], appContext: IAppContext): CreateBuilderOptions;
1
+ export declare function createBuilderGenerator(bundler: 'webpack' | 'rspack'): Promise<typeof import("./builder-rspack").createRspackBuilderForModern | typeof import("./builder-webpack").createWebpackBuilderForModern>;
@@ -0,0 +1,13 @@
1
+ import { BuilderPlugin, DefaultBuilderPluginAPI } from '@modern-js/builder-shared';
2
+ import { BuilderConfig as RspackBuilderConfig, NormalizedConfig as RspackNormalizedConfig } from '@modern-js/builder-rspack-provider';
3
+ import { BuilderConfig as WebpackBuilderConfig, NormalizedConfig as WebpackNormalizedConfig } from '@modern-js/builder-webpack-provider';
4
+ import type { BuilderOptions } from '../types';
5
+ import type { Bundler } from '../../../types';
6
+ type BuilderConfig = RspackBuilderConfig | WebpackBuilderConfig;
7
+ type NormalizedConfig = RspackNormalizedConfig | WebpackNormalizedConfig;
8
+ type BuilderPluginAPI = DefaultBuilderPluginAPI<BuilderConfig, NormalizedConfig>;
9
+ export declare const builderPluginAdapterModern: <B extends Bundler>(options: BuilderOptions<B>) => BuilderPlugin<BuilderPluginAPI>;
10
+ /** register builder hooks callback */
11
+
12
+ export declare function applyCallbacks<B extends Bundler>(api: BuilderPluginAPI, options: BuilderOptions<B>): void;
13
+ export {};
@@ -1,8 +1,9 @@
1
1
  import type { webpack } from '@modern-js/builder-webpack-provider';
2
+ import type { Rspack } from '@modern-js/builder-rspack-provider';
2
3
  import type HtmlWebpackPlugin from '@modern-js/builder-webpack-provider/html-webpack-plugin';
3
4
  export declare class HtmlAsyncChunkPlugin {
4
5
  name: string;
5
6
  htmlWebpackPlugin: typeof HtmlWebpackPlugin;
6
7
  constructor(htmlWebpackPlugin: typeof HtmlWebpackPlugin);
7
- apply(compiler: webpack.Compiler): void;
8
+ apply(compiler: webpack.Compiler | Rspack.Compiler): void;
8
9
  }
@@ -1,4 +1,5 @@
1
1
  import type { webpack } from '@modern-js/builder-webpack-provider';
2
+ import type { Rspack } from '@modern-js/builder-rspack-provider';
2
3
  import type HtmlWebpackPlugin from '@modern-js/builder-webpack-provider/html-webpack-plugin';
3
4
  export declare class BottomTemplatePlugin {
4
5
  htmlWebpackPlugin: typeof HtmlWebpackPlugin;
@@ -6,5 +7,5 @@ export declare class BottomTemplatePlugin {
6
7
  bodyRegExp: RegExp;
7
8
  name: string;
8
9
  constructor(htmlWebpackPlugin: typeof HtmlWebpackPlugin);
9
- apply(compiler: webpack.Compiler): void;
10
+ apply(compiler: Rspack.Compiler | webpack.Compiler): void;
10
11
  }
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { WebpackChain } from '@modern-js/builder-webpack-provider';
3
- import { AppNormalizedConfig, IAppContext } from '../types';
3
+ import { AppNormalizedConfig, IAppContext } from '../../types';
4
4
  export declare function createCopyPattern(appContext: IAppContext, config: AppNormalizedConfig, patternsType: 'upload' | 'public', chain?: WebpackChain): {
5
5
  info: (file: {
6
6
  sourceFilename: string;
@@ -0,0 +1,3 @@
1
+ export * from './createCopyPattern';
2
+ export * from './types';
3
+ export * from './builderPlugins/adapterModern';
@@ -0,0 +1,4 @@
1
+ import type { webpack } from '@modern-js/builder-webpack-provider';
2
+ import type { Rspack } from '@modern-js/builder-rspack-provider';
3
+ declare function loader(this: webpack.LoaderContext<void> | Rspack.LoaderContext): string;
4
+ export default loader;
@@ -0,0 +1,16 @@
1
+ import type { BuilderPluginAPI as WebpackBuilderPluginAPI } from '@modern-js/builder-webpack-provider';
2
+ import type { BuilderPluginAPI as RspackBuilderPluginAPI } from '@modern-js/builder-rspack-provider';
3
+ import { BuilderInstance } from '@modern-js/builder-shared';
4
+ import { AppNormalizedConfig, Bundler, IAppContext } from '../../types';
5
+ type Parameter<T extends (arg: any) => void> = Parameters<T>[0];
6
+ type FnParameter<T extends {
7
+ [p: string]: (arg: any) => void;
8
+ }> = { [P in keyof T]: Parameter<T[P]> };
9
+ type BuilderPluginCallbacks<B extends Bundler> = FnParameter<Partial<Pick<B extends 'rspack' ? RspackBuilderPluginAPI : WebpackBuilderPluginAPI, 'onAfterBuild' | 'onAfterCreateCompiler' | 'onAfterStartDevServer' | 'onBeforeBuild' | 'onBeforeCreateCompiler' | 'onBeforeStartDevServer' | 'onDevCompileDone' | 'onExit'>>>;
10
+ export type BuilderOptions<B extends Bundler> = {
11
+ normalizedConfig: AppNormalizedConfig<B>;
12
+ appContext: IAppContext;
13
+ } & BuilderPluginCallbacks<B>;
14
+ export type ModifyBuilderConfig<B extends Bundler> = (config: AppNormalizedConfig<B>) => Promise<void> | void;
15
+ export type ModifyBuilderInstance = (builder: BuilderInstance) => Promise<void> | void;
16
+ export {};
@@ -1,4 +1,4 @@
1
1
  import { PluginAPI } from '@modern-js/core';
2
2
  import type { BuildOptions } from '../utils/types';
3
3
  import type { AppTools } from '../types';
4
- export declare const build: (api: PluginAPI<AppTools>, options?: BuildOptions) => Promise<void>;
4
+ export declare const build: (api: PluginAPI<AppTools<'shared'>>, options?: BuildOptions) => Promise<void>;
@@ -1,3 +1,3 @@
1
1
  import type { PluginAPI } from '@modern-js/core';
2
2
  import type { AppTools } from '../types';
3
- export declare const deploy: (api: PluginAPI<AppTools>, options: any) => Promise<void>;
3
+ export declare const deploy: (api: PluginAPI<AppTools<'shared'>>, options: any) => Promise<void>;
@@ -1,4 +1,4 @@
1
1
  import { PluginAPI } from '@modern-js/core';
2
2
  import { DevOptions } from '../utils/types';
3
3
  import type { AppTools } from '../types';
4
- export declare const dev: (api: PluginAPI<AppTools>, options: DevOptions) => Promise<void>;
4
+ export declare const dev: (api: PluginAPI<AppTools<'shared'>>, options: DevOptions) => Promise<void>;
@@ -1,7 +1,7 @@
1
1
  import type { PluginAPI } from '@modern-js/core';
2
2
  import type { InspectOptions } from '../utils/types';
3
3
  import type { AppTools } from '../types';
4
- export declare const inspect: (api: PluginAPI<AppTools>, options: InspectOptions) => Promise<{
4
+ export declare const inspect: (api: PluginAPI<AppTools<'shared'>>, options: InspectOptions) => Promise<{
5
5
  builderConfig: string;
6
6
  bundlerConfigs: string[];
7
7
  origin: {
@@ -1,3 +1,3 @@
1
1
  import type { PluginAPI } from '@modern-js/core';
2
2
  import type { AppTools } from '../types';
3
- export declare const start: (api: PluginAPI<AppTools>) => Promise<void>;
3
+ export declare const start: (api: PluginAPI<AppTools<'shared'>>) => Promise<void>;
@@ -1,3 +1,3 @@
1
1
  import { IAppContext, AppUserConfig, AppLegacyUserConfig } from '../types';
2
- export declare function createDefaultConfig(appContext: IAppContext): AppUserConfig;
2
+ export declare function createDefaultConfig(appContext: IAppContext, bundler: 'webpack' | 'rspack'): AppUserConfig<'webpack'> | AppUserConfig<'rspack'>;
3
3
  export declare function createLegacyDefaultConfig(appContext: IAppContext): AppLegacyUserConfig;
@@ -1,2 +1,3 @@
1
- export { createDefaultConfig, createLegacyDefaultConfig } from './default';
2
- export { initialNormalizedConfig, checkIsLegacyConfig } from './initial';
1
+ export * from './legacy';
2
+ export * from './initialize';
3
+ export * from './default';
@@ -0,0 +1,2 @@
1
+ import type { AppNormalizedConfig, IAppContext } from '../../types';
2
+ export declare function initialNormalizedConfig(config: AppNormalizedConfig<'shared'>, appContext: IAppContext, bundler: 'webpack' | 'rspack'): AppNormalizedConfig<'shared'>;
@@ -1,4 +1,4 @@
1
1
  import { AppNormalizedConfig, IAppContext } from '../../types';
2
- export declare function initHtmlConfig(config: AppNormalizedConfig, appContext: IAppContext): import("@modern-js/builder-shared").SharedHtmlConfig;
3
- export declare function initSourceConfig(config: AppNormalizedConfig, appContext: IAppContext): void;
4
- export declare function initToolsConfig(config: AppNormalizedConfig): void;
2
+ export declare function initHtmlConfig(config: AppNormalizedConfig<'shared'>, appContext: IAppContext): import("@modern-js/builder-shared").SharedHtmlConfig;
3
+ export declare function initSourceConfig(config: AppNormalizedConfig<'shared'>, appContext: IAppContext, bundler: 'webpack' | 'rspack'): void;
4
+ export declare function initToolsConfig(config: AppNormalizedConfig<'webpack'>): void;
@@ -1,2 +1,2 @@
1
1
  import { AppLegacyNormalizedConfig, AppNormalizedConfig } from '../../types';
2
- export declare function createHtmlConfig(config: Readonly<AppLegacyNormalizedConfig>): AppNormalizedConfig['html'];
2
+ export declare function createHtmlConfig(config: Readonly<AppLegacyNormalizedConfig>): AppNormalizedConfig<'webpack'>['html'];
@@ -1,2 +1,2 @@
1
1
  import { AppLegacyNormalizedConfig, AppNormalizedConfig } from '../../types';
2
- export declare function createOutputConfig(config: Readonly<AppLegacyNormalizedConfig>): AppNormalizedConfig['output'];
2
+ export declare function createOutputConfig(config: Readonly<AppLegacyNormalizedConfig>): AppNormalizedConfig<'webpack'>['output'];
@@ -1,2 +1,2 @@
1
1
  import { AppLegacyNormalizedConfig, AppNormalizedConfig } from '../../types';
2
- export declare function createSourceConfig(config: AppLegacyNormalizedConfig): AppNormalizedConfig['source'];
2
+ export declare function createSourceConfig(config: AppLegacyNormalizedConfig): AppNormalizedConfig<'webpack'>['source'];
@@ -1,2 +1,2 @@
1
1
  import { AppLegacyNormalizedConfig, AppNormalizedConfig } from '../../types';
2
- export declare function createToolsConfig(config: AppLegacyNormalizedConfig): AppNormalizedConfig['tools'];
2
+ export declare function createToolsConfig(config: AppLegacyNormalizedConfig): AppNormalizedConfig<'webpack'>['tools'];
@@ -0,0 +1,3 @@
1
+ import type { AppLegacyNormalizedConfig, AppLegacyUserConfig, AppNormalizedConfig, AppUserConfig } from '../../types';
2
+ export declare function transformNormalizedConfig(config: AppLegacyNormalizedConfig): AppNormalizedConfig<'webpack'>;
3
+ export declare function checkIsLegacyConfig(config: AppLegacyUserConfig | AppUserConfig): config is AppLegacyUserConfig;
@@ -1,6 +1,6 @@
1
1
  import type { UserConfigExport } from '@modern-js/core';
2
- import type { AppUserConfig, AppLegacyUserConfig } from './types';
3
- export declare const defineConfig: (config: UserConfigExport<AppUserConfig>) => UserConfigExport<AppUserConfig>;
2
+ import type { AppLegacyUserConfig, AppUserConfig } from './types';
3
+ export declare const defineConfig: <B extends "webpack" | "rspack" = "webpack">(config: UserConfigExport<AppUserConfig<B>>) => UserConfigExport<AppUserConfig<B>>;
4
4
  /**
5
5
  * @deprecated
6
6
  * Using defineConfig first.
@@ -4,9 +4,13 @@ import { AppTools } from './types';
4
4
  export * from './defineConfig';
5
5
  export * from './types';
6
6
  export type { RuntimeUserConfig } from './types/config';
7
- export declare const devCommand: (program: Command, api: PluginAPI<AppTools>) => Promise<void>;
8
- export declare const buildCommand: (program: Command, api: PluginAPI<AppTools>) => Promise<void>;
7
+ export declare const devCommand: (program: Command, api: PluginAPI<AppTools<'shared'>>) => Promise<void>;
8
+ export declare const buildCommand: (program: Command, api: PluginAPI<AppTools<'shared'>>) => Promise<void>;
9
+ interface AppToolsOptions {
10
+ /** Specify the use what kind of bundler to compiler, default: `webpack` */
11
+ bundler?: 'experimental-rspack' | 'webpack';
12
+ }
9
13
 
10
- declare const _default: () => CliPlugin<AppTools>;
14
+ declare const _default: (options?: AppToolsOptions) => CliPlugin<AppTools<'shared'>>;
11
15
 
12
16
  export default _default;