@modern-js/app-tools 2.5.0 → 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 (260) hide show
  1. package/dist/cjs/analyze/generateCode.js +13 -19
  2. package/dist/cjs/analyze/getBundleEntry.js +1 -1
  3. package/dist/cjs/builder/builder-webpack/builderPlugins/compatModern.js +3 -3
  4. package/dist/cjs/builder/builder-webpack/index.js +5 -11
  5. package/dist/cjs/builder/generator/getBuilderTargets.js +1 -1
  6. package/dist/cjs/commands/dev.js +14 -6
  7. package/dist/cjs/config/legacy/createToolsConfig.js +4 -1
  8. package/dist/esm/analyze/generateCode.js +26 -37
  9. package/dist/esm/analyze/getBundleEntry.js +2 -2
  10. package/dist/esm/builder/builder-webpack/builderPlugins/compatModern.js +2 -2
  11. package/dist/esm/builder/builder-webpack/index.js +7 -11
  12. package/dist/esm/builder/generator/getBuilderTargets.js +1 -1
  13. package/dist/esm/commands/dev.js +8 -3
  14. package/dist/esm/config/legacy/createToolsConfig.js +4 -1
  15. package/dist/esm-node/analyze/generateCode.js +14 -20
  16. package/dist/esm-node/analyze/getBundleEntry.js +3 -2
  17. package/dist/esm-node/builder/builder-webpack/builderPlugins/compatModern.js +2 -2
  18. package/dist/esm-node/builder/builder-webpack/index.js +6 -12
  19. package/dist/esm-node/builder/generator/getBuilderTargets.js +1 -1
  20. package/dist/esm-node/commands/dev.js +14 -6
  21. package/dist/esm-node/config/legacy/createToolsConfig.js +4 -1
  22. package/dist/js/modern/analyze/constants.js +54 -0
  23. package/dist/js/modern/analyze/generateCode.js +247 -0
  24. package/dist/js/modern/analyze/getBundleEntry.js +71 -0
  25. package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +220 -0
  26. package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +216 -0
  27. package/dist/js/modern/analyze/getClientRoutes/index.js +6 -0
  28. package/dist/js/modern/analyze/getClientRoutes/utils.js +31 -0
  29. package/dist/js/modern/analyze/getFileSystemEntry.js +109 -0
  30. package/dist/js/modern/analyze/getHtmlTemplate.js +115 -0
  31. package/dist/js/modern/analyze/getServerRoutes.js +175 -0
  32. package/dist/js/modern/analyze/index.js +332 -0
  33. package/dist/js/modern/analyze/isDefaultExportFunction.js +42 -0
  34. package/dist/js/modern/analyze/makeLegalIdentifier.js +13 -0
  35. package/dist/js/modern/analyze/nestedRoutes.js +157 -0
  36. package/dist/js/modern/analyze/templates.js +334 -0
  37. package/dist/js/modern/analyze/utils.js +141 -0
  38. package/dist/js/modern/builder/builderPlugins/compatModern.js +233 -0
  39. package/dist/js/modern/builder/index.js +159 -0
  40. package/dist/js/modern/builder/loaders/routerLoader.js +17 -0
  41. package/dist/js/modern/builder/loaders/serverModuleLoader.js +7 -0
  42. package/dist/js/modern/builder/share.js +46 -0
  43. package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +30 -0
  44. package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +37 -0
  45. package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +113 -0
  46. package/dist/js/modern/commands/build.js +91 -0
  47. package/dist/js/modern/commands/deploy.js +28 -0
  48. package/dist/js/modern/commands/dev.js +109 -0
  49. package/dist/js/modern/commands/index.js +3 -0
  50. package/dist/js/modern/commands/inspect.js +38 -0
  51. package/dist/js/modern/commands/serve.js +54 -0
  52. package/dist/js/modern/config/default.js +175 -0
  53. package/dist/js/modern/config/index.js +8 -0
  54. package/dist/js/modern/config/initial/createHtmlConfig.js +35 -0
  55. package/dist/js/modern/config/initial/createOutputConfig.js +68 -0
  56. package/dist/js/modern/config/initial/createSourceConfig.js +39 -0
  57. package/dist/js/modern/config/initial/createToolsConfig.js +42 -0
  58. package/dist/js/modern/config/initial/index.js +16 -0
  59. package/dist/js/modern/config/initial/inits.js +152 -0
  60. package/dist/js/modern/config/initial/transformNormalizedConfig.js +47 -0
  61. package/dist/js/modern/defineConfig.js +27 -0
  62. package/dist/js/modern/exports/server.js +4 -0
  63. package/dist/js/modern/hooks.js +35 -0
  64. package/dist/js/modern/index.js +211 -0
  65. package/dist/js/modern/initialize/index.js +124 -0
  66. package/dist/js/modern/locale/en.js +36 -0
  67. package/dist/js/modern/locale/index.js +9 -0
  68. package/dist/js/modern/locale/zh.js +36 -0
  69. package/dist/js/modern/schema/Schema.js +40 -0
  70. package/dist/js/modern/schema/index.js +88 -0
  71. package/dist/js/modern/schema/legacy.js +148 -0
  72. package/dist/js/modern/types/config/deploy.js +0 -0
  73. package/dist/js/modern/types/config/dev.js +0 -0
  74. package/dist/js/modern/types/config/experiments.js +0 -0
  75. package/dist/js/modern/types/config/html.js +0 -0
  76. package/dist/js/modern/types/config/index.js +1 -0
  77. package/dist/js/modern/types/config/output.js +0 -0
  78. package/dist/js/modern/types/config/performance.js +0 -0
  79. package/dist/js/modern/types/config/security.js +0 -0
  80. package/dist/js/modern/types/config/source.js +0 -0
  81. package/dist/js/modern/types/config/tools.js +0 -0
  82. package/dist/js/modern/types/hooks.js +0 -0
  83. package/dist/js/modern/types/index.js +3 -0
  84. package/dist/js/modern/types/legacyConfig/deploy.js +0 -0
  85. package/dist/js/modern/types/legacyConfig/dev.js +0 -0
  86. package/dist/js/modern/types/legacyConfig/index.js +0 -0
  87. package/dist/js/modern/types/legacyConfig/output.js +0 -0
  88. package/dist/js/modern/types/legacyConfig/source.js +0 -0
  89. package/dist/js/modern/types/legacyConfig/tools.js +0 -0
  90. package/dist/js/modern/utils/config.js +128 -0
  91. package/dist/js/modern/utils/createServer.js +75 -0
  92. package/dist/js/modern/utils/env.js +15 -0
  93. package/dist/js/modern/utils/generateWatchFiles.js +55 -0
  94. package/dist/js/modern/utils/getSelectedEntries.js +58 -0
  95. package/dist/js/modern/utils/getServerInternalPlugins.js +58 -0
  96. package/dist/js/modern/utils/language.js +8 -0
  97. package/dist/js/modern/utils/printInstructions.js +31 -0
  98. package/dist/js/modern/utils/restart.js +44 -0
  99. package/dist/js/modern/utils/routes.js +30 -0
  100. package/dist/js/modern/utils/types.js +0 -0
  101. package/dist/js/node/analyze/constants.js +98 -0
  102. package/dist/js/node/analyze/generateCode.js +271 -0
  103. package/dist/js/node/analyze/getBundleEntry.js +95 -0
  104. package/dist/js/node/analyze/getClientRoutes/getRoutes.js +242 -0
  105. package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +238 -0
  106. package/dist/js/node/analyze/getClientRoutes/index.js +30 -0
  107. package/dist/js/node/analyze/getClientRoutes/utils.js +58 -0
  108. package/dist/js/node/analyze/getFileSystemEntry.js +131 -0
  109. package/dist/js/node/analyze/getHtmlTemplate.js +144 -0
  110. package/dist/js/node/analyze/getServerRoutes.js +194 -0
  111. package/dist/js/node/analyze/index.js +339 -0
  112. package/dist/js/node/analyze/isDefaultExportFunction.js +71 -0
  113. package/dist/js/node/analyze/makeLegalIdentifier.js +36 -0
  114. package/dist/js/node/analyze/nestedRoutes.js +184 -0
  115. package/dist/js/node/analyze/templates.js +365 -0
  116. package/dist/js/node/analyze/utils.js +172 -0
  117. package/dist/js/node/builder/builderPlugins/compatModern.js +258 -0
  118. package/dist/js/node/builder/index.js +177 -0
  119. package/dist/js/node/builder/loaders/routerLoader.js +38 -0
  120. package/dist/js/node/builder/loaders/serverModuleLoader.js +28 -0
  121. package/dist/js/node/builder/share.js +75 -0
  122. package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +53 -0
  123. package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +60 -0
  124. package/dist/js/node/builder/webpackPlugins/routerPlugin.js +135 -0
  125. package/dist/js/node/commands/build.js +112 -0
  126. package/dist/js/node/commands/deploy.js +51 -0
  127. package/dist/js/node/commands/dev.js +126 -0
  128. package/dist/js/node/commands/index.js +19 -0
  129. package/dist/js/node/commands/inspect.js +61 -0
  130. package/dist/js/node/commands/serve.js +83 -0
  131. package/dist/js/node/config/default.js +197 -0
  132. package/dist/js/node/config/index.js +34 -0
  133. package/dist/js/node/config/initial/createHtmlConfig.js +58 -0
  134. package/dist/js/node/config/initial/createOutputConfig.js +91 -0
  135. package/dist/js/node/config/initial/createSourceConfig.js +62 -0
  136. package/dist/js/node/config/initial/createToolsConfig.js +65 -0
  137. package/dist/js/node/config/initial/index.js +41 -0
  138. package/dist/js/node/config/initial/inits.js +175 -0
  139. package/dist/js/node/config/initial/transformNormalizedConfig.js +70 -0
  140. package/dist/js/node/defineConfig.js +49 -0
  141. package/dist/js/node/exports/server.js +27 -0
  142. package/dist/js/node/hooks.js +54 -0
  143. package/dist/js/node/index.js +235 -0
  144. package/dist/js/node/initialize/index.js +134 -0
  145. package/dist/js/node/locale/en.js +59 -0
  146. package/dist/js/node/locale/index.js +33 -0
  147. package/dist/js/node/locale/zh.js +59 -0
  148. package/dist/js/node/schema/Schema.js +63 -0
  149. package/dist/js/node/schema/index.js +118 -0
  150. package/dist/js/node/schema/legacy.js +169 -0
  151. package/dist/js/node/types/config/deploy.js +15 -0
  152. package/dist/js/node/types/config/dev.js +15 -0
  153. package/dist/js/node/types/config/experiments.js +15 -0
  154. package/dist/js/node/types/config/html.js +15 -0
  155. package/dist/js/node/types/config/index.js +17 -0
  156. package/dist/js/node/types/config/output.js +15 -0
  157. package/dist/js/node/types/config/performance.js +15 -0
  158. package/dist/js/node/types/config/security.js +15 -0
  159. package/dist/js/node/types/config/source.js +15 -0
  160. package/dist/js/node/types/config/tools.js +15 -0
  161. package/dist/js/node/types/hooks.js +15 -0
  162. package/dist/js/node/types/index.js +19 -0
  163. package/dist/js/node/types/legacyConfig/deploy.js +15 -0
  164. package/dist/js/node/types/legacyConfig/dev.js +15 -0
  165. package/dist/js/node/types/legacyConfig/index.js +15 -0
  166. package/dist/js/node/types/legacyConfig/output.js +15 -0
  167. package/dist/js/node/types/legacyConfig/source.js +15 -0
  168. package/dist/js/node/types/legacyConfig/tools.js +15 -0
  169. package/dist/js/node/utils/config.js +153 -0
  170. package/dist/js/node/utils/createServer.js +106 -0
  171. package/dist/js/node/utils/env.js +38 -0
  172. package/dist/js/node/utils/generateWatchFiles.js +85 -0
  173. package/dist/js/node/utils/getSelectedEntries.js +81 -0
  174. package/dist/js/node/utils/getServerInternalPlugins.js +79 -0
  175. package/dist/js/node/utils/language.js +31 -0
  176. package/dist/js/node/utils/printInstructions.js +54 -0
  177. package/dist/js/node/utils/restart.js +67 -0
  178. package/dist/js/node/utils/routes.js +59 -0
  179. package/dist/js/node/utils/types.js +15 -0
  180. package/dist/js/treeshaking/analyze/constants.js +40 -0
  181. package/dist/js/treeshaking/analyze/generateCode.js +485 -0
  182. package/dist/js/treeshaking/analyze/getBundleEntry.js +62 -0
  183. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +233 -0
  184. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +231 -0
  185. package/dist/js/treeshaking/analyze/getClientRoutes/index.js +3 -0
  186. package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +23 -0
  187. package/dist/js/treeshaking/analyze/getFileSystemEntry.js +107 -0
  188. package/dist/js/treeshaking/analyze/getHtmlTemplate.js +302 -0
  189. package/dist/js/treeshaking/analyze/getServerRoutes.js +222 -0
  190. package/dist/js/treeshaking/analyze/index.js +697 -0
  191. package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +47 -0
  192. package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +13 -0
  193. package/dist/js/treeshaking/analyze/nestedRoutes.js +384 -0
  194. package/dist/js/treeshaking/analyze/templates.js +468 -0
  195. package/dist/js/treeshaking/analyze/utils.js +374 -0
  196. package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +304 -0
  197. package/dist/js/treeshaking/builder/index.js +374 -0
  198. package/dist/js/treeshaking/builder/loaders/routerLoader.js +13 -0
  199. package/dist/js/treeshaking/builder/loaders/serverModuleLoader.js +5 -0
  200. package/dist/js/treeshaking/builder/share.js +40 -0
  201. package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +110 -0
  202. package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +72 -0
  203. package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +343 -0
  204. package/dist/js/treeshaking/commands/build.js +291 -0
  205. package/dist/js/treeshaking/commands/deploy.js +154 -0
  206. package/dist/js/treeshaking/commands/dev.js +301 -0
  207. package/dist/js/treeshaking/commands/index.js +3 -0
  208. package/dist/js/treeshaking/commands/inspect.js +149 -0
  209. package/dist/js/treeshaking/commands/serve.js +199 -0
  210. package/dist/js/treeshaking/config/default.js +210 -0
  211. package/dist/js/treeshaking/config/index.js +3 -0
  212. package/dist/js/treeshaking/config/initial/createHtmlConfig.js +19 -0
  213. package/dist/js/treeshaking/config/initial/createOutputConfig.js +41 -0
  214. package/dist/js/treeshaking/config/initial/createSourceConfig.js +42 -0
  215. package/dist/js/treeshaking/config/initial/createToolsConfig.js +23 -0
  216. package/dist/js/treeshaking/config/initial/index.js +12 -0
  217. package/dist/js/treeshaking/config/initial/inits.js +209 -0
  218. package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +35 -0
  219. package/dist/js/treeshaking/defineConfig.js +61 -0
  220. package/dist/js/treeshaking/exports/server.js +2 -0
  221. package/dist/js/treeshaking/hooks.js +29 -0
  222. package/dist/js/treeshaking/index.js +706 -0
  223. package/dist/js/treeshaking/initialize/index.js +276 -0
  224. package/dist/js/treeshaking/locale/en.js +38 -0
  225. package/dist/js/treeshaking/locale/index.js +9 -0
  226. package/dist/js/treeshaking/locale/zh.js +38 -0
  227. package/dist/js/treeshaking/schema/Schema.js +273 -0
  228. package/dist/js/treeshaking/schema/index.js +181 -0
  229. package/dist/js/treeshaking/schema/legacy.js +337 -0
  230. package/dist/js/treeshaking/types/config/deploy.js +1 -0
  231. package/dist/js/treeshaking/types/config/dev.js +1 -0
  232. package/dist/js/treeshaking/types/config/experiments.js +1 -0
  233. package/dist/js/treeshaking/types/config/html.js +1 -0
  234. package/dist/js/treeshaking/types/config/index.js +1 -0
  235. package/dist/js/treeshaking/types/config/output.js +1 -0
  236. package/dist/js/treeshaking/types/config/performance.js +1 -0
  237. package/dist/js/treeshaking/types/config/security.js +1 -0
  238. package/dist/js/treeshaking/types/config/source.js +1 -0
  239. package/dist/js/treeshaking/types/config/tools.js +1 -0
  240. package/dist/js/treeshaking/types/hooks.js +1 -0
  241. package/dist/js/treeshaking/types/index.js +3 -0
  242. package/dist/js/treeshaking/types/legacyConfig/deploy.js +1 -0
  243. package/dist/js/treeshaking/types/legacyConfig/dev.js +1 -0
  244. package/dist/js/treeshaking/types/legacyConfig/index.js +1 -0
  245. package/dist/js/treeshaking/types/legacyConfig/output.js +1 -0
  246. package/dist/js/treeshaking/types/legacyConfig/source.js +1 -0
  247. package/dist/js/treeshaking/types/legacyConfig/tools.js +1 -0
  248. package/dist/js/treeshaking/utils/config.js +302 -0
  249. package/dist/js/treeshaking/utils/createServer.js +258 -0
  250. package/dist/js/treeshaking/utils/env.js +13 -0
  251. package/dist/js/treeshaking/utils/generateWatchFiles.js +214 -0
  252. package/dist/js/treeshaking/utils/getSelectedEntries.js +186 -0
  253. package/dist/js/treeshaking/utils/getServerInternalPlugins.js +210 -0
  254. package/dist/js/treeshaking/utils/language.js +6 -0
  255. package/dist/js/treeshaking/utils/printInstructions.js +152 -0
  256. package/dist/js/treeshaking/utils/restart.js +187 -0
  257. package/dist/js/treeshaking/utils/routes.js +153 -0
  258. package/dist/js/treeshaking/utils/types.js +1 -0
  259. package/dist/types/builder/builder-webpack/builderPlugins/compatModern.d.ts +1 -7
  260. package/package.json +11 -11
