@flatjs/evolve 2.3.2-next.0 → 2.3.2-next.2

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 (252) hide show
  1. package/dist/build-server/compiler-server-manager.d.ts +1 -1
  2. package/dist/compiler/create-build-server-compiler.js +1 -1
  3. package/dist/core/rspack/create-externals.d.ts +4 -0
  4. package/dist/core/rspack/create-optimization.d.ts +4 -0
  5. package/dist/core/rspack/create-optimization.js +1 -0
  6. package/dist/core/rspack/create-performance.d.ts +2 -0
  7. package/dist/core/rspack/create-plugins.d.ts +5 -0
  8. package/dist/core/rspack/create-plugins.js +1 -0
  9. package/dist/core/rspack/create-resolve.d.ts +2 -0
  10. package/dist/core/rspack/create-resolve.js +1 -0
  11. package/dist/core/rspack/create-rspack-output.d.ts +4 -0
  12. package/dist/core/rspack/create-rspack-output.js +1 -0
  13. package/dist/core/rspack/create-rspack-rule-sets.d.ts +4 -0
  14. package/dist/core/rspack/create-rspack-rule-sets.js +1 -0
  15. package/dist/core/rspack/dev-serve/add-rspack-compiler-to-dev-server.d.ts +11 -0
  16. package/dist/core/rspack/dev-serve/add-rspack-compiler-to-dev-server.js +1 -0
  17. package/dist/core/rspack/dev-serve/create-rspack-compiler-task.d.ts +3 -0
  18. package/dist/core/rspack/dev-serve/create-rspack-compiler-task.js +1 -0
  19. package/dist/core/rspack/load-rspack-config.d.ts +11 -0
  20. package/dist/core/rspack/load-rspack-config.js +1 -0
  21. package/dist/core/rspack/load-rspack-watch-options.d.ts +12 -0
  22. package/dist/core/rspack/load-rspack-watch-options.js +1 -0
  23. package/dist/core/rspack/start-rspack-build.d.ts +12 -0
  24. package/dist/core/rspack/start-rspack-build.js +1 -0
  25. package/dist/{create-webpack → core/webpack}/create-externals.d.ts +2 -2
  26. package/dist/core/webpack/create-externals.js +1 -0
  27. package/dist/{create-webpack → core/webpack}/create-optimization.d.ts +2 -2
  28. package/dist/core/webpack/create-optimization.js +1 -0
  29. package/dist/{create-webpack → core/webpack}/create-output.d.ts +2 -2
  30. package/dist/core/webpack/create-output.js +1 -0
  31. package/dist/{create-webpack → core/webpack}/create-performance.d.ts +1 -1
  32. package/dist/core/webpack/create-performance.js +1 -0
  33. package/dist/core/webpack/create-plugins.d.ts +5 -0
  34. package/dist/core/webpack/create-plugins.js +1 -0
  35. package/dist/{create-webpack → core/webpack}/create-resolve.d.ts +1 -1
  36. package/dist/{create-webpack → core/webpack}/create-rule-sets.d.ts +2 -2
  37. package/dist/core/webpack/create-rule-sets.js +1 -0
  38. package/dist/{dev-server/add-compiler-to-dev-server.d.ts → core/webpack/dev-serve/add-webpack-compiler-to-dev-server.d.ts} +2 -2
  39. package/dist/core/webpack/dev-serve/add-webpack-compiler-to-dev-server.js +1 -0
  40. package/dist/core/webpack/dev-serve/create-webpack-compiler-task.d.ts +3 -0
  41. package/dist/core/webpack/dev-serve/create-webpack-compiler-task.js +1 -0
  42. package/dist/core/webpack/index.d.ts +2 -0
  43. package/dist/core/webpack/index.js +1 -0
  44. package/dist/{create-webpack → core/webpack}/load-watch-options.d.ts +3 -3
  45. package/dist/core/webpack/load-watch-options.js +1 -0
  46. package/dist/{create-webpack → core/webpack}/load-webpack-config.d.ts +3 -3
  47. package/dist/core/webpack/load-webpack-config.js +1 -0
  48. package/dist/core/webpack/start-webpack-build.d.ts +12 -0
  49. package/dist/core/webpack/start-webpack-build.js +1 -0
  50. package/dist/default-options.js +1 -1
  51. package/dist/dev-server/create-app-page-route.d.ts +1 -1
  52. package/dist/dev-server/create-dev-server-entries.d.ts +1 -1
  53. package/dist/dev-server/index.d.ts +0 -2
  54. package/dist/dev-server/index.js +1 -1
  55. package/dist/dev-server/middlewares/create-page-middleware.d.ts +1 -1
  56. package/dist/dev-server/middlewares/get-all-sorted-modules.d.ts +1 -1
  57. package/dist/dev-server/middlewares/get-dev-server-host-uri.d.ts +1 -1
  58. package/dist/dev-server/middlewares/get-hmr-runtime-chunks.d.ts +1 -1
  59. package/dist/dev-server/middlewares/get-normalized-entry-name.d.ts +1 -1
  60. package/dist/dev-server/middlewares/get-page-main-html.d.ts +1 -1
  61. package/dist/dev-server/middlewares/get-page-module-html.d.ts +1 -1
  62. package/dist/dev-server/middlewares/get-runtime-manifest.d.ts +1 -1
  63. package/dist/helpers/assert-single-compiler.d.ts +14 -1
  64. package/dist/helpers/assert-single-compiler.js +1 -1
  65. package/dist/helpers/custom-listr-renderer.js +1 -1
  66. package/dist/helpers/flat-entry-map.d.ts +1 -1
  67. package/dist/helpers/format-spinner-text.d.ts +3 -1
  68. package/dist/helpers/format-spinner-text.js +1 -1
  69. package/dist/helpers/print-promotion.d.ts +2 -0
  70. package/dist/helpers/print-promotion.js +1 -0
  71. package/dist/index.d.ts +2 -0
  72. package/dist/index.js +1 -1
  73. package/dist/main/create-build-server.d.ts +1 -1
  74. package/dist/main/index.d.ts +0 -1
  75. package/dist/main/index.js +1 -1
  76. package/dist/main/prepare-build.d.ts +1 -1
  77. package/dist/main/prepare-build.js +1 -1
  78. package/dist/main/prepare-serve.d.ts +2 -1
  79. package/dist/main/prepare-serve.js +1 -1
  80. package/dist/main/start-build-dynamic.d.ts +3 -2
  81. package/dist/main/start-build-dynamic.js +1 -1
  82. package/dist/main/start-build-worker.d.ts +1 -3
  83. package/dist/main/start-build-worker.js +1 -1
  84. package/dist/main/start-build.d.ts +1 -1
  85. package/dist/main/start-build.js +1 -1
  86. package/dist/main/start-serve.d.ts +2 -1
  87. package/dist/main/start-serve.js +1 -1
  88. package/dist/minimizer/default-options.d.ts +2 -0
  89. package/dist/minimizer/default-options.js +1 -1
  90. package/dist/minimizer/index.d.ts +2 -1
  91. package/dist/minimizer/index.js +1 -1
  92. package/dist/minimizer/rspack/create-minimizers.d.ts +3 -0
  93. package/dist/minimizer/rspack/create-minimizers.js +1 -0
  94. package/dist/minimizer/{image-minimizer.d.ts → rspack/image-minimizer.d.ts} +1 -1
  95. package/dist/minimizer/rspack/image-minimizer.js +1 -0
  96. package/dist/minimizer/rspack/terser-minimizer.d.ts +6 -0
  97. package/dist/minimizer/rspack/terser-minimizer.js +1 -0
  98. package/dist/minimizer/webpack/create-minimizers.d.ts +3 -0
  99. package/dist/minimizer/webpack/create-minimizers.js +1 -0
  100. package/dist/minimizer/webpack/image-minimizer.d.ts +16 -0
  101. package/dist/minimizer/webpack/image-minimizer.js +1 -0
  102. package/dist/minimizer/webpack/terser-minimizer.d.ts +6 -0
  103. package/dist/minimizer/{terser-minimizer.js → webpack/terser-minimizer.js} +1 -1
  104. package/dist/plugins/{define-variable/define-variable-plugin.d.ts → rspack/define-variable/index.d.ts} +3 -3
  105. package/dist/plugins/rspack/define-variable/index.js +1 -0
  106. package/dist/plugins/rspack/module-federation/external-template-remotes-rspack-plugin.d.ts +4 -0
  107. package/dist/plugins/rspack/module-federation/external-template-remotes-rspack-plugin.js +1 -0
  108. package/dist/plugins/rspack/module-federation/index.d.ts +4 -0
  109. package/dist/plugins/rspack/module-federation/index.js +1 -0
  110. package/dist/plugins/rspack/multi-html/index.d.ts +4 -0
  111. package/dist/plugins/rspack/multi-html/index.js +1 -0
  112. package/dist/plugins/rspack/multi-html/multi-html-cdn-rspack-plugin.d.ts +18 -0
  113. package/dist/plugins/rspack/multi-html/multi-html-cdn-rspack-plugin.js +1 -0
  114. package/dist/plugins/{multi-html/multi-html-modify-plugin.d.ts → rspack/multi-html/multi-html-modify--rspack-plugin.d.ts} +2 -2
  115. package/dist/plugins/rspack/multi-html/multi-html-modify--rspack-plugin.js +1 -0
  116. package/dist/plugins/rspack/multi-html/multi-html-rspack-plugin.d.ts +11 -0
  117. package/dist/plugins/rspack/multi-html/multi-html-rspack-plugin.js +1 -0
  118. package/dist/plugins/{circular-dependency/circular-dependency-plugin.d.ts → webpack/circular-dependency/circular-dependency-webpack-plugin.d.ts} +1 -1
  119. package/dist/plugins/webpack/circular-dependency/circular-dependency-webpack-plugin.js +1 -0
  120. package/dist/plugins/webpack/circular-dependency/index.d.ts +9 -0
  121. package/dist/plugins/webpack/circular-dependency/index.js +1 -0
  122. package/dist/plugins/webpack/clean-webpack/clean-webpack-plugin.js +1 -0
  123. package/dist/plugins/webpack/clean-webpack/index.d.ts +9 -0
  124. package/dist/plugins/webpack/clean-webpack/index.js +1 -0
  125. package/dist/plugins/webpack/define-variable/index.d.ts +16 -0
  126. package/dist/plugins/webpack/define-variable/index.js +1 -0
  127. package/dist/plugins/{html-inject-scripts/plugin-html-inject-script.d.ts → webpack/html-inject-scripts/html-inject-script-webpack-plugin.d.ts} +1 -1
  128. package/dist/plugins/webpack/html-inject-scripts/html-inject-script-webpack-plugin.js +1 -0
  129. package/dist/plugins/webpack/html-inject-scripts/html-inline-script-webpack-plugin.d.ts +12 -0
  130. package/dist/plugins/webpack/html-inject-scripts/html-inline-script-webpack-plugin.js +1 -0
  131. package/dist/plugins/webpack/html-inject-scripts/index.d.ts +2 -0
  132. package/dist/plugins/webpack/html-inject-scripts/index.js +1 -0
  133. package/dist/plugins/{module-federation/external-template-remotes.d.ts → webpack/module-federation/external-template-remotes-webpack-plugin.d.ts} +1 -1
  134. package/dist/plugins/webpack/module-federation/external-template-remotes-webpack-plugin.js +1 -0
  135. package/dist/plugins/webpack/module-federation/index.d.ts +4 -0
  136. package/dist/plugins/webpack/module-federation/index.js +1 -0
  137. package/dist/plugins/webpack/multi-html/index.d.ts +4 -0
  138. package/dist/plugins/webpack/multi-html/index.js +1 -0
  139. package/dist/plugins/{multi-html/multi-html-cdn-plugin.d.ts → webpack/multi-html/multi-html-cdn-webpack-plugin.d.ts} +2 -2
  140. package/dist/plugins/webpack/multi-html/multi-html-cdn-webpack-plugin.js +1 -0
  141. package/dist/plugins/webpack/multi-html/multi-html-modify-webpack-plugin.d.ts +12 -0
  142. package/dist/plugins/webpack/multi-html/multi-html-modify-webpack-plugin.js +1 -0
  143. package/dist/plugins/webpack/multi-html/multi-html-webpack-plugins.d.ts +11 -0
  144. package/dist/plugins/webpack/multi-html/multi-html-webpack-plugins.js +1 -0
  145. package/dist/plugins/webpack/stats-webpack/index.d.ts +12 -0
  146. package/dist/plugins/webpack/stats-webpack/index.js +1 -0
  147. package/dist/plugins/webpack/stats-webpack/stats-webpack-plugin.js +1 -0
  148. package/dist/rules/index.d.ts +2 -0
  149. package/dist/rules/index.js +1 -0
  150. package/dist/rules/rspack/index.d.ts +5 -0
  151. package/dist/rules/rspack/index.js +1 -0
  152. package/dist/rules/rspack/rule-assets.d.ts +10 -0
  153. package/dist/rules/rspack/rule-assets.js +1 -0
  154. package/dist/rules/rspack/rule-css.d.ts +11 -0
  155. package/dist/rules/rspack/rule-css.js +1 -0
  156. package/dist/rules/rspack/rule-less.d.ts +26 -0
  157. package/dist/rules/rspack/rule-less.js +1 -0
  158. package/dist/rules/rspack/rule-scripts.d.ts +3 -0
  159. package/dist/rules/rspack/rule-scripts.js +1 -0
  160. package/dist/rules/rspack/rule-svg-icon.d.ts +6 -0
  161. package/dist/rules/rspack/rule-svg-icon.js +1 -0
  162. package/dist/rules/rule-utils.d.ts +19 -0
  163. package/dist/rules/rule-utils.js +1 -0
  164. package/dist/rules/wepack/index.d.ts +5 -0
  165. package/dist/rules/wepack/index.js +1 -0
  166. package/dist/{create-webpack/rule-sets → rules/wepack}/rule-assets.d.ts +1 -1
  167. package/dist/rules/wepack/rule-assets.js +1 -0
  168. package/dist/{create-webpack/rule-sets → rules/wepack}/rule-css.d.ts +1 -1
  169. package/dist/rules/wepack/rule-css.js +1 -0
  170. package/dist/{create-webpack/rule-sets → rules/wepack}/rule-less.d.ts +1 -1
  171. package/dist/rules/wepack/rule-less.js +1 -0
  172. package/dist/{create-webpack/rule-sets → rules/wepack}/rule-scripts.d.ts +1 -1
  173. package/dist/rules/wepack/rule-scripts.js +1 -0
  174. package/dist/{create-webpack/rule-sets → rules/wepack}/rule-svg-icon.d.ts +1 -1
  175. package/dist/rules/wepack/rule-svg-icon.js +1 -0
  176. package/dist/types/index.d.ts +2 -0
  177. package/dist/types/index.js +1 -1
  178. package/dist/types/types-build.d.ts +4 -0
  179. package/dist/types/types-cli-options.d.ts +5 -0
  180. package/dist/types/types-dev-server.d.ts +23 -0
  181. package/dist/types/types-federation.d.ts +2 -3
  182. package/dist/types/types-options.d.ts +5 -0
  183. package/dist/types/types-webpack.d.ts +42 -3
  184. package/package.json +25 -15
  185. package/dist/create-webpack/create-optimization.js +0 -1
  186. package/dist/create-webpack/create-output.js +0 -1
  187. package/dist/create-webpack/create-plugins.d.ts +0 -5
  188. package/dist/create-webpack/create-plugins.js +0 -1
  189. package/dist/create-webpack/create-rule-sets.js +0 -1
  190. package/dist/create-webpack/load-watch-options.js +0 -1
  191. package/dist/create-webpack/load-webpack-config.js +0 -1
  192. package/dist/create-webpack/rule-sets/rule-assets.js +0 -1
  193. package/dist/create-webpack/rule-sets/rule-css.js +0 -1
  194. package/dist/create-webpack/rule-sets/rule-less.js +0 -1
  195. package/dist/create-webpack/rule-sets/rule-scripts.js +0 -1
  196. package/dist/create-webpack/rule-sets/rule-svg-icon.js +0 -1
  197. package/dist/create-webpack/rule-sets/rule-utils.d.ts +0 -7
  198. package/dist/create-webpack/rule-sets/rule-utils.js +0 -1
  199. package/dist/create-webpack/types.d.ts +0 -2
  200. package/dist/dev-server/add-compiler-to-dev-server.js +0 -1
  201. package/dist/dev-server/create-dev-server-compiler-task.d.ts +0 -3
  202. package/dist/dev-server/create-dev-server-compiler-task.js +0 -1
  203. package/dist/dev-server/middlewares/types.d.ts +0 -24
  204. package/dist/dev-server/middlewares/types.js +0 -1
  205. package/dist/helpers/custom-message-channel.d.ts +0 -17
  206. package/dist/helpers/custom-message-channel.js +0 -1
  207. package/dist/main/create-thread-worker.d.ts +0 -31
  208. package/dist/main/create-thread-worker.js +0 -1
  209. package/dist/main/get-worker-path.d.ts +0 -1
  210. package/dist/main/get-worker-path.js +0 -1
  211. package/dist/main/start-group-entry-build.d.ts +0 -15
  212. package/dist/main/start-group-entry-build.js +0 -1
  213. package/dist/minimizer/create-minimizers.d.ts +0 -3
  214. package/dist/minimizer/create-minimizers.js +0 -1
  215. package/dist/minimizer/image-minimizer.js +0 -1
  216. package/dist/minimizer/terser-minimizer.d.ts +0 -6
  217. package/dist/plugins/circular-dependency/circular-dependency-plugin.js +0 -1
  218. package/dist/plugins/circular-dependency/index.d.ts +0 -7
  219. package/dist/plugins/circular-dependency/index.js +0 -1
  220. package/dist/plugins/clean-webpack/clean-webpack-plugin.js +0 -1
  221. package/dist/plugins/clean-webpack/index.d.ts +0 -9
  222. package/dist/plugins/clean-webpack/index.js +0 -1
  223. package/dist/plugins/define-variable/define-variable-plugin.js +0 -1
  224. package/dist/plugins/define-variable/index.d.ts +0 -1
  225. package/dist/plugins/define-variable/index.js +0 -1
  226. package/dist/plugins/html-inject-scripts/plugin-html-inject-script.js +0 -1
  227. package/dist/plugins/module-federation/external-template-remotes.js +0 -1
  228. package/dist/plugins/module-federation/index.d.ts +0 -1
  229. package/dist/plugins/module-federation/index.js +0 -1
  230. package/dist/plugins/module-federation/module-federation.d.ts +0 -4
  231. package/dist/plugins/module-federation/module-federation.js +0 -1
  232. package/dist/plugins/multi-html/index.d.ts +0 -4
  233. package/dist/plugins/multi-html/index.js +0 -1
  234. package/dist/plugins/multi-html/multi-html-cdn-plugin.js +0 -1
  235. package/dist/plugins/multi-html/multi-html-modify-plugin.js +0 -1
  236. package/dist/plugins/multi-html/multi-html-plugin.d.ts +0 -11
  237. package/dist/plugins/multi-html/multi-html-plugin.js +0 -1
  238. package/dist/plugins/stats-webpack/index.d.ts +0 -12
  239. package/dist/plugins/stats-webpack/index.js +0 -1
  240. package/dist/plugins/stats-webpack/stats-webpack-plugin.js +0 -1
  241. /package/dist/{create-webpack → core/rspack}/create-externals.js +0 -0
  242. /package/dist/{create-webpack → core/rspack}/create-performance.js +0 -0
  243. /package/dist/{create-webpack → core/webpack}/create-resolve.js +0 -0
  244. /package/dist/{create-webpack → helpers}/resolve-public-path.d.ts +0 -0
  245. /package/dist/{create-webpack → helpers}/resolve-public-path.js +0 -0
  246. /package/dist/plugins/{clean-webpack → webpack/clean-webpack}/clean-webpack-plugin.d.ts +0 -0
  247. /package/dist/plugins/{stats-webpack → webpack/stats-webpack}/helper-write-stats.d.ts +0 -0
  248. /package/dist/plugins/{stats-webpack → webpack/stats-webpack}/helper-write-stats.js +0 -0
  249. /package/dist/plugins/{stats-webpack → webpack/stats-webpack}/stats-webpack-plugin.d.ts +0 -0
  250. /package/dist/{create-webpack/rule-sets → rules}/constants.d.ts +0 -0
  251. /package/dist/{create-webpack/rule-sets → rules}/constants.js +0 -0
  252. /package/dist/{create-webpack/types.js → types/types-build.js} +0 -0
@@ -0,0 +1,11 @@
1
+ import { type EntryMapItem } from '../../../types/types-entry-map.js';
2
+ import { type EvolveMultiCdnEnvType } from '../../../types/types-multi-html.js';
3
+ import { type FlatEvolveOptions } from '../../../types/types-options.js';
4
+ import type { WebpackPlugin } from '../../../types/types-webpack.js';
5
+ /**
6
+ * Create `html-webpack-plugin` for this build, refer to best practices
7
+ * We'd better pass only one entry for each `build` cycle
8
+ * @param buildEntryItem the entries for this `build`
9
+ * @param allEnv
10
+ */
11
+ export declare const createMultiHtmlWebpackPlugins: (serveMode: boolean, evolveOptions: FlatEvolveOptions, entryMapItemList: EntryMapItem[], allEnv: Array<EvolveMultiCdnEnvType>) => WebpackPlugin[];
@@ -0,0 +1 @@
1
+ import HtmlWebpackPlugin from"html-webpack-plugin";import{existsSync}from"node:fs";import{logger}from"@flatjs/common";import{allowPx2remForModule}from"../../../helpers/allow-px2rem-for-module.js";import{getHtmlPluginConfig}from"../../../helpers/get-html-plugin-config.js";import{normalizeTemplateInjectTokens}from"../../../helpers/normalize-template-inject-tokens.js";import{findEnvCdn}from"../../../helpers/script-injects.js";import{MultiHtmlModifyWebpackPlugin}from"./multi-html-modify-webpack-plugin.js";const minifyOpts={minifyJS:!0,removeComments:!0,collapseWhitespace:!0,collapseBooleanAttributes:!1};export const createMultiHtmlWebpackPlugins=(e,t,l,i)=>{const n=l[0],[,o]=n,m=[new MultiHtmlModifyWebpackPlugin(l)],{options:p}=o,r=e?"development":"production",s=l.map((e=>e[0]));for(const e of i){const l={mode:r,envCdn:findEnvCdn(t.multiHtmlCdn,e)},i=normalizeTemplateInjectTokens(l,p);let o=getHtmlPluginConfig("templatePath",l,p?.templatePath).replace("{0}",e.trim());existsSync(o)||(logger.warn(`The template file ${o} is not exists, use \`prod\` instead!`),o=getHtmlPluginConfig("templatePath",l,p?.templatePath).replace("{0}","prod")),m.push(new HtmlWebpackPlugin({inject:"body",title:getHtmlPluginConfig("title",l,p?.title),chunks:s,minify:!1!==p?.htmlMinify&&!["me","dev"].includes(e)&&minifyOpts,filename:t=>`${t}/index${"prod"===e?"":`-${e}`}.html`,template:o,templateParameters:{title:"<%= title %>",favicon:getHtmlPluginConfig("favicon",l,p?.favicon),viewport:allowPx2remForModule(n,t)?getHtmlPluginConfig("viewport",l,p?.viewport):"",...i},multiCdn:{env:e,disabled:(p?.excludeCdnEnvs||["me","dev","ntv"]).includes(e)}}))}return m};
@@ -0,0 +1,12 @@
1
+ import type { FlatCliOptions } from '../../../types/types-cli-options.js';
2
+ import { type FlatEvolveOptions } from '../../../types/types-options.js';
3
+ import type { WebpackPlugin } from '../../../types/types-webpack.js';
4
+ /**
5
+ * Creates an array of Webpack plugins for generating stats files.
6
+ *
7
+ * @param serveMode - A boolean indicating whether the application is running in serve mode.
8
+ * @param evolveOptions - The options for the evolve package.
9
+ * @param cliOptions - The options passed through the command-line interface.
10
+ * @returns An array of Webpack plugins.
11
+ */
12
+ export declare const createStatsWebpackPlugins: (serveMode: boolean, evolveOptions: FlatEvolveOptions, cliOptions?: FlatCliOptions) => WebpackPlugin[];
@@ -0,0 +1 @@
1
+ import{StatsWebpackPlugin}from"./stats-webpack-plugin.js";export const createStatsWebpackPlugins=(t,e,a={})=>{const{analyzer:r=!1}=a;return t||!r?[]:[new StatsWebpackPlugin({verbose:!0,projectCwd:e.projectCwd})]};
@@ -0,0 +1 @@
1
+ import{rmSync}from"node:fs";import{mkdir}from"node:fs/promises";import{dirname,join,resolve}from"node:path";import{logger}from"@flatjs/common";import{webpackStatsDir}from"../../../constants.js";import{getStatsFileName}from"../../../helpers/get-stats-file-name.js";import{writeStats}from"./helper-write-stats.js";export class StatsWebpackPlugin{constructor(t={}){this.verbose=!0===t.verbose||!1,this.projectCwd=t.projectCwd||process.cwd(),this.outputPath=join(this.projectCwd,webpackStatsDir)}apply(t){this.handleBeforeClean();t.hooks.done.tapAsync("stats-webpack-plugin",((t,e)=>{this.statsFilename=getStatsFileName(t),this.handleDone(t,e)}))}handleBeforeClean(){rmSync(this.outputPath,{force:!0,recursive:!0})}async handleDone(t,e){try{await this.generateStatsFile(t.toJson()),e()}catch(t){e(t)}}async generateStatsFile(t){const e=resolve(this.outputPath,this.statsFilename);await mkdir(dirname(e),{recursive:!0});try{await writeStats(t,e),this.verbose&&logger.debug(`stats-webpack-plugin: saved stats file to ${e}`)}catch(t){this.verbose&&logger.error(`stats-webpack-plugin: error saving stats file to ${e}: ${t}`)}}}
@@ -0,0 +1,2 @@
1
+ export * from './rspack/index.js';
2
+ export * from './wepack/index.js';
@@ -0,0 +1 @@
1
+ export*from"./rspack/index.js";export*from"./wepack/index.js";
@@ -0,0 +1,5 @@
1
+ export * from './rule-assets.js';
2
+ export * from './rule-css.js';
3
+ export * from './rule-less.js';
4
+ export * from './rule-scripts.js';
5
+ export * from './rule-svg-icon.js';
@@ -0,0 +1 @@
1
+ export*from"./rule-assets.js";export*from"./rule-css.js";export*from"./rule-less.js";export*from"./rule-scripts.js";export*from"./rule-svg-icon.js";
@@ -0,0 +1,10 @@
1
+ import type { RuleSetRule } from '@rspack/core';
2
+ import { type EntryMapItem } from '../../types/types-entry-map.js';
3
+ import { type FlatEvolveOptions } from '../../types/types-options.js';
4
+ /**
5
+ * Preparing image loader for normal pictures except stored in folder `icons`
6
+ * Webpack@5 don't need `file-loader`, `raw-loader`, `url-loader` provider us `asset-modules`
7
+ * https://webpack.js.org/guides/asset-modules/
8
+ * @param entryMapItemList The available entries, `development` it contains multiple enties, `production`
9
+ */
10
+ export declare const rspackRuleAssets: (entryMapItemList: EntryMapItem[], evolveOptions: FlatEvolveOptions) => RuleSetRule;
@@ -0,0 +1 @@
1
+ import{resolvePublicPath}from"../../helpers/resolve-public-path.js";import{FONT_PATH_REGEX,IMAGE_PATH_REGEX}from"../constants.js";import{getEntryAssetFileName,isIconSvg}from"../rule-utils.js";export const rspackRuleAssets=(e,t)=>{const s=resolvePublicPath(t);return{type:"asset",test:e=>FONT_PATH_REGEX.test(e)||IMAGE_PATH_REGEX.test(e)&&!isIconSvg(e),generator:{filename:({filename:s})=>getEntryAssetFileName(s,e,t),publicPath:"auto"===s?void 0:s},parser:{dataUrlCondition:{maxSize:t.loaderOptions.assetDataUrlMaxSize}}}};
@@ -0,0 +1,11 @@
1
+ import { type RuleSetRule } from '@rspack/core';
2
+ import { type EntryMapItem } from '../../types/types-entry-map.js';
3
+ import { type FlatEvolveOptions } from '../../types/types-options.js';
4
+ /**
5
+ * Actually, style-loader is the one that is responsible for CSS HMR
6
+ * https://github.com/webpack-contrib/style-loader/blob/master/src/index.js#L31-L42
7
+ * @param serveMode
8
+ * @param entryMapItem
9
+ * @param evolveOptions `builtin` loaders
10
+ */
11
+ export declare const rspackRuleCss: (serveMode: boolean, entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions, useCssModule?: boolean) => RuleSetRule;
@@ -0,0 +1 @@
1
+ import{requireResolve}from"@flatjs/common";import{forgePostcssPluginPixel}from"@flatjs/forge-postcss-plugin-pixel";import{CssExtractRspackPlugin}from"@rspack/core";import{allowPx2remForModule}from"../../helpers/allow-px2rem-for-module.js";const getPostcssOptions=(s={},o={})=>{const e=o.plugins||[];return!1!==s&&e.push(forgePostcssPluginPixel(s)),{plugins:e}};export const rspackRuleCss=(s,o,e,r=!1)=>{const{pixelOptions:t,cssLoaderOptions:l={},postcssOptions:i}=e.loaderOptions,{modules:p,...c}=l,u=r?{modules:Object.assign({namedExport:!1},p)}:{modules:!1},n={test:/\.css$/i,use:[{loader:CssExtractRspackPlugin.loader,options:{esModule:!0}},{loader:requireResolve(import.meta.url,"css-loader"),options:{sourceMap:s,...u,...c}}]};r?n.include=/\.module\.css$/i:n.exclude=/\.module\.css$/i;const a=allowPx2remForModule(o,e);if(Array.isArray(n.use)){const o=getPostcssOptions(!!a&&t,i);n.use.push({loader:requireResolve(import.meta.url,"postcss-loader"),options:{postcssOptions:{...o,config:!1},sourceMap:s}})}return n};
@@ -0,0 +1,26 @@
1
+ import type { RuleSetRule } from '@rspack/core';
2
+ import { type EntryMapItem } from '../../types/types-entry-map.js';
3
+ import { type FlatEvolveOptions } from '../../types/types-options.js';
4
+ /**
5
+ * Preparing configurations for `less-loader`
6
+ * @param serveMode The value indicates if we are in `built` or `serve` mode.
7
+ * @param pluginLoaderOptions `builtin` loaders
8
+ * @example
9
+ * ```ts
10
+ * `~` makes the url an module
11
+ * webpack: {
12
+ * externals: {
13
+ * antd: 'antd',
14
+ * dayjs: 'dayjs',
15
+ * },
16
+ * resolve: {
17
+ * alias: {
18
+ * '@': resolve(projectCwd, './src'),
19
+ * },
20
+ * },
21
+ * },
22
+ * `@import '~@/theme/default.less';` at `src/theme/default.less`
23
+ *
24
+ * ```
25
+ */
26
+ export declare const rspackRuleLess: (serveMode: boolean, entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => RuleSetRule;
@@ -0,0 +1 @@
1
+ import{requireResolve}from"@flatjs/common";import{rspackRuleCss}from"./rule-css.js";export const rspackRuleLess=(s,e,r)=>{const o=rspackRuleCss(s,e,r);o.test=/\.less$/i;const t=r.loaderOptions.lessOptions;return Array.isArray(o.use)&&o.use.push({loader:requireResolve(import.meta.url,"less-loader"),options:{sourceMap:s,lessOptions:{sourceMap:s,javascriptEnabled:!0,...t}}}),o};
@@ -0,0 +1,3 @@
1
+ import type { RuleSetRule } from '@rspack/core';
2
+ import { type EntryMapItem, type FlatEvolveOptions } from '../../types/index.js';
3
+ export declare const rspackRuleScripts: (serveMode: boolean, entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => RuleSetRule;
@@ -0,0 +1 @@
1
+ import{assertSwcImportOptions}from"@flatjs/babel-plugin-import/helpers";import{shouldEnableReactFastRefresh}from"../../helpers/should-enable-react-fast-refresh.js";export const rspackRuleScripts=(e,t,r)=>{const{loaderOptions:s,projectCwd:a}=r,{modularImports:o=[]}=s,p=assertSwcImportOptions(a,o),l=shouldEnableReactFastRefresh(e,t,r);return{test:/\.(jsx|tsx|ts|js|mjs|cjs|mts|cts)$/,exclude:/node_modules/,use:[{loader:"builtin:swc-loader",options:{jsc:{parser:{decorators:!0,syntax:"typescript",tsx:!0},externalHelpers:!0,experimental:{keepImportAttributes:!0,plugins:[["@flatjs/swc-plugin-import",{modularImports:p}]]},transform:{legacyDecorator:!0,react:{runtime:"automatic",pragma:"React.createElement",pragmaFrag:"React.Fragment",throwIfNamespace:!0,development:l,refresh:l}}},env:{mode:"entry",targets:{browsers:["ie >= 11","safari > 10"]}}}}]}};
@@ -0,0 +1,6 @@
1
+ import type { RuleSetRule } from '@rspack/core';
2
+ /**
3
+ * Preparing svg loader for `icons`
4
+ * Note we must be put all *.svg into folder `icons`
5
+ */
6
+ export declare const rspackRuleSvgIcon: () => RuleSetRule;
@@ -0,0 +1 @@
1
+ import{getDirname}from"@armit/file-utility";import{isIconSvg}from"../rule-utils.js";export const rspackRuleSvgIcon=()=>({test:e=>isIconSvg(e),use:[{loader:getDirname(import.meta.url,"../../loaders/loader-icon.cjs"),options:{svgo:{plugins:[{name:"removeTitle"},{name:"removeDimensions"}]}}}]});
@@ -0,0 +1,19 @@
1
+ import type { EntryMapItem } from '../types/types-entry-map.js';
2
+ import type { FlatEvolveOptions } from '../types/types-options.js';
3
+ /**
4
+ * Causeof we expose a component <Icon /> from `@wove/react` it can be optimized via icon-loader.
5
+ * limitation assets match `svg-icons/**\/*.svg` to icon loader resolver.
6
+ * @param resource
7
+ * @returns
8
+ */
9
+ export declare const isIconSvg: (resource: string) => boolean;
10
+ /**
11
+ * Get the asset filename based on the entry configuration.
12
+ * This function determines the output path for assets by matching them against entry points.
13
+ *
14
+ * @param filename - The original filename of the asset
15
+ * @param entryMapItemList - List of entry configurations
16
+ * @param evolveOptions - Configuration options containing project paths
17
+ * @returns The formatted asset filename with content hash
18
+ */
19
+ export declare const getEntryAssetFileName: (filename: string, entryMapItemList: EntryMapItem[], evolveOptions: FlatEvolveOptions) => string;
@@ -0,0 +1 @@
1
+ import{dirname,join,relative,resolve}from"node:path";import{ensureSlash,normalizePlatformPath}from"@flatjs/common";import{ICON_PATH_REGEX}from"./constants.js";export const isIconSvg=t=>ICON_PATH_REGEX.test(t)&&t.endsWith(".svg");export const getEntryAssetFileName=(t,e,r)=>{const{projectCwd:o,projectVirtualPath:n}=r;let s=dirname(join(n,t.replace(/^src/,"")));const a=[];for(const[t,r]of e)for(const e of r.entry)a.push({entryName:t,entry:e});a.sort(((t,e)=>e.entry.length-t.entry.length));for(const e of a){const{entryName:r,entry:n}=e,a=dirname(join(o,n)),i=resolve(o,t);if(i.startsWith(ensureSlash(a,!0,!0))){s=dirname(join(r,relative(a,i)));break}}return`${normalizePlatformPath(s)}/[name]-[contenthash:8][ext]`};
@@ -0,0 +1,5 @@
1
+ export * from './rule-assets.js';
2
+ export * from './rule-css.js';
3
+ export * from './rule-less.js';
4
+ export * from './rule-scripts.js';
5
+ export * from './rule-svg-icon.js';
@@ -0,0 +1 @@
1
+ export*from"./rule-assets.js";export*from"./rule-css.js";export*from"./rule-less.js";export*from"./rule-scripts.js";export*from"./rule-svg-icon.js";
@@ -7,4 +7,4 @@ import { type FlatEvolveOptions } from '../../types/types-options.js';
7
7
  * https://webpack.js.org/guides/asset-modules/
8
8
  * @param entryMapItemList The available entries, `development` it contains multiple enties, `production`
9
9
  */
10
- export declare const ruleAssets: (entryMapItemList: EntryMapItem[], evolveOptions: FlatEvolveOptions) => RuleSetRule;
10
+ export declare const webpackRuleAssets: (entryMapItemList: EntryMapItem[], evolveOptions: FlatEvolveOptions) => RuleSetRule;
@@ -0,0 +1 @@
1
+ import{resolvePublicPath}from"../../helpers/resolve-public-path.js";import{FONT_PATH_REGEX,IMAGE_PATH_REGEX}from"../constants.js";import{getEntryAssetFileName,isIconSvg}from"../rule-utils.js";export const webpackRuleAssets=(e,t)=>{const s=resolvePublicPath(t);return{type:"asset",test:e=>FONT_PATH_REGEX.test(e)||IMAGE_PATH_REGEX.test(e)&&!isIconSvg(e),generator:{filename:({filename:s})=>getEntryAssetFileName(s,e,t),publicPath:"auto"===s?void 0:s},parser:{dataUrlCondition:{maxSize:t.loaderOptions.assetDataUrlMaxSize}}}};
@@ -8,4 +8,4 @@ import { type FlatEvolveOptions } from '../../types/types-options.js';
8
8
  * @param entryMapItem
9
9
  * @param evolveOptions `builtin` loaders
10
10
  */
11
- export declare const ruleCss: (serveMode: boolean, entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions, useCssModule?: boolean) => RuleSetRule;
11
+ export declare const webpackRuleCss: (serveMode: boolean, entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions, useCssModule?: boolean) => RuleSetRule;
@@ -0,0 +1 @@
1
+ import cssnano from"cssnano";import MiniCssExtractPlugin from"mini-css-extract-plugin";import{requireResolve}from"@flatjs/common";import{forgePostcssPluginPixel}from"@flatjs/forge-postcss-plugin-pixel";import{allowPx2remForModule}from"../../helpers/allow-px2rem-for-module.js";const getPostcssOptions=(s,o={},e={})=>{const r=[...e.plugins||[],cssnano({preset:["default",{discardComments:{removeAll:!s},reduceInitial:!1,normalizeWhitespace:!s,...e.cssnanoOptions}]})];return!1!==o&&r.push(forgePostcssPluginPixel(o)),{plugins:r}};export const webpackRuleCss=(s,o,e,r=!1)=>{const{pixelOptions:t,cssLoaderOptions:i={},postcssOptions:l}=e.loaderOptions,{modules:n,...p}=i,c=r?{modules:Object.assign({namedExport:!1},n)}:{modules:!1},u={test:/\.css$/i,use:[{loader:MiniCssExtractPlugin.loader,options:{esModule:!0}},{loader:requireResolve(import.meta.url,"css-loader"),options:{sourceMap:s,...c,...p}}]};r?u.include=/\.module\.css$/i:u.exclude=/\.module\.css$/i;const a=allowPx2remForModule(o,e);if(Array.isArray(u.use)){const o=getPostcssOptions(s,!!a&&t,l);u.use.push({loader:requireResolve(import.meta.url,"postcss-loader"),options:{postcssOptions:{...o,config:!1},sourceMap:s}})}return u};
@@ -23,4 +23,4 @@ import { type FlatEvolveOptions } from '../../types/types-options.js';
23
23
  *
24
24
  * ```
25
25
  */
26
- export declare const ruleLess: (serveMode: boolean, entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => RuleSetRule;
26
+ export declare const webpackRuleLess: (serveMode: boolean, entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => RuleSetRule;
@@ -0,0 +1 @@
1
+ import{requireResolve}from"@flatjs/common";import{webpackRuleCss}from"./rule-css.js";export const webpackRuleLess=(s,e,r)=>{const o=webpackRuleCss(s,e,r);o.test=/\.less$/i;const t=r.loaderOptions.lessOptions;return Array.isArray(o.use)&&o.use.push({loader:requireResolve(import.meta.url,"less-loader"),options:{sourceMap:s,lessOptions:{sourceMap:s,javascriptEnabled:!0,...t}}}),o};
@@ -2,4 +2,4 @@ import { type RuleSetRule } from 'webpack';
2
2
  import { type TransformOptions } from '@babel/core';
3
3
  import { type EntryMapItem, type FlatEvolveOptions } from '../../types/index.js';
4
4
  export declare const ruleBabel: (options: TransformOptions) => RuleSetRule;
5
- export declare const ruleScripts: (serveMode: boolean, entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => RuleSetRule;
5
+ export declare const webpackRuleScripts: (serveMode: boolean, entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => RuleSetRule;
@@ -0,0 +1 @@
1
+ import{requireResolve}from"@flatjs/common";import{mergeBabelOption}from"../../helpers/merge-babel-options.js";import{shouldEnableReactFastRefresh}from"../../helpers/should-enable-react-fast-refresh.js";export const ruleBabel=e=>({test:/\.(tsx|ts|js|jsx|mjs|cjs|mts|cts)$/,use:[{loader:requireResolve(import.meta.url,"babel-loader"),options:e}]});export const webpackRuleScripts=(e,r,s)=>{const{projectCwd:t}=s,{babelOptions:o={},modularImports:l=[]}=s.loaderOptions,a=mergeBabelOption(e,l,o,t);return shouldEnableReactFastRefresh(e,r,s)&&(a.plugins?a.plugins.push(requireResolve(import.meta.url,"react-refresh/babel")):a.plugins=[requireResolve(import.meta.url,"react-refresh/babel")]),ruleBabel(a)};
@@ -3,4 +3,4 @@ import { type RuleSetRule } from 'webpack';
3
3
  * Preparing svg loader for `icons`
4
4
  * Note we must be put all *.svg into folder `icons`
5
5
  */
6
- export declare const ruleSvgIcon: () => RuleSetRule;
6
+ export declare const webpackRuleSvgIcon: () => RuleSetRule;
@@ -0,0 +1 @@
1
+ import{getDirname}from"@armit/file-utility";import{isIconSvg}from"../rule-utils.js";export const webpackRuleSvgIcon=()=>({test:e=>isIconSvg(e),use:[{loader:getDirname(import.meta.url,"../../loaders/loader-icon.cjs"),options:{svgo:{plugins:[{name:"removeTitle"},{name:"removeDimensions"}]}}}]});
@@ -1,4 +1,6 @@
1
1
  export * from './types-analyzer.js';
2
+ export * from './types-build.js';
3
+ export * from './types-cli-options.js';
2
4
  export * from './types-dev-server.js';
3
5
  export * from './types-entry-map.js';
4
6
  export * from './types-federation.js';
@@ -1 +1 @@
1
- export*from"./types-analyzer.js";export*from"./types-dev-server.js";export*from"./types-entry-map.js";export*from"./types-federation.js";export*from"./types-global-compiler-options.js";export*from"./types-loader-options.js";export*from"./types-modular-import.js";export*from"./types-multi-html.js";export*from"./types-options.js";export*from"./types-webpack.js";
1
+ export*from"./types-analyzer.js";export*from"./types-build.js";export*from"./types-cli-options.js";export*from"./types-dev-server.js";export*from"./types-entry-map.js";export*from"./types-federation.js";export*from"./types-global-compiler-options.js";export*from"./types-loader-options.js";export*from"./types-modular-import.js";export*from"./types-multi-html.js";export*from"./types-options.js";export*from"./types-webpack.js";
@@ -0,0 +1,4 @@
1
+ export type EvolveBuildResult = {
2
+ name?: string[];
3
+ warningStats?: unknown;
4
+ };
@@ -9,4 +9,9 @@ export interface FlatCliOptions {
9
9
  * @default false
10
10
  */
11
11
  analyzer?: boolean;
12
+ /**
13
+ * The kernel types used for building currently offer webpack and rspack
14
+ * @default 'webpack'
15
+ */
16
+ compilerType?: 'webpack' | 'rspack';
12
17
  }
@@ -115,3 +115,26 @@ export type FlatEvolveDevServerOptions = {
115
115
  */
116
116
  https?: SecureContextHttps;
117
117
  };
118
+ export type EvolveDevServerEntryMap = {
119
+ /**
120
+ * entryName: `home`
121
+ */
122
+ [entryName: string]: {
123
+ /**
124
+ * entryMapItem config options.
125
+ */
126
+ entryConfig: EvolveEntryMapContent;
127
+ /**
128
+ * dev server port number
129
+ */
130
+ devServerPort: number;
131
+ /**
132
+ * dev server host uri.
133
+ */
134
+ devServerHostUri: string;
135
+ /**
136
+ * entryName: `home` should be normallized to ${`projectVirtualPath`}/home
137
+ */
138
+ normalizedEntryName: string;
139
+ };
140
+ };
@@ -2,7 +2,7 @@ import { type LibraryOptions } from 'webpack';
2
2
  /**
3
3
  * Advanced configuration for modules that should be shared in the share scope.
4
4
  */
5
- interface SharedConfig {
5
+ export interface SharedConfig {
6
6
  /**
7
7
  * Include the provided and fallback module directly instead behind an async request. This allows to use this shared module in initial load too. All possible shared modules need to be eager too.
8
8
  */
@@ -40,7 +40,7 @@ interface SharedConfig {
40
40
  */
41
41
  version?: string | false;
42
42
  }
43
- interface SharedObject {
43
+ export interface SharedObject {
44
44
  [index: string]: string | SharedConfig;
45
45
  }
46
46
  /**
@@ -117,4 +117,3 @@ export type ModuleFederationOptions = {
117
117
  */
118
118
  shared?: (string | SharedObject)[] | SharedObject;
119
119
  };
120
- export {};
@@ -134,4 +134,9 @@ export interface FlatEvolveOptions {
134
134
  * @default 10
135
135
  */
136
136
  maxEntryGroupSize?: number;
137
+ /**
138
+ * Whether to open the rs-evolve doctor plugin.
139
+ * @default false
140
+ */
141
+ openRsdoctor?: boolean;
137
142
  }
@@ -1,17 +1,48 @@
1
+ import type { Compiler, WebpackPluginInstance } from 'webpack';
1
2
  import { type Configuration, type RuleSetRule } from 'webpack';
2
- import { type WebpackPlugin } from '../create-webpack/types.js';
3
3
  import { type TerserMinimizerOptions } from '../minimizer/types.js';
4
+ export type WebpackPlugin = ((this: Compiler, compiler: Compiler) => void) | WebpackPluginInstance;
4
5
  /**
5
6
  * The webpack entry configuration.
6
7
  */
7
8
  export interface WebpackEntryObject {
8
9
  [index: string]: string | [string, ...string[]];
9
10
  }
10
- export interface FlatEvolveWebpackOptions extends Pick<Configuration, 'performance' | 'stats' | 'infrastructureLogging'> {
11
+ export interface FlatEvolveWebpackOptions extends Pick<Configuration, 'infrastructureLogging'> {
12
+ /**
13
+ * Options for the performance hints.
14
+ */
15
+ performance?: false | {
16
+ /**
17
+ * Filter function to select assets that are checked.
18
+ */
19
+ assetFilter?: (name: string, source?: any, assetInfo?: any) => boolean;
20
+ /**
21
+ * Sets the format of the hints: warnings, errors or nothing at all.
22
+ */
23
+ hints?: false | 'error' | 'warning';
24
+ /**
25
+ * File size limit (in bytes) when exceeded, that webpack will provide performance hints.
26
+ */
27
+ maxAssetSize?: number;
28
+ /**
29
+ * Total size of an entry point (in bytes).
30
+ */
31
+ maxEntrypointSize?: number;
32
+ };
33
+ /**
34
+ * Options for the stats.
35
+ */
36
+ stats?: Omit<Configuration['stats'], 'preset'> & {
37
+ /**
38
+ * Sets the preset for stats or enables/disables them.
39
+ */
40
+ preset?: boolean | 'normal' | 'none' | 'verbose' | 'errors-only' | 'errors-warnings' | 'minimal' | 'detailed' | 'summary';
41
+ };
11
42
  /**
12
43
  * These options change how modules are resolved.
13
44
  */
14
- resolve?: Configuration['resolve'] & {
45
+ resolve?: Omit<Configuration['resolve'], 'fallback'> & {
15
46
  /**
16
47
  * Only allow pass `key:value` alias `{'@xxx':'./src/xxx'}`
17
48
  * Note: Usually you don't need to specify an alias, the framework will auto support `paths` alias of tsconfig.json
@@ -26,6 +57,14 @@ export interface FlatEvolveWebpackOptions extends Pick<Configuration, 'performan
26
57
  * ```
27
58
  */
28
59
  alias?: Record<string, string>;
60
+ /**
61
+ * Redirect module requests when normal resolving fails.
62
+ *
63
+ * Compatible with both rspack and webpack, using intersection of their types.
64
+ */
65
+ fallback?: {
66
+ [x: string]: string | false | string[];
67
+ };
29
68
  };
30
69
  /**
31
70
  * Specify the default type of externals.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatjs/evolve",
3
- "version": "2.3.2-next.0",
3
+ "version": "2.3.2-next.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -25,12 +25,18 @@
25
25
  "build-release": "yarn build && rimraf ./_release && yarn pack && mkdir ./_release && tar zxvf ./package.tgz --directory ./_release && rm ./package.tgz",
26
26
  "minify": "node ../../scripts/minify.mjs --dest=dist",
27
27
  "codegen": "graphql-codegen --config ./codegen.cjs",
28
- "clean": "rimraf --no-glob ./dist ./coverage ./__data__ ./config/__data__ ./_release ./tsconfig.tsbuildinfo",
28
+ "clean": "rimraf --no-glob ./dist ./node_modules ./coverage ./__data__ ./config/__data__ ./_release ./tsconfig.tsbuildinfo",
29
29
  "lint": "eslint . --cache --cache-location ../../.cache/eslint/evolve.eslintcache",
30
30
  "test": "run-s test-unit",
31
- "test-task": "vitest run",
32
- "test-unit": "vitest run --passWithNoTests",
33
- "test-watch": "vitest watch --ui",
31
+ "test-task": "run-s test-task:webpack && run-s test-task:rspack",
32
+ "test-unit": "run-s test-unit:webpack && run-s test-unit:rspack",
33
+ "test-watch": "run-s test-watch:webpack && run-s test-watch:rspack",
34
+ "test-task:webpack": "COMPILER_TYPE=webpack vitest run --exclude **/rspack-main",
35
+ "test-unit:webpack": "COMPILER_TYPE=webpack vitest run --passWithNoTests --exclude **/rspack-main",
36
+ "test-watch:webpack": "COMPILER_TYPE=webpack vitest watch --ui --exclude **/rspack-main",
37
+ "test-task:rspack": "COMPILER_TYPE=rspack vitest run --exclude **/webpack-main",
38
+ "test-unit:rspack": "COMPILER_TYPE=rspack vitest run --passWithNoTests --exclude **/webpack-main",
39
+ "test-watch:rspack": "COMPILER_TYPE=rspack vitest watch --ui --exclude **/webpack-main",
34
40
  "fix-all-files": "eslint . --fix",
35
41
  "typecheck": "tsc --project ./tsconfig.json --noEmit"
36
42
  },