@@ -83,7 +83,6 @@ ${initialize || ""}`
83
83
  ).join("\n");
84
84
  };
85
85
  const generateCode = async (appContext, config, entrypoints, api) => {
86
- var _a, _b, _c;
87
86
  const {
88
87
  internalDirectory,
89
88
  srcDirectory,
@@ -92,7 +91,7 @@ const generateCode = async (appContext, config, entrypoints, api) => {
92
91
  packageName
93
92
  } = appContext;
94
93
  const hookRunners = api.useHookRunners();
95
- const isV5 = typeof ((_a = config.runtime) == null ? void 0 : _a.router) !== "boolean" && ((_c = (_b = config == null ? void 0 : config.runtime) == null ? void 0 : _b.router) == null ? void 0 : _c.mode) === "react-router-5";
94
+ const isV5 = (0, import_utils.isRouterV5)(config);
96
95
  const { mountId } = config.html;
97
96
  const getRoutes = isV5 ? import_getClientRoutes.getClientRoutesLegacy : import_getClientRoutes.getClientRoutes;
98
97
  await Promise.all(entrypoints.map(generateEntryCode));
@@ -111,23 +110,18 @@ const generateCode = async (appContext, config, entrypoints, api) => {
111
110
  internalDirAlias
112
111
  });
113
112
  }
114
- if (entrypoint.nestedRoutesEntry) {
115
- if (!isV5) {
116
- nestedRoute = await (0, import_nestedRoutes.walk)(
117
- entrypoint.nestedRoutesEntry,
118
- entrypoint.nestedRoutesEntry,
119
- {
120
- name: internalSrcAlias,
121
- basename: srcDirectory
122
- },
123
- entrypoint.entryName
124
- );
125
- if (nestedRoute) {
126
- initialRoutes.unshift(nestedRoute);
127
- }
128
- } else {
129
- import_utils.logger.error("Nested routes is not supported in legacy mode.");
130
- process.exit(1);
113
+ if (!isV5 && entrypoint.nestedRoutesEntry) {
114
+ nestedRoute = await (0, import_nestedRoutes.walk)(
115
+ entrypoint.nestedRoutesEntry,
116
+ entrypoint.nestedRoutesEntry,
117
+ {
118
+ name: internalSrcAlias,
119
+ basename: srcDirectory
120
+ },
121
+ entrypoint.entryName
122
+ );
123
+ if (nestedRoute) {
124
+ initialRoutes.unshift(nestedRoute);
131
125
  }
132
126
  }
133
127
  const { routes } = await hookRunners.modifyFileSystemRoutes({
@@ -78,7 +78,7 @@ const getBundleEntry = (appContext, config) => {
78
78
  customBootstrap: value.customBootstrap && (0, import_utils.ensureAbsolutePath)(appDirectory, value.customBootstrap),
79
79
  fileSystemRoutes: import_utils.fs.statSync((0, import_utils.ensureAbsolutePath)(appDirectory, value.entry)).isDirectory() ? {} : void 0
80
80
  };
81
- if (entrypoint.fileSystemRoutes) {
81
+ if (entrypoint.fileSystemRoutes && (0, import_utils.isRouterV5)(config)) {
82
82
  entrypoint.nestedRoutesEntry = entrypoint.entry;
83
83
  }
84
84
  if (!ifAlreadyExists(defaults, entrypoint)) {
@@ -17,13 +17,13 @@ var __copyProps = (to, from, except, desc) => {
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
  var compatModern_exports = {};
19
19
  __export(compatModern_exports, {
20
- PluginCompatModern: () => PluginCompatModern
20
+ builderPluginCompatModern: () => builderPluginCompatModern
21
21
  });
22
22
  module.exports = __toCommonJS(compatModern_exports);
23
23
  var import_path = require("path");
24
24
  var import_shared = require("../../shared");
25
25
  var import_webpackPlugins = require("../webpackPlugins");
26
- const PluginCompatModern = (options) => ({
26
+ const builderPluginCompatModern = (options) => ({
27
27
  name: "builder-plugin-compat-modern",
28
28
  setup(api) {
29
29
  const { normalizedConfig: modernConfig, appContext } = options;
@@ -60,5 +60,5 @@ const PluginCompatModern = (options) => ({
60
60
  });
61
61
  // Annotate the CommonJS export names for ESM import in node:
62
62
  0 && (module.exports = {
63
- PluginCompatModern
63
+ builderPluginCompatModern
64
64
  });
@@ -27,7 +27,6 @@ __export(builder_webpack_exports, {
27
27
  });
28
28
  module.exports = __toCommonJS(builder_webpack_exports);
29
29
  var import_builder_webpack_provider = require("@modern-js/builder-webpack-provider");
30
- var import_utils = require("@modern-js/utils");
31
30
  var import_shared = require("../shared");
32
31
  var import_generator = require("../generator");
33
32
  var import_compatModern = require("./builderPlugins/compatModern");
@@ -57,20 +56,15 @@ function modifyOutputConfig(config, appContext) {
57
56
  async function applyBuilderPlugins(builder, options) {
58
57
  const { normalizedConfig } = options;
59
58
  if (!normalizedConfig.output.disableNodePolyfill) {
60
- const { PluginNodePolyfill } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-plugin-node-polyfill")));
61
- builder.addPlugins([PluginNodePolyfill()]);
59
+ const { builderPluginNodePolyfill } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-plugin-node-polyfill")));
60
+ builder.addPlugins([builderPluginNodePolyfill()]);
62
61
  }
63
62
  if (normalizedConfig.tools.esbuild) {
64
63
  const { esbuild: esbuildOptions } = normalizedConfig.tools;
65
- const { PluginEsbuild } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-plugin-esbuild")));
66
- builder.addPlugins([
67
- PluginEsbuild({
68
- loader: false,
69
- minimize: (0, import_utils.applyOptionsChain)({}, esbuildOptions)
70
- })
71
- ]);
64
+ const { builderPluginEsbuild } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-plugin-esbuild")));
65
+ builder.addPlugins([builderPluginEsbuild(esbuildOptions)]);
72
66
  }
73
- builder.addPlugins([(0, import_compatModern.PluginCompatModern)(options)]);
67
+ builder.addPlugins([(0, import_compatModern.builderPluginCompatModern)(options)]);
74
68
  }
75
69
  // Annotate the CommonJS export names for ESM import in node:
76
70
  0 && (module.exports = {
@@ -27,7 +27,7 @@ function getBuilderTargets(normalizedConfig) {
27
27
  if (useNodeTarget) {
28
28
  targets.push("node");
29
29
  }
30
- const useWorkerTarget = (0, import_utils.isProd)() ? (0, import_utils.isServiceWorker)(normalizedConfig) : false;
30
+ const useWorkerTarget = (0, import_utils.isServiceWorker)(normalizedConfig);
31
31
  if (useWorkerTarget) {
32
32
  targets.push("service-worker");
33
33
  }
@@ -27,7 +27,7 @@ var import_routes = require("../utils/routes");
27
27
  var import_config = require("../utils/config");
28
28
  var import_getServerInternalPlugins = require("../utils/getServerInternalPlugins");
29
29
  const dev = async (api, options) => {
30
- var _a;
30
+ var _a, _b;
31
31
  if (options.analyze) {
32
32
  process.env.BUNDLE_ANALYZE = "true";
33
33
  }
@@ -59,6 +59,7 @@ const dev = async (api, options) => {
59
59
  dev: {
60
60
  port,
61
61
  https: normalizedConfig.dev.https,
62
+ host: normalizedConfig.dev.host,
62
63
  ...(_a = normalizedConfig.tools) == null ? void 0 : _a.devServer
63
64
  },
64
65
  pwd: appDirectory,
@@ -71,12 +72,19 @@ const dev = async (api, options) => {
71
72
  ...serverOptions,
72
73
  compiler: null
73
74
  });
74
- app.listen(port, async (err) => {
75
- if (err) {
76
- throw err;
75
+ const host = ((_b = normalizedConfig.dev) == null ? void 0 : _b.host) || "localhost";
76
+ app.listen(
77
+ {
78
+ port,
79
+ host
80
+ },
81
+ async (err) => {
82
+ if (err) {
83
+ throw err;
84
+ }
85
+ (0, import_printInstructions.printInstructions)(hookRunners, appContext, normalizedConfig);
77
86
  }
78
- (0, import_printInstructions.printInstructions)(hookRunners, appContext, normalizedConfig);
79
- });
87
+ );
80
88
  } else {
81
89
  const { server } = await appContext.builder.startDevServer({
82
90
  printURLs: false,
@@ -56,7 +56,10 @@ function createToolsConfig(config) {
56
56
  devServer,
57
57
  tailwindcss,
58
58
  jest,
59
- esbuild
59
+ esbuild: {
60
+ loader: false,
61
+ minimize: esbuild
62
+ }
60
63
  };
61
64
  }
62
65
  // Annotate the CommonJS export names for ESM import in node:
@@ -148,7 +148,7 @@ var __generator = this && this.__generator || function(thisArg, body) {
148
148
  }
149
149
  };
150
150
  import path from "path";
151
- import { fs, getEntryOptions, logger } from "@modern-js/utils";
151
+ import { fs, getEntryOptions, isRouterV5, logger } from "@modern-js/utils";
152
152
  import { useResolvedConfigContext } from "@modern-js/core";
153
153
  import * as templates from "./templates";
154
154
  import { getClientRoutes, getClientRoutesLegacy } from "./getClientRoutes";
@@ -240,7 +240,7 @@ var createImportStatements = function(statements) {
240
240
  };
241
241
  var generateCode = function() {
242
242
  var _ref = _asyncToGenerator(function(appContext, config, entrypoints, api) {
243
- var _config_runtime, _config_runtime1, _config_runtime_router, internalDirectory, srcDirectory, internalDirAlias, internalSrcAlias, packageName, hookRunners, isV5, mountId, getRoutes;
243
+ var internalDirectory, srcDirectory, internalDirAlias, internalSrcAlias, packageName, hookRunners, isV5, mountId, getRoutes;
244
244
  function generateEntryCode(entrypoint) {
245
245
  return _generateEntryCode.apply(this, arguments);
246
246
  }
@@ -253,11 +253,11 @@ var generateCode = function() {
253
253
  entryName = entrypoint.entryName, isAutoMount = entrypoint.isAutoMount, customBootstrap = entrypoint.customBootstrap, fileSystemRoutes = entrypoint.fileSystemRoutes;
254
254
  if (!isAutoMount) return [
255
255
  3,
256
- 17
256
+ 16
257
257
  ];
258
258
  if (!fileSystemRoutes) return [
259
259
  3,
260
- 10
260
+ 9
261
261
  ];
262
262
  initialRoutes = [];
263
263
  nestedRoute = null;
@@ -270,11 +270,7 @@ var generateCode = function() {
270
270
  internalDirAlias: internalDirAlias
271
271
  });
272
272
  }
273
- if (!entrypoint.nestedRoutesEntry) return [
274
- 3,
275
- 3
276
- ];
277
- if (!!isV5) return [
273
+ if (!(!isV5 && entrypoint.nestedRoutesEntry)) return [
278
274
  3,
279
275
  2
280
276
  ];
@@ -290,15 +286,8 @@ var generateCode = function() {
290
286
  if (nestedRoute) {
291
287
  initialRoutes.unshift(nestedRoute);
292
288
  }
293
- return [
294
- 3,
295
- 3
296
- ];
289
+ _state.label = 2;
297
290
  case 2:
298
- logger.error("Nested routes is not supported in legacy mode.");
299
- process.exit(1);
300
- _state.label = 3;
301
- case 3:
302
291
  return [
303
292
  4,
304
293
  hookRunners.modifyFileSystemRoutes({
@@ -306,7 +295,7 @@ var generateCode = function() {
306
295
  routes: initialRoutes
307
296
  })
308
297
  ];
309
- case 4:
298
+ case 3:
310
299
  routes = _state.sent().routes;
311
300
  config2 = useResolvedConfigContext();
312
301
  ssr = getEntryOptions(entryName, config2.server.ssr, config2.server.ssrByEntries, packageName);
@@ -338,18 +327,18 @@ var generateCode = function() {
338
327
  internalDirectory: internalDirectory
339
328
  })
340
329
  ];
341
- case 5:
330
+ case 4:
342
331
  return [
343
332
  4,
344
333
  _.apply(hookRunners, [
345
334
  (_tmp.code = _state.sent(), _tmp)
346
335
  ])
347
336
  ];
348
- case 6:
337
+ case 5:
349
338
  _ref = _state.sent(), code2 = _ref.code;
350
339
  if (!(entrypoint.nestedRoutesEntry && mode)) return [
351
340
  3,
352
- 9
341
+ 8
353
342
  ];
354
343
  routesServerFile = getServerLoadersFile(internalDirectory, entryName);
355
344
  code3 = templates.routesForServer({
@@ -359,19 +348,19 @@ var generateCode = function() {
359
348
  4,
360
349
  fs.ensureFile(routesServerFile)
361
350
  ];
362
- case 7:
351
+ case 6:
363
352
  _state.sent();
364
353
  return [
365
354
  4,
366
355
  fs.writeFile(routesServerFile, code3)
367
356
  ];
368
- case 8:
357
+ case 7:
369
358
  _state.sent();
359
+ _state.label = 8;
360
+ case 8:
361
+ fs.outputFileSync(path.resolve(internalDirectory, "./".concat(entryName, "/").concat(FILE_SYSTEM_ROUTES_FILE_NAME)), code2, "utf8");
370
362
  _state.label = 9;
371
363
  case 9:
372
- fs.outputFileSync(path.resolve(internalDirectory, "./".concat(entryName, "/").concat(FILE_SYSTEM_ROUTES_FILE_NAME)), code2, "utf8");
373
- _state.label = 10;
374
- case 10:
375
364
  return [
376
365
  4,
377
366
  hookRunners.modifyEntryImports({
@@ -385,7 +374,7 @@ var generateCode = function() {
385
374
  })
386
375
  })
387
376
  ];
388
- case 11:
377
+ case 10:
389
378
  _ref1 = _state.sent(), importStatements = _ref1.imports;
390
379
  return [
391
380
  4,
@@ -394,7 +383,7 @@ var generateCode = function() {
394
383
  plugins: []
395
384
  })
396
385
  ];
397
- case 12:
386
+ case 11:
398
387
  plugins = _state.sent().plugins;
399
388
  return [
400
389
  4,
@@ -407,7 +396,7 @@ var generateCode = function() {
407
396
  })
408
397
  })
409
398
  ];
410
- case 13:
399
+ case 12:
411
400
  _ref2 = _state.sent(), renderFunction = _ref2.code;
412
401
  return [
413
402
  4,
@@ -416,7 +405,7 @@ var generateCode = function() {
416
405
  exportStatement: "export default AppWrapper;"
417
406
  })
418
407
  ];
419
- case 14:
408
+ case 13:
420
409
  exportStatement = _state.sent().exportStatement;
421
410
  code = templates.index({
422
411
  mountId: mountId,
@@ -428,7 +417,7 @@ var generateCode = function() {
428
417
  entrypoint.entry = entryFile;
429
418
  if (!config.source.enableAsyncEntry) return [
430
419
  3,
431
- 16
420
+ 15
432
421
  ];
433
422
  return [
434
423
  4,
@@ -437,19 +426,19 @@ var generateCode = function() {
437
426
  code: "import('./".concat(ENTRY_BOOTSTRAP_FILE_NAME, "');")
438
427
  })
439
428
  ];
440
- case 15:
429
+ case 14:
441
430
  _ref3 = _state.sent(), asyncEntryCode = _ref3.code;
442
431
  fs.outputFileSync(entryFile, asyncEntryCode, "utf8");
443
432
  bootstrapFile = path.resolve(internalDirectory, "./".concat(entryName, "/").concat(ENTRY_BOOTSTRAP_FILE_NAME));
444
433
  fs.outputFileSync(bootstrapFile, code, "utf8");
445
434
  return [
446
435
  3,
447
- 17
436
+ 16
448
437
  ];
449
- case 16:
438
+ case 15:
450
439
  fs.outputFileSync(entryFile, code, "utf8");
451
- _state.label = 17;
452
- case 17:
440
+ _state.label = 16;
441
+ case 16:
453
442
  return [
454
443
  2
455
444
  ];
@@ -463,7 +452,7 @@ var generateCode = function() {
463
452
  case 0:
464
453
  internalDirectory = appContext.internalDirectory, srcDirectory = appContext.srcDirectory, internalDirAlias = appContext.internalDirAlias, internalSrcAlias = appContext.internalSrcAlias, packageName = appContext.packageName;
465
454
  hookRunners = api.useHookRunners();
466
- isV5 = typeof ((_config_runtime = config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.router) !== "boolean" && (config === null || config === void 0 ? void 0 : (_config_runtime1 = config.runtime) === null || _config_runtime1 === void 0 ? void 0 : (_config_runtime_router = _config_runtime1.router) === null || _config_runtime_router === void 0 ? void 0 : _config_runtime_router.mode) === "react-router-5";
455
+ isV5 = isRouterV5(config);
467
456
  mountId = config.html.mountId;
468
457
  getRoutes = isV5 ? getClientRoutesLegacy : getClientRoutes;
469
458
  return [
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
- import { ensureAbsolutePath, fs, findExists, MAIN_ENTRY_NAME } from "@modern-js/utils";
2
+ import { ensureAbsolutePath, fs, findExists, MAIN_ENTRY_NAME, isRouterV5 } from "@modern-js/utils";
3
3
  import { getFileSystemEntry } from "./getFileSystemEntry";
4
4
  import { JS_EXTENSIONS } from "./constants";
5
5
  var ensureExtensions = function(file) {
@@ -43,7 +43,7 @@ var getBundleEntry = function(appContext, config) {
43
43
  customBootstrap: value.customBootstrap && ensureAbsolutePath(appDirectory, value.customBootstrap),
44
44
  fileSystemRoutes: fs.statSync(ensureAbsolutePath(appDirectory, value.entry)).isDirectory() ? {} : void 0
45
45
  };
46
- if (entrypoint.fileSystemRoutes) {
46
+ if (entrypoint.fileSystemRoutes && isRouterV5(config)) {
47
47
  entrypoint.nestedRoutesEntry = entrypoint.entry;
48
48
  }
49
49
  if (!ifAlreadyExists(defaults, entrypoint)) {
@@ -26,7 +26,7 @@ function _unsupportedIterableToArray(o, minLen) {
26
26
  import { join } from "path";
27
27
  import { createCopyPattern } from "../../shared";
28
28
  import { RouterPlugin } from "../webpackPlugins";
29
- var PluginCompatModern = function(options) {
29
+ var builderPluginCompatModern = function(options) {
30
30
  return {
31
31
  name: "builder-plugin-compat-modern",
32
32
  setup: function setup(api) {
@@ -61,4 +61,4 @@ var PluginCompatModern = function(options) {
61
61
  }
62
62
  };
63
63
  };
64
- export { PluginCompatModern };
64
+ export { builderPluginCompatModern };
@@ -200,10 +200,9 @@ var __generator = this && this.__generator || function(thisArg, body) {
200
200
  }
201
201
  };
202
202
  import { builderWebpackProvider } from "@modern-js/builder-webpack-provider";
203
- import { applyOptionsChain } from "@modern-js/utils";
204
203
  import { createCopyPattern } from "../shared";
205
204
  import { generateBuilder } from "../generator";
206
- import { PluginCompatModern } from "./builderPlugins/compatModern";
205
+ import { builderPluginCompatModern } from "./builderPlugins/compatModern";
207
206
  function createWebpackBuilderForModern(options) {
208
207
  return generateBuilder(options, builderWebpackProvider, {
209
208
  modifyBuilderConfig: function modifyBuilderConfig(config) {
@@ -248,7 +247,7 @@ function applyBuilderPlugins(builder, options) {
248
247
  }
249
248
  function _applyBuilderPlugins() {
250
249
  _applyBuilderPlugins = _asyncToGenerator(function(builder, options) {
251
- var normalizedConfig, PluginNodePolyfill, _normalizedConfig_tools, esbuildOptions, PluginEsbuild;
250
+ var normalizedConfig, builderPluginNodePolyfill, _normalizedConfig_tools, esbuildOptions, builderPluginEsbuild;
252
251
  return __generator(this, function(_state) {
253
252
  switch(_state.label){
254
253
  case 0:
@@ -262,9 +261,9 @@ function _applyBuilderPlugins() {
262
261
  import("@modern-js/builder-plugin-node-polyfill")
263
262
  ];
264
263
  case 1:
265
- PluginNodePolyfill = _state.sent().PluginNodePolyfill;
264
+ builderPluginNodePolyfill = _state.sent().builderPluginNodePolyfill;
266
265
  builder.addPlugins([
267
- PluginNodePolyfill()
266
+ builderPluginNodePolyfill()
268
267
  ]);
269
268
  _state.label = 2;
270
269
  case 2:
@@ -278,17 +277,14 @@ function _applyBuilderPlugins() {
278
277
  import("@modern-js/builder-plugin-esbuild")
279
278
  ];
280
279
  case 3:
281
- PluginEsbuild = _state.sent().PluginEsbuild;
280
+ builderPluginEsbuild = _state.sent().builderPluginEsbuild;
282
281
  builder.addPlugins([
283
- PluginEsbuild({
284
- loader: false,
285
- minimize: applyOptionsChain({}, esbuildOptions)
286
- })
282
+ builderPluginEsbuild(esbuildOptions)
287
283
  ]);
288
284
  _state.label = 4;
289
285
  case 4:
290
286
  builder.addPlugins([
291
- PluginCompatModern(options)
287
+ builderPluginCompatModern(options)
292
288
  ]);
293
289
  return [
294
290
  2
@@ -7,7 +7,7 @@ function getBuilderTargets(normalizedConfig) {
7
7
  if (useNodeTarget) {
8
8
  targets.push("node");
9
9
  }
10
- var useWorkerTarget = isProd() ? isServiceWorker(normalizedConfig) : false;
10
+ var useWorkerTarget = isServiceWorker(normalizedConfig);
11
11
  if (useWorkerTarget) {
12
12
  targets.push("service-worker");
13
13
  }
@@ -182,7 +182,7 @@ import { buildServerConfig } from "../utils/config";
182
182
  import { getServerInternalPlugins } from "../utils/getServerInternalPlugins";
183
183
  var dev = function() {
184
184
  var _ref = _asyncToGenerator(function(api, options) {
185
- var _normalizedConfig_tools, normalizedConfig, appContext, hookRunners, appDirectory, distDirectory, port, apiOnly, serverConfigFile, serverInternalPlugins, serverOptions, app, server;
185
+ var _normalizedConfig_tools, normalizedConfig, appContext, hookRunners, appDirectory, distDirectory, port, apiOnly, serverConfigFile, serverInternalPlugins, serverOptions, _normalizedConfig_dev, app, host, server;
186
186
  return __generator(this, function(_state) {
187
187
  switch(_state.label){
188
188
  case 0:
@@ -236,7 +236,8 @@ var dev = function() {
236
236
  serverOptions = {
237
237
  dev: _objectSpread({
238
238
  port: port,
239
- https: normalizedConfig.dev.https
239
+ https: normalizedConfig.dev.https,
240
+ host: normalizedConfig.dev.host
240
241
  }, (_normalizedConfig_tools = normalizedConfig.tools) === null || _normalizedConfig_tools === void 0 ? void 0 : _normalizedConfig_tools.devServer),
241
242
  pwd: appDirectory,
242
243
  config: normalizedConfig,
@@ -255,7 +256,11 @@ var dev = function() {
255
256
  ];
256
257
  case 5:
257
258
  app = _state.sent();
258
- app.listen(port, function() {
259
+ host = ((_normalizedConfig_dev = normalizedConfig.dev) === null || _normalizedConfig_dev === void 0 ? void 0 : _normalizedConfig_dev.host) || "localhost";
260
+ app.listen({
261
+ port: port,
262
+ host: host
263
+ }, function() {
259
264
  var _ref = _asyncToGenerator(function(err) {
260
265
  return __generator(this, function(_state) {
261
266
  if (err) {
@@ -17,7 +17,10 @@ function createToolsConfig(config) {
17
17
  devServer: devServer,
18
18
  tailwindcss: tailwindcss,
19
19
  jest: jest,
20
- esbuild: esbuild
20
+ esbuild: {
21
+ loader: false,
22
+ minimize: esbuild
23
+ }
21
24
  };
22
25
  }
23
26
  export { createToolsConfig };
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
- import { fs, getEntryOptions, logger } from "@modern-js/utils";
2
+ import { fs, getEntryOptions, isRouterV5, logger } from "@modern-js/utils";
3
3
  import {
4
4
  useResolvedConfigContext
5
5
  } from "@modern-js/core";
@@ -60,7 +60,6 @@ ${initialize || ""}`
60
60
  ).join("\n");