@@ -43,14 +49,19 @@
43
49
  "@babel/core": "^7.26.10",
44
50
  "@clack/prompts": "^0.10.1",
45
51
  "@discoveryjs/json-ext": "0.6.3",
46
- "@flatjs/babel-plugin-import": "2.2.9-next.0",
47
- "@flatjs/common": "2.2.3",
48
- "@flatjs/evolve-preset-babel": "2.2.3",
49
- "@flatjs/forge-postcss-plugin-pixel": "2.2.3",
50
- "@flatjs/forge-ts-checker": "1.1.1",
51
- "@flatjs/graph": "2.2.9-next.0",
52
- "@flatjs/mock": "2.4.1-next.0",
52
+ "@flatjs/babel-plugin-import": "2.2.9-next.1",
53
+ "@flatjs/common": "2.2.4-next.0",
54
+ "@flatjs/evolve-preset-babel": "2.2.4-next.0",
55
+ "@flatjs/forge-postcss-plugin-pixel": "2.2.4-next.0",
56
+ "@flatjs/forge-ts-checker": "1.1.2-next.0",
57
+ "@flatjs/graph": "2.2.9-next.1",
58
+ "@flatjs/mock": "2.4.1-next.1",
53
59
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.16",
60
+ "@rsdoctor/rspack-plugin": "^1.1.2",
61
+ "@rspack/core": "^1.3.10",
62
+ "@rspack/dev-server": "^1.1.1",
63
+ "@rspack/plugin-react-refresh": "^1.4.3",
64
+ "@swc/helpers": "^0.5.17",
54
65
  "@types/babel__core": "^7.20.5",
55
66
  "babel-loader": "^10.0.0",
56
67
  "better-opn": "^3.0.2",
@@ -76,7 +87,6 @@
76
87
  "svgo": "^3.3.2",
77
88
  "tarjan-graph": "^3.0.0",
78
89
  "terser-webpack-plugin": "^5.3.14",
79
- "tinypool": "^1.0.2",
80
90
  "tsconfig-paths-webpack-plugin": "^4.2.0",
81
91
  "type-fest": "^4.40.0",
82
92
  "typescript": "^5.8.3",
@@ -90,7 +100,7 @@
90
100
  "@dimjs/model": "2.1.1",
91
101
  "@dimjs/model-react": "2.1.1",
92
102
  "@dimjs/utils": "2.1.2",
93
- "@flatjs/testing": "2.2.3",
103
+ "@flatjs/testing": "2.2.4-next.0",
94
104
  "@hyperse/eslint-config-hyperse": "^1.4.1",
95
105
  "@swc/core": "1.11.21",
96
106
  "@types/express": "5.0.1",
@@ -105,7 +115,7 @@
105
115
  "react": "19.1.0",
106
116
  "rimraf": "6.0.1",
107
117
  "vite-tsconfig-paths": "5.1.4",
108
- "vitest": "3.1.2",
118
+ "vitest": "3.1.4",
109
119
  "vue-loader": "17.4.2"