61
61
  };
62
62
  const generateCode = async (appContext, config, entrypoints, api) => {
63
- var _a, _b, _c;
64
63
  const {
65
64
  internalDirectory,
66
65
  srcDirectory,
@@ -69,7 +68,7 @@ const generateCode = async (appContext, config, entrypoints, api) => {
69
68
  packageName
70
69
  } = appContext;
71
70
  const hookRunners = api.useHookRunners();
72
- const isV5 = typeof ((_a = config.runtime) == null ? void 0 : _a.router) !== "boolean" && ((_c = (_b = config == null ? void 0 : config.runtime) == null ? void 0 : _b.router) == null ? void 0 : _c.mode) === "react-router-5";
71
+ const isV5 = isRouterV5(config);
73
72
  const { mountId } = config.html;
74
73
  const getRoutes = isV5 ? getClientRoutesLegacy : getClientRoutes;
75
74
  await Promise.all(entrypoints.map(generateEntryCode));
@@ -88,23 +87,18 @@ const generateCode = async (appContext, config, entrypoints, api) => {
88
87
  internalDirAlias
89
88
  });
90
89
  }
91
- if (entrypoint.nestedRoutesEntry) {
92
- if (!isV5) {
93
- nestedRoute = await walk(
94
- entrypoint.nestedRoutesEntry,
95
- entrypoint.nestedRoutesEntry,
96
- {
97
- name: internalSrcAlias,
98
- basename: srcDirectory
99
- },
100
- entrypoint.entryName
101
- );
102
- if (nestedRoute) {
103
- initialRoutes.unshift(nestedRoute);
104
- }
105
- } else {
106
- logger.error("Nested routes is not supported in legacy mode.");
107
- process.exit(1);
90
+ if (!isV5 && entrypoint.nestedRoutesEntry) {
91
+ nestedRoute = await walk(
92
+ entrypoint.nestedRoutesEntry,
93
+ entrypoint.nestedRoutesEntry,
94
+ {
95
+ name: internalSrcAlias,
96
+ basename: srcDirectory
97
+ },
98
+ entrypoint.entryName
99
+ );
100
+ if (nestedRoute) {
101
+ initialRoutes.unshift(nestedRoute);
108
102
  }
109
103
  }
110
104
  const { routes } = await hookRunners.modifyFileSystemRoutes({
@@ -3,7 +3,8 @@ import {
3
3
  ensureAbsolutePath,
4
4
  fs,
5
5
  findExists,
6
- MAIN_ENTRY_NAME
6
+ MAIN_ENTRY_NAME,
7
+ isRouterV5
7
8
  } from "@modern-js/utils";
8
9
  import { getFileSystemEntry } from "./getFileSystemEntry";
9
10
  import { JS_EXTENSIONS } from "./constants";
@@ -55,7 +56,7 @@ const getBundleEntry = (appContext, config) => {
55
56
  customBootstrap: value.customBootstrap && ensureAbsolutePath(appDirectory, value.customBootstrap),
56
57
  fileSystemRoutes: fs.statSync(ensureAbsolutePath(appDirectory, value.entry)).isDirectory() ? {} : void 0
57
58
  };
58
- if (entrypoint.fileSystemRoutes) {
59
+ if (entrypoint.fileSystemRoutes && isRouterV5(config)) {
59
60
  entrypoint.nestedRoutesEntry = entrypoint.entry;
60
61
  }
61
62
  if (!ifAlreadyExists(defaults, entrypoint)) {
@@ -1,7 +1,7 @@
1
1
  import { join } from "path";
2
2
  import { createCopyPattern } from "../../shared";
3
3
  import { RouterPlugin } from "../webpackPlugins";
4
- const PluginCompatModern = (options) => ({
4
+ const builderPluginCompatModern = (options) => ({
5
5
  name: "builder-plugin-compat-modern",
6
6
  setup(api) {
7
7
  const { normalizedConfig: modernConfig, appContext } = options;
@@ -37,5 +37,5 @@ const PluginCompatModern = (options) => ({
37
37
  }
38
38
  });
39
39
  export {
40
- PluginCompatModern
40
+ builderPluginCompatModern
41
41
  };
@@ -1,10 +1,9 @@
1
1
  import {
2
2
  builderWebpackProvider
3
3
  } from "@modern-js/builder-webpack-provider";
4
- import { applyOptionsChain } from "@modern-js/utils";
5
4
  import { createCopyPattern } from "../shared";
6
5
  import { generateBuilder } from "../generator";
7
- import { PluginCompatModern } from "./builderPlugins/compatModern";
6
+ import { builderPluginCompatModern } from "./builderPlugins/compatModern";
8
7
  function createWebpackBuilderForModern(options) {
9
8
  return generateBuilder(options, builderWebpackProvider, {
10
9
  modifyBuilderConfig(config) {
@@ -31,20 +30,15 @@ function modifyOutputConfig(config, appContext) {
31
30
  async function applyBuilderPlugins(builder, options) {
32
31
  const { normalizedConfig } = options;
33
32
  if (!normalizedConfig.output.disableNodePolyfill) {
34
- const { PluginNodePolyfill } = await import("@modern-js/builder-plugin-node-polyfill");
35
- builder.addPlugins([PluginNodePolyfill()]);
33
+ const { builderPluginNodePolyfill } = await import("@modern-js/builder-plugin-node-polyfill");
34
+ builder.addPlugins([builderPluginNodePolyfill()]);
36
35
  }
37
36
  if (normalizedConfig.tools.esbuild) {
38
37
  const { esbuild: esbuildOptions } = normalizedConfig.tools;
39
- const { PluginEsbuild } = await import("@modern-js/builder-plugin-esbuild");
40
- builder.addPlugins([
41
- PluginEsbuild({
42
- loader: false,
43
- minimize: applyOptionsChain({}, esbuildOptions)
44
- })
45
- ]);
38
+ const { builderPluginEsbuild } = await import("@modern-js/builder-plugin-esbuild");
39
+ builder.addPlugins([builderPluginEsbuild(esbuildOptions)]);
46
40
  }
47
- builder.addPlugins([PluginCompatModern(options)]);
41
+ builder.addPlugins([builderPluginCompatModern(options)]);
48
42
  }
49
43
  export {
50
44
  createWebpackBuilderForModern