110
120
  },
111
121
  "peerDependencies": {
@@ -1 +0,0 @@
1
- import{posix}from"node:path";import{devReactFastRefresh}from"../constants.js";import{shouldEnableReactFastRefresh}from"../helpers/should-enable-react-fast-refresh.js";import{createMinimizers}from"../minimizer/index.js";export const createOptimization=(e,i,n)=>({nodeEnv:e?"development":"production",chunkIds:"named",moduleIds:"named",runtimeChunk:!!shouldEnableReactFastRefresh(e,n,i)&&{name:e=>posix.join(e.name,devReactFastRefresh.runtime)},minimize:!1!==i.webpack?.minimizer&&!e,minimizer:createMinimizers(e,i.webpack),splitChunks:{name:!1,chunks:"all",minSize:25e5,cacheGroups:{default:!1,defaultVendors:!1}}});
@@ -1 +0,0 @@
1
- import{join}from"node:path";import{enableBundleHashNameForModule}from"../helpers/enable-bundle-hashname-for-module.js";import{getBundleFileName}from"../helpers/get-bundle-file-name.js";import{resolvePublicPath}from"./resolve-public-path.js";export const createOutput=async(e,o,t)=>{const{projectCwd:n,webpack:a}=o,l=t[1],i=enableBundleHashNameForModule(o,l?.options),u=resolvePublicPath(o),p="function"==typeof a?.outputDir?await a.outputDir():a?.outputDir||"public";return{devtoolModuleFilenameTemplate:({namespace:e,resourcePath:o})=>`webpack:///${join(e,o)}`,environment:{},pathinfo:!1,path:join(n,p),publicPath:u,filename:`[name]/${getBundleFileName("js",e,i)}`,chunkFilename:i?"[id].[contenthash].js":"[id].js",...l.options?.output}};
@@ -1,5 +0,0 @@
1
- import type { FlatCliOptions } from '../types/types-cli-options.js';
2
- import { type EntryMapItem } from '../types/types-entry-map.js';
3
- import { type FlatEvolveOptions } from '../types/types-options.js';
4
- import { type FlatEvolveWebpackOptions } from '../types/types-webpack.js';
5
- export declare const createPlugins: (serveMode: boolean, entryMapItemList: EntryMapItem[], evolveOptions: FlatEvolveOptions, cliOptions?: FlatCliOptions) => Promise<FlatEvolveWebpackOptions["plugins"]>;
@@ -1 +0,0 @@
1
- import CaseSensitivePathsPlugin from"case-sensitive-paths-webpack-plugin";import MiniCssExtractPlugin from"mini-css-extract-plugin";import webpack from"webpack";import{logger}from"@flatjs/common";import ReactRefreshWebpackPlugin from"@pmmmwh/react-refresh-webpack-plugin";import{enableBundleHashNameForModule}from"../helpers/enable-bundle-hashname-for-module.js";import{getBundleFileName}from"../helpers/get-bundle-file-name.js";import{shouldEnableReactFastRefresh}from"../helpers/should-enable-react-fast-refresh.js";import{createCircularDependencyPlugin}from"../plugins/circular-dependency/index.js";import{createCleanWebpackPlugin}from"../plugins/clean-webpack/index.js";import{createBuiltinDefineVariables}from"../plugins/define-variable/index.js";import{createModuleFederationPlugin}from"../plugins/module-federation/index.js";import{createHtmlPlugins}from"../plugins/multi-html/index.js";import{createStatsWebpackPlugin}from"../plugins/stats-webpack/index.js";export const createPlugins=async(e,a,i,n)=>{const r=a[0],[l,t]=r,s=enableBundleHashNameForModule(i,t?.options),c=[new webpack.WatchIgnorePlugin({paths:[/\.d\.[cm]ts$/]}),new CaseSensitivePathsPlugin,...createCircularDependencyPlugin(e,i),new MiniCssExtractPlugin({filename:`[name]/${getBundleFileName("css",e,s)}`,chunkFilename:s?"[id].[contenthash].css":"[id].css"}),...await createBuiltinDefineVariables(e,i),...createCleanWebpackPlugin(e,a,i),...createModuleFederationPlugin(e,a,i),...createHtmlPlugins(e,a,i),...createStatsWebpackPlugin(e,i,n)],o=shouldEnableReactFastRefresh(e,r,i);o&&c.push(new ReactRefreshWebpackPlugin({overlay:!1})),!o&&e&&(i.devServer?.liveReload?logger.warn('The HMR disabled cause of "liveReload" specificed'):logger.warn(`The HMR disabled cause of \`"moduleFederation":"${l}"\``));const u=i.webpack?.plugins||[];return c.concat(u)};
@@ -1 +0,0 @@
1
- import{ruleAssets}from"./rule-sets/rule-assets.js";import{ruleCss}from"./rule-sets/rule-css.js";import{ruleLess}from"./rule-sets/rule-less.js";import{ruleScripts}from"./rule-sets/rule-scripts.js";import{ruleSvgIcon}from"./rule-sets/rule-svg-icon.js";export const createRuleSets=(s,e,r)=>{const l=e[0],t=[ruleSvgIcon(),ruleAssets(e,r),ruleCss(s,l,r,!1),ruleCss(s,l,r,!0),ruleLess(s,l,r),ruleScripts(s,l,r)],u=r.webpack?.ruleSets||[];return t.concat(u)};
@@ -1 +0,0 @@
1
- import fg from"fast-glob";import{existsSync}from"node:fs";import{posix}from"node:path";import{logger}from"@flatjs/common";import{normalizeEntryModuleAbsolutePath}from"../helpers/normalize-entry-module-absolute-path.js";export const loadWatchOptions=(o,t,e={})=>{const{ignored:r=[]}=e,{entryMap:n}=t,s=normalizeEntryModuleAbsolutePath(t,o),a=normalizeEntryModuleAbsolutePath(t,n);for(const o of a){existsSync(o)||logger.warn(`The module path does not exist. Check ${o}`);s.findIndex((t=>t===o))<0&&r.push(posix.join("**",fg.convertPathToPattern(o),"**/*"))}return{...e,ignored:r}};
@@ -1 +0,0 @@
1
- import{assertGroupEntryItem}from"../helpers/assert-group-entry-item.js";import{createExternals}from"./create-externals.js";import{createOptimization}from"./create-optimization.js";import{createOutput}from"./create-output.js";import{createPerformance}from"./create-performance.js";import{createPlugins}from"./create-plugins.js";import{createResolve}from"./create-resolve.js";import{createRuleSets}from"./create-rule-sets.js";import{loadWatchOptions}from"./load-watch-options.js";export const loadWebpackConfig=async(e,t,r,a)=>{const o="development"===e,{projectCwd:s,webpack:c,devServer:n}=r,p=loadWatchOptions(t,r,n?.watchOptions),i=assertGroupEntryItem(t,r),m=createRuleSets(o,i,r),l=await createPlugins(o,i,r,a),u=i[0];return{mode:e,plugins:l,watchOptions:p,output:await createOutput(o,r,u),context:s,target:c?.target??["web","es5"],resolve:createResolve(s,c),module:{rules:m},devtool:o?"eval-source-map":c?.sourceMap||!1,externalsType:c?.externalsType,externals:createExternals(c?.externals,u),performance:createPerformance(o,c?.performance),optimization:createOptimization(o,r,u),infrastructureLogging:c?.infrastructureLogging??{level:"warn"},stats:c?.stats??{preset:"errors-warnings"},cache:{type:"memory"}}};
@@ -1 +0,0 @@
1
- import{dirname,join,relative,resolve}from"node:path";import{ensureSlash,normalizePlatformPath}from"@flatjs/common";import{resolvePublicPath}from"../resolve-public-path.js";import{FONT_PATH_REGEX,IMAGE_PATH_REGEX}from"./constants.js";import{isIconSvg}from"./rule-utils.js";const getEntryAssetFileName=(e,t,r)=>{const{projectCwd:o,projectVirtualPath:n}=r;let s=dirname(join(n,e.replace(/^src/,"")));const a=[];for(const[e,r]of t)for(const t of r.entry)a.push({entryName:e,entry:t});a.sort(((e,t)=>t.entry.length-e.entry.length));for(const t of a){const{entryName:r,entry:n}=t,a=dirname(join(o,n)),i=resolve(o,e);if(i.startsWith(ensureSlash(a,!0,!0))){s=dirname(join(r,relative(a,i)));break}}return`${normalizePlatformPath(s)}/[name]-[contenthash:8][ext]`};export const ruleAssets=(e,t)=>{const r=resolvePublicPath(t);return{type:"asset",test:e=>FONT_PATH_REGEX.test(e)||IMAGE_PATH_REGEX.test(e)&&!isIconSvg(e),generator:{filename:({filename:r})=>getEntryAssetFileName(r,e,t),publicPath:"auto"===r?void 0:r},parser:{dataUrlCondition:{maxSize:t.loaderOptions.assetDataUrlMaxSize}}}};
@@ -1 +0,0 @@
1
- import cssnano from"cssnano";import MiniCssExtractPlugin from"mini-css-extract-plugin";import{requireResolve}from"@flatjs/common";import{forgePostcssPluginPixel}from"@flatjs/forge-postcss-plugin-pixel";import{allowPx2remForModule}from"../../helpers/allow-px2rem-for-module.js";const getPostcssOptions=(s,o={},e={})=>{const r=[...e.plugins||[],cssnano({preset:["default",{discardComments:{removeAll:!s},reduceInitial:!1,normalizeWhitespace:!s,...e.cssnanoOptions}]})];return!1!==o&&r.push(forgePostcssPluginPixel(o)),{plugins:r}};export const ruleCss=(s,o,e,r=!1)=>{const{pixelOptions:t,cssLoaderOptions:i={},postcssOptions:l}=e.loaderOptions,{modules:n,...p}=i,c=r?{modules:Object.assign({namedExport:!1},n)}:{modules:!1},u={test:/\.css$/i,use:[{loader:MiniCssExtractPlugin.loader,options:{esModule:!0}},{loader:requireResolve(import.meta.url,"css-loader"),options:{sourceMap:s,...c,...p}}]};r?u.include=/\.module\.css$/i:u.exclude=/\.module\.css$/i;const a=allowPx2remForModule(o,e);if(Array.isArray(u.use)){const o=getPostcssOptions(s,!!a&&t,l);u.use.push({loader:requireResolve(import.meta.url,"postcss-loader"),options:{postcssOptions:{...o,config:!1},sourceMap:s}})}return u};
@@ -1 +0,0 @@
1
- import{requireResolve}from"@flatjs/common";import{ruleCss}from"./rule-css.js";export const ruleLess=(s,e,r)=>{const o=ruleCss(s,e,r);o.test=/\.less$/i;const t=r.loaderOptions.lessOptions;return Array.isArray(o.use)&&o.use.push({loader:requireResolve(import.meta.url,"less-loader"),options:{sourceMap:s,lessOptions:{sourceMap:s,javascriptEnabled:!0,...t}}}),o};
@@ -1 +0,0 @@
1
- import{requireResolve}from"@flatjs/common";import{mergeBabelOption}from"../../helpers/merge-babel-options.js";import{shouldEnableReactFastRefresh}from"../../helpers/should-enable-react-fast-refresh.js";export const ruleBabel=e=>({test:/\.(tsx|ts|js|jsx|mjs|cjs|mts|cts)$/,use:[{loader:requireResolve(import.meta.url,"babel-loader"),options:e}]});export const ruleScripts=(e,r,s)=>{const{projectCwd:t}=s,{babelOptions:o={},modularImports:l=[]}=s.loaderOptions,a=mergeBabelOption(e,l,o,t);return shouldEnableReactFastRefresh(e,r,s)&&(a.plugins?a.plugins.push(requireResolve(import.meta.url,"react-refresh/babel")):a.plugins=[requireResolve(import.meta.url,"react-refresh/babel")]),ruleBabel(a)};
@@ -1 +0,0 @@
1
- import{getDirname}from"@armit/file-utility";import{isIconSvg}from"./rule-utils.js";export const ruleSvgIcon=()=>({test:e=>isIconSvg(e),use:[{loader:getDirname(import.meta.url,"../../loaders/loader-icon.cjs"),options:{svgo:{plugins:[{name:"removeTitle"},{name:"removeDimensions"}]}}}]});
@@ -1,7 +0,0 @@
1
- /**
2
- * Causeof we expose a component <Icon /> from `@wove/react` it can be optimized via icon-loader.
3
- * limitation assets match `svg-icons/**\/*.svg` to icon loader resolver.
4
- * @param resource
5
- * @returns
6
- */
7
- export declare const isIconSvg: (resource: string) => boolean;
@@ -1 +0,0 @@
1
- import{ICON_PATH_REGEX}from"./constants.js";export const isIconSvg=s=>ICON_PATH_REGEX.test(s)&&s.endsWith(".svg");
@@ -1,2 +0,0 @@
1
- import { type Compiler, type WebpackPluginInstance } from 'webpack';
2
- export type WebpackPlugin = ((this: Compiler, compiler: Compiler) => void) | WebpackPluginInstance;
@@ -1 +0,0 @@
1
- import{join}from"node:path";import WebpackDevServer from"webpack-dev-server";export const addCompilerToDevServer=(e,r,t,o,s)=>{const{projectCwd:d,devServer:l}=s,a=new WebpackDevServer({server:{type:l?.https?"https":"http",options:{...l?.https}},open:!1,compress:!0,port:t,hot:r,liveReload:!r,allowedHosts:"all",static:{directory:`${join(d,"/public")}`},headers:{"Access-Control-Allow-Origin":"*"},setupMiddlewares:e=>(l?.devBeforeMiddlewares&&e.unshift(...l.devBeforeMiddlewares),l?.devAfterMiddlewares&&e.push(...l.devAfterMiddlewares),e),client:{progress:!0,overlay:l?.clientOverlay,webSocketURL:"localIp"===l?.webSocketURL?{hostname:o||void 0}:{hostname:"0.0.0.0",...l?.webSocketURL}}},e);return new Promise(((e,r)=>{a.startCallback((t=>{if(t)return r(t);e(!0)}))}))};
@@ -1,3 +0,0 @@
1
- import { type FlatEvolveOptions } from '../types/types-options.js';
2
- import { type EvolveDevServerEntryMap } from './middlewares/types.js';
3
- export declare const createDevServerCompilerTask: (publicIp: string, servedDevServerEntries: EvolveDevServerEntryMap, servedDevServerEntryList: Array<EvolveDevServerEntryMap>, evolveOptions: FlatEvolveOptions) => Promise<boolean>;
@@ -1 +0,0 @@
1
- import{relative}from"node:path";import webpack from"webpack";import{chalk,logger,mergeOptions,urlJoin}from"@flatjs/common";import{loadWebpackConfig}from"../create-webpack/load-webpack-config.js";import{assertSingleCompiler}from"../helpers/assert-single-compiler.js";import{flatEntryMap}from"../helpers/flat-entry-map.js";import{shouldEnableReactFastRefresh}from"../helpers/should-enable-react-fast-refresh.js";import{addCompilerToDevServer}from"./add-compiler-to-dev-server.js";export const createDevServerCompilerTask=async(e,r,o,t)=>{const{projectCwd:a}=t,[n,i]=Object.entries(r)[0],{devServerPort:s,devServerHostUri:l}=i;for(const[,e]of Object.entries(r)){const r=e.entryConfig,t=r.options?.moduleFederation,a=t?.remotes||[],n=flatEntryMap(o);a.forEach((e=>{e.endpoint=e=>{const r=n[e];if(!r)throw new Error(`No servedDevServerEntry found via "${e}"`);return urlJoin(r?.devServerHostUri,["/public"])}}))}const p=Object.keys(r).reduce(((e,o)=>(e[o]=r[o].entryConfig,e)),{}),c=urlJoin(l,["public"]),m=await loadWebpackConfig("development",p,mergeOptions(t,{webpack:{publicPath:c}})),f=shouldEnableReactFastRefresh(!0,[n,i.entryConfig],t),d=assertSingleCompiler(p,m,t,f),v=webpack(d),h=addCompilerToDevServer(v,f,s,e,t),b=v.name||"";return v.hooks.invalid.tap("fileChange",(e=>{const r=relative(a,e||"");logger.info(`file change ➩ ${chalk(["cyan"])(r||"")}`,b)})),h};
@@ -1,24 +0,0 @@
1
- import { type EvolveEntryMapContent } from '../../types/types-entry-map.js';
2
- export type EvolveDevServerEntryMap = {
3
- /**
4
- * entryName: `home`
5
- */
6
- [entryName: string]: {
7
- /**
8
- * entryMapItem config options.
9
- */
10
- entryConfig: EvolveEntryMapContent;
11
- /**
12
- * dev server port number
13
- */
14
- devServerPort: number;
15
- /**
16
- * dev server host uri.
17
- */
18
- devServerHostUri: string;
19
- /**
20
- * entryName: `home` should be normallized to ${`projectVirtualPath`}/home
21
- */
22
- normalizedEntryName: string;
23
- };
24
- };