@flatjs/evolve 2.1.0-next.28 → 2.1.0-next.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. package/dist/constants.d.ts +0 -9
  2. package/dist/constants.js +1 -1
  3. package/dist/create-webpack/create-externals.d.ts +1 -1
  4. package/dist/create-webpack/create-externals.js +1 -1
  5. package/dist/create-webpack/create-optimization.d.ts +1 -1
  6. package/dist/create-webpack/create-optimization.js +1 -1
  7. package/dist/create-webpack/create-output.d.ts +1 -1
  8. package/dist/create-webpack/create-performance.d.ts +1 -1
  9. package/dist/create-webpack/create-plugins.d.ts +1 -2
  10. package/dist/create-webpack/create-plugins.js +1 -1
  11. package/dist/create-webpack/create-resolve.js +1 -1
  12. package/dist/create-webpack/create-rule-sets.d.ts +1 -1
  13. package/dist/create-webpack/create-rule-sets.js +1 -1
  14. package/dist/create-webpack/load-webpack-config.d.ts +1 -2
  15. package/dist/create-webpack/load-webpack-config.js +1 -1
  16. package/dist/create-webpack/rule-sets/rule-assets.d.ts +2 -2
  17. package/dist/create-webpack/rule-sets/rule-assets.js +1 -1
  18. package/dist/create-webpack/rule-sets/rule-css.js +1 -1
  19. package/dist/create-webpack/rule-sets/rule-scripts.d.ts +0 -2
  20. package/dist/create-webpack/rule-sets/rule-scripts.js +1 -1
  21. package/dist/create-webpack/types.d.ts +1 -1
  22. package/dist/default-options.js +1 -1
  23. package/dist/define-config/define-config.d.ts +2 -2
  24. package/dist/dev-server/add-compiler-to-dev-server.js +1 -1
  25. package/dist/dev-server/create-dev-server-compiler-tasks.d.ts +3 -0
  26. package/dist/dev-server/create-dev-server-compiler-tasks.js +1 -0
  27. package/dist/dev-server/create-dev-server-entries.d.ts +1 -1
  28. package/dist/dev-server/create-dev-server-entries.js +1 -1
  29. package/dist/dev-server/create-dev-server.js +1 -1
  30. package/dist/dev-server/index.d.ts +3 -3
  31. package/dist/dev-server/index.js +1 -1
  32. package/dist/dev-server/middlewares/get-bundle-asset.d.ts +1 -1
  33. package/dist/dev-server/middlewares/get-page-main-html.js +1 -1
  34. package/dist/dev-server/middlewares/get-page-module-html.js +1 -1
  35. package/dist/helpers/assert-only-single-entry-item.d.ts +7 -0
  36. package/dist/helpers/assert-only-single-entry-item.js +1 -0
  37. package/dist/helpers/get-bundle-file-name.d.ts +1 -1
  38. package/dist/helpers/index.d.ts +4 -18
  39. package/dist/helpers/index.js +1 -1
  40. package/dist/helpers/json-serializer.js +1 -1
  41. package/dist/helpers/normalize-entry-map.d.ts +0 -1
  42. package/dist/helpers/normalize-entry-map.js +1 -1
  43. package/dist/helpers/open-page.js +1 -1
  44. package/dist/helpers/refresh-evolve-mock-options.js +1 -1
  45. package/dist/helpers/script-injects.d.ts +1 -1
  46. package/dist/helpers/should-enable-react-fast-refresh.js +1 -1
  47. package/dist/helpers/split-to-multi-compiler.d.ts +8 -0
  48. package/dist/helpers/split-to-multi-compiler.js +1 -0
  49. package/dist/index.d.ts +1 -1
  50. package/dist/index.js +1 -1
  51. package/dist/load-config/load-evolve-config.js +1 -1
  52. package/dist/loaders/loader-icon.cjs +1 -2
  53. package/dist/main/create-thread-worker.d.ts +14 -29
  54. package/dist/main/create-thread-worker.js +1 -1
  55. package/dist/main/index.d.ts +1 -1
  56. package/dist/main/index.js +1 -1
  57. package/dist/main/prepare-build.d.ts +3 -4
  58. package/dist/main/prepare-build.js +1 -1
  59. package/dist/main/prepare-serve.d.ts +1 -1
  60. package/dist/main/prepare-serve.js +1 -1
  61. package/dist/main/start-build-dynamic.d.ts +2 -2
  62. package/dist/main/start-build-dynamic.js +1 -1
  63. package/dist/main/start-build-worker.d.ts +6 -17
  64. package/dist/main/start-build-worker.js +1 -1
  65. package/dist/main/start-build.d.ts +2 -3
  66. package/dist/main/start-build.js +1 -1
  67. package/dist/main/start-one-entry-build.d.ts +13 -0
  68. package/dist/main/start-one-entry-build.js +1 -0
  69. package/dist/main/start-serve.d.ts +1 -1
  70. package/dist/main/start-serve.js +1 -1
  71. package/dist/minimizer/create-minimizers.js +1 -1
  72. package/dist/minimizer/image-minimizer.js +1 -1
  73. package/dist/minimizer/terser-minimizer.js +1 -1
  74. package/dist/plugins/circular-dependency/circular-dependency-plugin.js +1 -1
  75. package/dist/plugins/clean-webpack/index.d.ts +1 -1
  76. package/dist/plugins/clean-webpack/index.js +1 -1
  77. package/dist/plugins/define-variable/define-variable-plugin.js +1 -1
  78. package/dist/plugins/module-federation/module-federation.d.ts +1 -1
  79. package/dist/plugins/module-federation/module-federation.js +1 -1
  80. package/dist/plugins/multi-html/index.d.ts +1 -1
  81. package/dist/plugins/multi-html/index.js +1 -1
  82. package/dist/plugins/multi-html/multi-html-cdn-plugin.js +1 -1
  83. package/dist/plugins/multi-html/multi-html-plugin.d.ts +1 -1
  84. package/dist/plugins/multi-html/multi-html-plugin.js +1 -1
  85. package/dist/types/index.d.ts +1 -3
  86. package/dist/types/index.js +1 -1
  87. package/dist/types/types-dev-server.d.ts +6 -17
  88. package/dist/types/types-entry-map.d.ts +3 -21
  89. package/dist/types/types-loader-options.d.ts +9 -31
  90. package/dist/types/types-options.d.ts +15 -30
  91. package/dist/types/types-webpack.d.ts +2 -5
  92. package/package.json +61 -69
  93. package/templates/html-plugin/index-dev.html +2 -2
  94. package/templates/html-plugin/index-inte.html +2 -2
  95. package/templates/html-plugin/index-inte2.html +2 -2
  96. package/templates/html-plugin/index-inte3.html +2 -2
  97. package/templates/html-plugin/index-inte4.html +2 -2
  98. package/templates/html-plugin/index-me.html +2 -2
  99. package/templates/html-plugin/index-prod.html +2 -2
  100. package/templates/html-plugin/index-rc.html +2 -2
  101. package/templates/html-plugin/index-uat.html +2 -2
  102. package/templates/module.html +2 -2
  103. package/dist/compiler/create-global-compiler.d.ts +0 -2
  104. package/dist/compiler/create-global-compiler.js +0 -1
  105. package/dist/create-webpack/load-watch-options.d.ts +0 -12
  106. package/dist/create-webpack/load-watch-options.js +0 -1
  107. package/dist/dev-server/create-dev-server-compiler-task.d.ts +0 -3
  108. package/dist/dev-server/create-dev-server-compiler-task.js +0 -1
  109. package/dist/helpers/assert-group-entry-item.d.ts +0 -7
  110. package/dist/helpers/assert-group-entry-item.js +0 -1
  111. package/dist/helpers/assert-single-compiler.d.ts +0 -15
  112. package/dist/helpers/assert-single-compiler.js +0 -1
  113. package/dist/helpers/check-runtime-env.d.ts +0 -4
  114. package/dist/helpers/check-runtime-env.js +0 -1
  115. package/dist/helpers/custom-listr-renderer.d.ts +0 -41
  116. package/dist/helpers/custom-listr-renderer.js +0 -1
  117. package/dist/helpers/custom-message-channel.d.ts +0 -17
  118. package/dist/helpers/custom-message-channel.js +0 -1
  119. package/dist/helpers/delete-object-keys.d.ts +0 -11
  120. package/dist/helpers/delete-object-keys.js +0 -1
  121. package/dist/helpers/flat-entry-map.d.ts +0 -8
  122. package/dist/helpers/flat-entry-map.js +0 -1
  123. package/dist/helpers/format-spinner-text.d.ts +0 -8
  124. package/dist/helpers/format-spinner-text.js +0 -1
  125. package/dist/helpers/get-runtime-cdn-base.d.ts +0 -2
  126. package/dist/helpers/get-runtime-cdn-base.js +0 -1
  127. package/dist/helpers/get-stats-file-name.d.ts +0 -2
  128. package/dist/helpers/get-stats-file-name.js +0 -1
  129. package/dist/helpers/is-deep-equal.d.ts +0 -9
  130. package/dist/helpers/is-deep-equal.js +0 -1
  131. package/dist/helpers/normalize-check-entry-options.d.ts +0 -10
  132. package/dist/helpers/normalize-check-entry-options.js +0 -1
  133. package/dist/helpers/normalize-entry-module-absolute-path.d.ts +0 -10
  134. package/dist/helpers/normalize-entry-module-absolute-path.js +0 -1
  135. package/dist/helpers/normalize-group-name.d.ts +0 -8
  136. package/dist/helpers/normalize-group-name.js +0 -1
  137. package/dist/helpers/normalize-template-inject-tokens.d.ts +0 -16
  138. package/dist/helpers/normalize-template-inject-tokens.js +0 -1
  139. package/dist/helpers/split-to-entry-group.d.ts +0 -52
  140. package/dist/helpers/split-to-entry-group.js +0 -1
  141. package/dist/helpers/verify-group-entry-options.d.ts +0 -9
  142. package/dist/helpers/verify-group-entry-options.js +0 -1
  143. package/dist/main/prepare-analyzer.d.ts +0 -9
  144. package/dist/main/prepare-analyzer.js +0 -1
  145. package/dist/main/start-analyzer.d.ts +0 -10
  146. package/dist/main/start-analyzer.js +0 -1
  147. package/dist/main/start-group-entry-build.d.ts +0 -15
  148. package/dist/main/start-group-entry-build.js +0 -1
  149. package/dist/plugins/stats-webpack/helper-write-stats.d.ts +0 -28
  150. package/dist/plugins/stats-webpack/helper-write-stats.js +0 -1
  151. package/dist/plugins/stats-webpack/index.d.ts +0 -12
  152. package/dist/plugins/stats-webpack/index.js +0 -1
  153. package/dist/plugins/stats-webpack/stats-webpack-plugin.d.ts +0 -25
  154. package/dist/plugins/stats-webpack/stats-webpack-plugin.js +0 -1
  155. package/dist/plugins/ts-checker/ts-checker-guard-plugin.d.ts +0 -13
  156. package/dist/plugins/ts-checker/ts-checker-guard-plugin.js +0 -1
  157. package/dist/plugins/ts-checker/ts-checker-plugin.d.ts +0 -3
  158. package/dist/plugins/ts-checker/ts-checker-plugin.js +0 -1
  159. package/dist/types/types-analyzer.d.ts +0 -70
  160. package/dist/types/types-analyzer.js +0 -1
  161. package/dist/types/types-cli-options.d.ts +0 -12
  162. package/dist/types/types-cli-options.js +0 -1
  163. package/dist/types/types-global-compiler-options.d.ts +0 -7
  164. package/dist/types/types-global-compiler-options.js +0 -1
  165. package/dist/types/types-threads-options.d.ts +0 -18
  166. package/dist/types/types-threads-options.js +0 -1
  167. package/templates/html-plugin/index-ntv.html +0 -61
@@ -1,4 +1,3 @@
1
- import { type EvolveEntryItemOption } from './types/types-entry-map.js';
2
1
  export declare const moduleName = "@flatjs/evolve";
3
2
  /**
4
3
  * the configuration file of `flat-evolve`
@@ -23,11 +22,3 @@ export declare const devReactFastRefresh: {
23
22
  runtime: string;
24
23
  reactRefreshSetup: string;
25
24
  };
26
- /**
27
- * Array of keys to ignore in the verifyGroupEntryOptions step
28
- */
29
- export declare const ignoreEntryOptionKeys: Array<keyof EvolveEntryItemOption>;
30
- /**
31
- * The directory where the webpack stats files are stored. relative to projectCwd
32
- */
33
- export declare const webpackStatsDir = ".cache/stats";
package/dist/constants.js CHANGED
@@ -1 +1 @@
1
- export const moduleName="@flatjs/evolve";export const configFileName="flatjs-evolve";export const viewportScripts='(function(d){var j;var b=1;var i=1;var h=750;var c=100;function e(s,o){var q=d.document;var l=q.documentElement;var k=navigator.userAgent;var m=k.toLowerCase().indexOf("android")>-1;i=d.devicePixelRatio||1;if(i>3){i=3}if(m){i=1}console.log("current devicePixelRatio:",i);l.setAttribute("data-dpr",i.toString());var p=q.querySelector(\'meta[name="viewport"]\');if(!p){b=1/i;p=q.createElement("meta");p.setAttribute("name","viewport");q.head.appendChild(p);p.setAttribute(["content","width=device-width,user-scalable=no,initial-scale=",b,",maximum-scale=",b,",minimum-scale=",b].join(""))}function n(){var t=document.documentElement.clientWidth;j=t/o*(s/i)*i;q.documentElement.style.fontSize=String(j)+"px"}var r;d.addEventListener("resize",function(){clearTimeout(r);r=setTimeout(n,300)},false);d.addEventListener("onload",n,false);n()}e(c,h);window.fabricViewport={currRem:j,currDpr:i,currScale:b,dpiPX2px:function f(k){return parseFloat(k.toString())/j*100+"px"},px2DPIpx:function a(k){return parseFloat(k.toString())/100*j+"px"},px2rem:function g(k){return parseFloat(k.toString())/100+"rem"}}})(window);';export const polyfill=["https://polyfill.io/v3/polyfill.min.js?features=Array.from%2CArray.isArray%2CArray.of%2CArray.prototype.entries%2CArray.prototype.every%2CArray.prototype.fill%2CArray.prototype.filter%2CArray.prototype.find%2CArray.prototype.findIndex%2CArray.prototype.flat%2CArray.prototype.forEach%2CArray.prototype.flatMap%2CArray.prototype.keys%2CArray.prototype.indexOf%2CArray.prototype.includes%2CArray.prototype.lastIndexOf%2CArray.prototype.map%2CArray.prototype.reduce%2CArray.prototype.reduceRight%2CArray.prototype.some%2CArray.prototype.sort%2CArray.prototype.values%2CArrayBuffer%2CBlob%2CDataView%2CDate.now%2CObject.assign%2CObject.create%2CObject.defineProperties%2CObject.defineProperty%2CObject.entries%2CObject.freeze%2CObject.fromEntries%2CObject.getOwnPropertySymbols%2CObject.getOwnPropertyNames%2CObject.getOwnPropertyDescriptors%2CObject.getOwnPropertyDescriptor%2CObject.getPrototypeOf%2CObject.is%2CObject.isExtensible%2CObject.isFrozen%2CObject.isSealed%2CObject.keys%2CObject.values%2CObject.setPrototypeOf%2CPromise%2CPromise.prototype.finally%2CReflect%2CReflect.apply%2CReflect.construct%2CReflect.defineProperty%2CReflect.deleteProperty%2CReflect.getPrototypeOf%2CReflect.getOwnPropertyDescriptor%2CReflect.get%2CReflect.ownKeys%2CReflect.isExtensible%2CReflect.has%2CReflect.preventExtensions%2CReflect.set%2CReflect.setPrototypeOf%2CSet%2CString.prototype.trimStart%2CString.prototype.trimEnd%2CString.prototype.trim%2CString.prototype.startsWith%2CString.prototype.repeat%2CString.prototype.replaceAll%2CString.prototype.padStart%2CString.prototype.padEnd%2CMap%2CObject.seal%2Cconsole.groupEnd%2Cconsole.group"];export const devReactFastRefresh={runtime:"reactRefreshRuntime",reactRefreshSetup:"reactRefreshSetup"};export const ignoreEntryOptionKeys=["title"];export const webpackStatsDir=".cache/stats";
1
+ export const moduleName="@flatjs/evolve";export const configFileName="flatjs-evolve";export const viewportScripts='(function(d){var j;var b=1;var i=1;var h=750;var c=100;function e(s,o){var q=d.document;var l=q.documentElement;var k=navigator.userAgent;var m=k.toLowerCase().indexOf("android")>-1;i=d.devicePixelRatio||1;if(i>3){i=3}if(m){i=1}console.log("current devicePixelRatio:",i);l.setAttribute("data-dpr",i.toString());var p=q.querySelector(\'meta[name="viewport"]\');if(!p){b=1/i;p=q.createElement("meta");p.setAttribute("name","viewport");q.head.appendChild(p);p.setAttribute(["content","width=device-width,user-scalable=no,initial-scale=",b,",maximum-scale=",b,",minimum-scale=",b].join(""))}function n(){var t=document.documentElement.clientWidth;j=t/o*(s/i)*i;q.documentElement.style.fontSize=String(j)+"px"}var r;d.addEventListener("resize",function(){clearTimeout(r);r=setTimeout(n,300)},false);d.addEventListener("onload",n,false);n()}e(c,h);window.fabricViewport={currRem:j,currDpr:i,currScale:b,dpiPX2px:function f(k){return parseFloat(k.toString())/j*100+"px"},px2DPIpx:function a(k){return parseFloat(k.toString())/100*j+"px"},px2rem:function g(k){return parseFloat(k.toString())/100+"rem"}}})(window);';export const polyfill=["https://polyfill.io/v3/polyfill.min.js?features=Array.from%2CArray.isArray%2CArray.of%2CArray.prototype.entries%2CArray.prototype.every%2CArray.prototype.fill%2CArray.prototype.filter%2CArray.prototype.find%2CArray.prototype.findIndex%2CArray.prototype.flat%2CArray.prototype.forEach%2CArray.prototype.flatMap%2CArray.prototype.keys%2CArray.prototype.indexOf%2CArray.prototype.includes%2CArray.prototype.lastIndexOf%2CArray.prototype.map%2CArray.prototype.reduce%2CArray.prototype.reduceRight%2CArray.prototype.some%2CArray.prototype.sort%2CArray.prototype.values%2CArrayBuffer%2CBlob%2CDataView%2CDate.now%2CObject.assign%2CObject.create%2CObject.defineProperties%2CObject.defineProperty%2CObject.entries%2CObject.freeze%2CObject.fromEntries%2CObject.getOwnPropertySymbols%2CObject.getOwnPropertyNames%2CObject.getOwnPropertyDescriptors%2CObject.getOwnPropertyDescriptor%2CObject.getPrototypeOf%2CObject.is%2CObject.isExtensible%2CObject.isFrozen%2CObject.isSealed%2CObject.keys%2CObject.values%2CObject.setPrototypeOf%2CPromise%2CPromise.prototype.finally%2CReflect%2CReflect.apply%2CReflect.construct%2CReflect.defineProperty%2CReflect.deleteProperty%2CReflect.getPrototypeOf%2CReflect.getOwnPropertyDescriptor%2CReflect.get%2CReflect.ownKeys%2CReflect.isExtensible%2CReflect.has%2CReflect.preventExtensions%2CReflect.set%2CReflect.setPrototypeOf%2CSet%2CString.prototype.trimStart%2CString.prototype.trimEnd%2CString.prototype.trim%2CString.prototype.startsWith%2CString.prototype.repeat%2CString.prototype.replaceAll%2CString.prototype.padStart%2CString.prototype.padEnd%2CMap%2CObject.seal%2Cconsole.groupEnd%2Cconsole.group"];export const devReactFastRefresh={runtime:"reactRefreshRuntime",reactRefreshSetup:"reactRefreshSetup"};
@@ -1,4 +1,4 @@
1
1
  import { type Configuration } from 'webpack';
2
2
  import { type EntryMapItem } from '../types/types-entry-map.js';
3
3
  import { type FlatEvolveWebpackOptions } from '../types/types-webpack.js';
4
- export declare const createExternals: (externals?: FlatEvolveWebpackOptions["externals"], entryItem?: EntryMapItem) => Configuration["externals"];
4
+ export declare const createExternals: (externals: FlatEvolveWebpackOptions['externals'], entryItem: EntryMapItem) => Configuration['externals'];
@@ -1 +1 @@
1
- import{mergeOptions}from"@flatjs/common";export const createExternals=(t={},e)=>{const o=e?.[1];return mergeOptions(t,o?.options?.externals||{})};
1
+ import{mergeOptions}from"@flatjs/common";export const createExternals=(t={},e)=>{const o=e[1],r=o.options?.externals||{};return mergeOptions(t,r)};
@@ -1,4 +1,4 @@
1
1
  import { type Configuration } from 'webpack';
2
2
  import { type EntryMapItem } from '../types/types-entry-map.js';
3
3
  import { type FlatEvolveOptions } from '../types/types-options.js';
4
- export declare const createOptimization: (serveMode: boolean, evolveOptions: FlatEvolveOptions, entryMapItem: EntryMapItem) => Configuration["optimization"];
4
+ export declare const createOptimization: (serveMode: boolean, evolveOptions: FlatEvolveOptions, entryItem: EntryMapItem) => Configuration['optimization'];
@@ -1 +1 @@
1
- import{join}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=>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
+ import{join}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:()=>join(n[0],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,4 +1,4 @@
1
1
  import { type Configuration } from 'webpack';
2
2
  import { type EntryMapItem } from '../types/types-entry-map.js';
3
3
  import { type FlatEvolveOptions } from '../types/types-options.js';
4
- export declare const createOutput: (serveMode: boolean, evolveOptions: FlatEvolveOptions, entryItem: EntryMapItem) => Promise<Configuration["output"]>;
4
+ export declare const createOutput: (serveMode: boolean, evolveOptions: FlatEvolveOptions, entryItem: EntryMapItem) => Promise<Configuration['output']>;
@@ -1,2 +1,2 @@
1
1
  import { type FlatEvolveWebpackOptions } from '../types/types-webpack.js';
2
- export declare const createPerformance: (serveMode: boolean, performanceOptions?: FlatEvolveWebpackOptions["performance"]) => FlatEvolveWebpackOptions["performance"];
2
+ export declare const createPerformance: (serveMode: boolean, performanceOptions?: FlatEvolveWebpackOptions['performance']) => FlatEvolveWebpackOptions['performance'];
@@ -1,5 +1,4 @@
1
- import { FlatCliOptions } from '../types/types-cli-options.js';
2
1
  import { type EntryMapItem } from '../types/types-entry-map.js';
3
2
  import { type FlatEvolveOptions } from '../types/types-options.js';
4
3
  import { type FlatEvolveWebpackOptions } from '../types/types-webpack.js';
5
- export declare const createPlugins: (serveMode: boolean, entryMapItemList: EntryMapItem[], evolveOptions: FlatEvolveOptions, cliOptions?: FlatCliOptions) => Promise<FlatEvolveWebpackOptions["plugins"]>;
4
+ export declare const createPlugins: (serveMode: boolean, entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => Promise<FlatEvolveWebpackOptions['plugins']>;
@@ -1 +1 @@
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,n,i)=>{const r=a[0],[l,t]=r,s=enableBundleHashNameForModule(n,t?.options),o=[new webpack.WatchIgnorePlugin({paths:[/\.d\.[cm]ts$/]}),new CaseSensitivePathsPlugin,...createCircularDependencyPlugin(e,n),new MiniCssExtractPlugin({filename:`[name]/${getBundleFileName("css",e,s)}`,chunkFilename:"[id].[contenthash].css"}),...await createBuiltinDefineVariables(e,n),...createCleanWebpackPlugin(e,a,n),...createModuleFederationPlugin(e,a,n),...createHtmlPlugins(e,a,n),...createStatsWebpackPlugin(e,n,i)],c=shouldEnableReactFastRefresh(e,r,n);c&&o.push(new ReactRefreshWebpackPlugin({overlay:!1})),!c&&e&&(n.devServer?.liveReload?logger.warn('The HMR disabled cause of "liveReload" specificed'):logger.warn(`The HMR disabled cause of \`"moduleFederation":"${l}"\``));const u=n.webpack?.plugins||[];return o.concat(u)};
1
+ import{logger}from"@flatjs/common";import ReactRefreshWebpackPlugin from"@pmmmwh/react-refresh-webpack-plugin";import CaseSensitivePathsPlugin from"case-sensitive-paths-webpack-plugin";import ForkTsCheckerWebpackPlugin from"fork-ts-checker-webpack-plugin";import MiniCssExtractPlugin from"mini-css-extract-plugin";import webpack from"webpack";import{BundleAnalyzerPlugin}from"webpack-bundle-analyzer";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";export const createPlugins=async(e,n,a)=>{const[r,i]=n,l=enableBundleHashNameForModule(a,i?.options),t=[new webpack.WatchIgnorePlugin({paths:[/\.d\.[cm]ts$/]}),new CaseSensitivePathsPlugin,...createCircularDependencyPlugin(e,a),new MiniCssExtractPlugin({filename:`[name]/${getBundleFileName("css",e,l)}`,chunkFilename:"[id].[contenthash].css"}),...await createBuiltinDefineVariables(e,a),...createCleanWebpackPlugin(e,n,a),...createModuleFederationPlugin(e,n,a),...createHtmlPlugins(e,n,a)],{analyzer:s,loaderOptions:o}=a,c=(n[1].entry||[]).find((e=>/.vue$/.test(e)));o.runTsChecker&&!c&&t.push(new ForkTsCheckerWebpackPlugin({async:e,typescript:{context:a.projectCwd,memoryLimit:8192}})),s&&t.push(new BundleAnalyzerPlugin({analyzerPort:"auto",analyzerMode:"server",...s}));const u=shouldEnableReactFastRefresh(e,n,a);u&&t.push(new ReactRefreshWebpackPlugin({overlay:!1})),!u&&e&&(a.devServer?.liveReload?logger.warn('The HMR disabled cause of "liveReload" specificed'):logger.warn(`The HMR disabled cause of \`"moduleFederation":"${r}"\``));const p=a.webpack?.plugins||[];return t.concat(p)};
@@ -1 +1 @@
1
- import{join}from"node:path";import{TsconfigPathsPlugin}from"tsconfig-paths-webpack-plugin";import{mergeOptions}from"@flatjs/common";export const createResolve=(s,o)=>{const t={mainFields:["browser","module","main"],extensions:[".ts",".tsx",".js",".jsx",".mjs",".cjs",".mts",".cts",".json"],extensionAlias:{".js":[".js",".ts"],".cjs":[".cjs",".cts"],".mjs":[".mjs",".mts"],".jsx":[".jsx",".tsx"]},plugins:[new TsconfigPathsPlugin({configFile:join(s,"tsconfig.json"),extensions:[".ts",".tsx",".js",".jsx",".mjs"]})]};return mergeOptions(t,o?.resolve||{})};
1
+ import{join}from"node:path";import{mergeOptions}from"@flatjs/common";import{TsconfigPathsPlugin}from"tsconfig-paths-webpack-plugin";export const createResolve=(s,o)=>{const n={mainFields:["browser","module","main"],extensions:[".ts",".tsx",".js",".json"],extensionAlias:{".js":[".js",".ts"],".cjs":[".cjs",".cts"],".mjs":[".mjs",".mts"],".jsx":[".jsx",".tsx"]},plugins:[new TsconfigPathsPlugin({configFile:join(s,"tsconfig.json"),extensions:[".ts",".tsx",".js",".jsx"]})]};return mergeOptions(n,o?.resolve||{})};
@@ -1,4 +1,4 @@
1
1
  import { type RuleSetRule } from 'webpack';
2
2
  import { type EntryMapItem } from '../types/types-entry-map.js';
3
3
  import { type FlatEvolveOptions } from '../types/types-options.js';
4
- export declare const createRuleSets: (serveMode: boolean, entryMapItemList: EntryMapItem[], evolveOptions: FlatEvolveOptions) => RuleSetRule[];
4
+ export declare const createRuleSets: (serveMode: boolean, entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => RuleSetRule[];
@@ -1 +1 @@
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
+ 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=[ruleSvgIcon(),ruleAssets(e,r),ruleCss(s,e,r,!1),ruleCss(s,e,r,!0),ruleLess(s,e,r),ruleScripts(s,e,r)],t=r.webpack?.ruleSets||[];return l.concat(t)};
@@ -1,5 +1,4 @@
1
1
  import { type Configuration } from 'webpack';
2
- import { FlatCliOptions } from '../types/types-cli-options.js';
3
2
  import { type EvolveEntryMap } from '../types/types-entry-map.js';
4
3
  import { type FlatEvolveOptions } from '../types/types-options.js';
5
4
  /**
@@ -8,4 +7,4 @@ import { type FlatEvolveOptions } from '../types/types-options.js';
8
7
  * @param entryMap The only single one `servedEntry` or `toBuildEntry`
9
8
  * @param overrideOptions The manually override configuration options for flatjsEvolve
10
9
  */
11
- export declare const loadWebpackConfig: (mode: "production" | "development", entryMap: EvolveEntryMap, evolveOptions: FlatEvolveOptions, cliOptions?: FlatCliOptions) => Promise<Omit<Configuration, "entry">>;
10
+ export declare const loadWebpackConfig: (mode: 'production' | 'development', entryMap: EvolveEntryMap, evolveOptions: FlatEvolveOptions) => Promise<Omit<Configuration, 'entry'>>;
@@ -1 +1 @@
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
+ import{assertOnlySingleEntryItem}from"../helpers/assert-only-single-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";export const loadWebpackConfig=async(e,t,r)=>{const a="development"===e,{projectCwd:o,webpack:s,devServer:n}=r,c=n?.watchOptions,i=assertOnlySingleEntryItem(t,r),m=createRuleSets(a,i,r);return{mode:e,plugins:await createPlugins(a,i,r),watchOptions:c,output:await createOutput(a,r,i),context:o,target:s?.target??["web","es5"],resolve:createResolve(o,s),module:{rules:m},devtool:a?"eval-source-map":s?.sourceMap||!1,externalsType:s?.externalsType,externals:createExternals(s?.externals,i),performance:createPerformance(a,s?.performance),optimization:createOptimization(a,r,i),infrastructureLogging:s?.infrastructureLogging??{level:"warn"},stats:s?.stats??{preset:"minimal"},cache:{type:"memory"}}};
@@ -5,6 +5,6 @@ import { type FlatEvolveOptions } from '../../types/types-options.js';
5
5
  * Preparing image loader for normal pictures except stored in folder `icons`
6
6
  * Webpack@5 don't need `file-loader`, `raw-loader`, `url-loader` provider us `asset-modules`
7
7
  * https://webpack.js.org/guides/asset-modules/
8
- * @param entryMapItemList The available entries, `development` it contains multiple enties, `production`
8
+ * @param entryItem The available entries, `development` it contains multiple enties, `production` only one entry in once build.
9
9
  */
10
- export declare const ruleAssets: (entryMapItemList: EntryMapItem[], evolveOptions: FlatEvolveOptions) => RuleSetRule;
10
+ export declare const ruleAssets: (entryItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => RuleSetRule;
@@ -1 +1 @@
1
- import{dirname,join,relative,resolve}from"node:path";import{ensureSlash}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:s}=r;let n=dirname(join(s,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:s}=t,a=dirname(join(o,s)),i=resolve(o,e);if(i.startsWith(ensureSlash(a,!0))){n=dirname(join(r,relative(a,i)));break}}return`${n}/[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
+ import{dirname,join,relative,resolve}from"node:path";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[s,o]=t,{projectCwd:a,projectVirtualPath:i}=r;let n=dirname(join(i,e.replace(/^src/,"")));const l=o.entry.map((e=>dirname(join(a,e)))),m=resolve(a,e),c=l.find((e=>m.startsWith(e)));return c&&(n=dirname(join(s,relative(c,m)))),`${n}/[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 +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 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
+ import{requireResolve}from"@flatjs/common";import{forgePostcssPluginPixel}from"@flatjs/forge-postcss-plugin-pixel";import cssnano from"cssnano";import MiniCssExtractPlugin from"mini-css-extract-plugin";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,n=r?{}:{modules:!1},p={test:/\.css$/i,use:[{loader:MiniCssExtractPlugin.loader,options:{esModule:!0}},{loader:requireResolve(import.meta.url,"css-loader"),options:{sourceMap:s,...i,...n}}]};r?p.include=/\.module\.css$/i:p.exclude=/\.module\.css$/i;const c=allowPx2remForModule(o,e);if(Array.isArray(p.use)){const o=getPostcssOptions(s,!!c&&t,l);p.use.push({loader:requireResolve(import.meta.url,"postcss-loader"),options:{postcssOptions:{...o,config:!1},sourceMap:s}})}return p};
@@ -1,5 +1,3 @@
1
1
  import { type RuleSetRule } from 'webpack';
2
- import { type TransformOptions } from '@babel/core';
3
2
  import { type EntryMapItem, type FlatEvolveOptions } from '../../types/index.js';
4
- export declare const ruleBabel: (options: TransformOptions) => RuleSetRule;
5
3
  export declare const ruleScripts: (serveMode: boolean, entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => RuleSetRule;
@@ -1 +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 ruleScripts=(e,r,s)=>{const{babelOptions:t={},modularImports:o=[]}=s.loaderOptions,l=mergeBabelOption(o,t);return shouldEnableReactFastRefresh(e,r,s)&&(l.plugins?l.plugins.push(requireResolve(import.meta.url,"react-refresh/babel")):l.plugins=[requireResolve(import.meta.url,"react-refresh/babel")]),ruleBabel(l)};
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 ruleScripts=(e,r,s)=>{const{babelOptions:o={},modularImports:t=[]}=s.loaderOptions,l=mergeBabelOption(t,o);shouldEnableReactFastRefresh(e,r,s)&&(l.plugins?l.plugins.push(requireResolve(import.meta.url,"react-refresh/babel")):l.plugins=[requireResolve(import.meta.url,"react-refresh/babel")]);return{test:/\.(tsx|ts|js|jsx)$/,use:[{loader:requireResolve(import.meta.url,"babel-loader"),options:l}]}};
@@ -1,2 +1,2 @@
1
- import { type Compiler, type WebpackPluginInstance } from 'webpack';
1
+ import { type WebpackPluginInstance, type Compiler } from 'webpack';
2
2
  export type WebpackPlugin = ((this: Compiler, compiler: Compiler) => void) | WebpackPluginInstance;
@@ -1 +1 @@
1
- export const defaultEvolveOptions={projectCwd:process.cwd(),projectVirtualPath:"flatjs/evolve",rejectWarnings:!1,devServer:{autoOpen:!0,pageProxy:"/pages",mockOptions:{mockBaseDir:"mocks"},clientOverlay:{errors:!0,warnings:!1},webSocketURL:"localIp",middlewares:[],watchOptions:{poll:1e3,ignored:["**/node_modules","**/mocks"],aggregateTimeout:500},defaultServeGlobalData:()=>Promise.resolve({}),bundleDirResolver:e=>e},webpack:{target:["web","es5"],plugins:[],ruleSets:[],publicPath:"auto",resolve:{},externals:{vue:"Vue",react:"React","react-dom":"ReactDOM"},outputDir:"public",enableBundleHashName:!0},pluginOptions:{},loaderOptions:{assetDataUrlMaxSize:4096,babelOptions:{usePreset:"react",plugins:[],presets:[]},lessOptions:{},postcssOptions:{cssnanoOptions:{}},pixelOptions:{rootValue:{px:100,rpx:1},outputUnit:"rem"},modularImports:[]},globalCompilerOptions:{runTsChecker:!0},entryMap:{},multiHtmlCdn:{},multiHtmlCdnEnvResolver:function cdnResolver(){},needVerifyPackages:{},packageInstallChecker:{enabled:!1,detectModules:["@dimjs/*"],throwError:!1,showAllInstalledGraph:!0},ci:{basedBranch:"origin/master"},isolation:!1,maxEntryGroupSize:10};
1
+ export const defaultEvolveOptions={projectCwd:process.cwd(),projectVirtualPath:"flatjs/evolve",rejectWarnings:!1,devServer:{autoOpen:!0,pageProxy:"/pages",mockOptions:{mockBaseDir:"mocks"},clientOverlay:{errors:!0,warnings:!1},webSocketURL:"localIp",middlewares:[],watchOptions:{poll:1e3,ignored:["**/node_modules","**/mocks"],aggregateTimeout:500},defaultServeGlobalData:()=>Promise.resolve({}),bundleDirResolver:e=>e},webpack:{target:["web","es5"],plugins:[],ruleSets:[],publicPath:"auto",resolve:{},externals:{vue:"Vue",react:"React","react-dom":"ReactDOM"},outputDir:"public",enableBundleHashName:!0},pluginOptions:{},loaderOptions:{assetDataUrlMaxSize:4096,babelOptions:{usePreset:"react",plugins:[],presets:[]},runTsChecker:!0,lessOptions:{},postcssOptions:{cssnanoOptions:{}},pixelOptions:{rootValue:{px:100,rpx:1},outputUnit:"rem"},modularImports:[]},entryMap:{},multiHtmlCdn:{},multiHtmlCdnEnvResolver:function cdnResolver(){},needVerifyPackages:{},packageInstallChecker:{enabled:!1,detectModules:["@dimjs/*"],throwError:!1,showAllInstalledGraph:!0},maxProcesses:5,ci:{basedBranch:"origin/master"}};
@@ -1,6 +1,6 @@
1
- import { type PartialDeep } from 'type-fest';
2
- import { type ConfigEnvBase, type UserConfigExport } from '@armit/config-loader';
1
+ import { type UserConfigExport, type ConfigEnvBase } from '@armit/config-loader';
3
2
  import { type requireResolve } from '@flatjs/common';
3
+ import { type PartialDeep } from 'type-fest';
4
4
  import { type FlatEvolveOptions } from '../types/types-options.js';
5
5
  export interface EvolveConfigBase extends ConfigEnvBase {
6
6
  /**
@@ -1 +1 @@
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
+ import{join}from"node:path";import WebpackDevServer from"webpack-dev-server";export const addCompilerToDevServer=(e,o,r,t,s)=>{const{projectCwd:p,devServer:c}=s,l=new WebpackDevServer({server:{type:c?.https?"https":"http",options:{...c?.https}},open:!1,compress:!0,port:r,hot:o,liveReload:!o,allowedHosts:"all",static:{directory:`${join(p,"/public")}`},headers:{"Access-Control-Allow-Origin":"*"},client:{progress:!0,overlay:c?.clientOverlay,webSocketURL:"localIp"===c?.webSocketURL?{hostname:t||void 0}:{hostname:"0.0.0.0",...c?.webSocketURL}}},e);return new Promise(((e,o)=>{l.startCallback((r=>{if(r)return o(r);e(!0)}))}))};
@@ -0,0 +1,3 @@
1
+ import { type FlatEvolveOptions } from '../types/types-options.js';
2
+ import { type EvolveDevServerEntryMap } from './middlewares/types.js';
3
+ export declare const createDevServerCompilerTasks: (projectCwd: string, mainPage: string, publicIp: string, servedDevServerEntries: EvolveDevServerEntryMap, evolveOptions: FlatEvolveOptions) => Promise<Promise<boolean>[]>;
@@ -0,0 +1 @@
1
+ import{relative}from"node:path";import{chalk,logger,mergeOptions,urlJoin}from"@flatjs/common";import webpack from"webpack";import{loadWebpackConfig}from"../create-webpack/load-webpack-config.js";import{shouldEnableReactFastRefresh}from"../helpers/should-enable-react-fast-refresh.js";import{splitToMultiCompilerConfigs}from"../helpers/split-to-multi-compiler.js";import{addCompilerToDevServer}from"./add-compiler-to-dev-server.js";export const createDevServerCompilerTasks=async(e,o,r,t,i)=>{const a=[];for(const[n,l]of Object.entries(t)){const s=l.entryConfig,p=s.options?.moduleFederation;(p?.remotes||[]).forEach((e=>{e.endpoint=e=>{const o=t[e];if(!o)throw new Error(`No servedDevServerEntry found via "${e}"`);return urlJoin(o?.devServerHostUri,["/public"])}}));const{devServerPort:c,devServerHostUri:m}=t[n],f={[n]:s},d=urlJoin(m,["public"]),v=await loadWebpackConfig("development",f,mergeOptions(i,{webpack:{publicPath:d}})),h=shouldEnableReactFastRefresh(!0,[n,s],i),g=webpack(splitToMultiCompilerConfigs(f,v,i,h)[0]);a.push(addCompilerToDevServer(g,h,c,r,i));const u=g.name||"";g.hooks.invalid.tap("fileChange",(o=>{const r=relative(e,o||"");logger.info(`file change ➩ ${chalk(["cyan"])(r)}`,u)})),g.hooks.done.tap("compileDone",(()=>{logger.info(`debug page ➩ ${chalk(["cyan"])(o)}`,u)}))}return a};
@@ -1,4 +1,4 @@
1
1
  import { type EvolveEntryMap } from '../types/types-entry-map.js';
2
2
  import { type FlatEvolveOptions } from '../types/types-options.js';
3
3
  import { type EvolveDevServerEntryMap } from './middlewares/types.js';
4
- export declare const createDevServerEntries: (lastPort: number, servedEntries: EvolveEntryMap, evolveOptions: FlatEvolveOptions) => Promise<EvolveDevServerEntryMap>;
4
+ export declare const createDevServerEntries: (startPort: number, servedEntries: EvolveEntryMap, evolveOptions: FlatEvolveOptions) => Promise<EvolveDevServerEntryMap>;
@@ -1 +1 @@
1
- import{mergeOptions}from"@flatjs/common";import{prepareMockDomain}from"@flatjs/mock";import{normalizeEvolveEntryName}from"../helpers/normalize-entry-map.js";export const createDevServerEntries=async(r,e,o)=>{const{devServer:t,projectVirtualPath:n}=o,m={},{mockPort:a,hostUri:i}=await prepareMockDomain(mergeOptions(t?.mockOptions||{},{port:r}));for(const[r,o]of Object.entries(e)){const e=normalizeEvolveEntryName(r,n);m[r]={entryConfig:o,devServerPort:a,devServerHostUri:i,normalizedEntryName:e}}return m};
1
+ import{mergeOptions}from"@flatjs/common";import{prepareMockDomain}from"@flatjs/mock";import{normalizeEvolveEntryName}from"../helpers/normalize-entry-map.js";export const createDevServerEntries=async(r,e,o)=>{const{devServer:t,projectVirtualPath:n}=o,m={};let a=r;for(const[r,o]of Object.entries(e)){a+=1;const{mockPort:e,hostUri:i}=await prepareMockDomain(mergeOptions(t?.mockOptions||{},{port:a})),s=normalizeEvolveEntryName(r,n);m[r]={entryConfig:o,devServerPort:e,devServerHostUri:i,normalizedEntryName:s}}return m};
@@ -1 +1 @@
1
- import express from"express";import https from"node:https";import{prepareMockDomain}from"@flatjs/mock";export const createDevServer=async e=>{const r=express(),t=e.devServer?.mockOptions,{mockPort:o,hostUri:p,publicIp:s}=await prepareMockDomain(t||{});return new Promise((t=>{const i=e.devServer?.https?https.createServer(e.devServer?.https,r):r;r.set("hostUri",p),i.listen(o,(()=>{t({app:r,publicIp:s,devHostUri:p,devPort:o})}))}))};
1
+ import https from"node:https";import{prepareMockDomain}from"@flatjs/mock";import express from"express";export const createDevServer=async e=>{const r=express(),t=e.devServer?.mockOptions,{mockPort:o,hostUri:p,publicIp:s}=await prepareMockDomain(t||{});return new Promise((t=>{const i=e.devServer?.https?https.createServer(e.devServer?.https,r):r;r.set("hostUri",p),i.listen(o,(()=>{t({app:r,publicIp:s,devHostUri:p,devPort:o})}))}))};
@@ -1,6 +1,6 @@
1
+ export * from './middlewares/index.js';
1
2
  export * from './add-compiler-to-dev-server.js';
2
- export * from './create-app-page-route.js';
3
3
  export * from './create-dev-server.js';
4
- export * from './create-dev-server-compiler-task.js';
4
+ export * from './create-app-page-route.js';
5
5
  export * from './create-dev-server-entries.js';
6
- export * from './middlewares/index.js';
6
+ export * from './create-dev-server-compiler-tasks.js';
@@ -1 +1 @@
1
- export*from"./add-compiler-to-dev-server.js";export*from"./create-app-page-route.js";export*from"./create-dev-server.js";export*from"./create-dev-server-compiler-task.js";export*from"./create-dev-server-entries.js";export*from"./middlewares/index.js";
1
+ export*from"./middlewares/index.js";export*from"./add-compiler-to-dev-server.js";export*from"./create-dev-server.js";export*from"./create-app-page-route.js";export*from"./create-dev-server-entries.js";export*from"./create-dev-server-compiler-tasks.js";
@@ -1 +1 @@
1
- export declare const getBundleAsset: (devServerHostUri: string, normalizedCurrEntry: string, extension: ".css" | ".js") => string;
1
+ export declare const getBundleAsset: (devServerHostUri: string, normalizedCurrEntry: string, extension: '.css' | '.js') => string;
@@ -1 +1 @@
1
- import _ from"lodash";import{readFileSync}from"node:fs";import{join}from"node:path";import{urlJoin}from"@flatjs/common";import{getPackageDir}from"../../helpers/get-pacakge-dir.js";import{normalizePageProxy}from"../../helpers/normalize-page-proxy.js";import{getSortedModules}from"./get-all-sorted-modules.js";export const getPageMainHtml=async(e,r,t)=>{const o=getPackageDir(),a=readFileSync(join(o,"./templates/main.html"),"utf-8"),n=getSortedModules(t,e,r),i=normalizePageProxy(t.devServer?.pageProxy||"/pages"),m=n.map((e=>{const{entryName:t,entryContent:o,isServedEntry:a,projectVirtualPath:n,normalizedEntryName:m}=e,s=urlJoin(r,[i,m],{env:"me"}),l=o.options?.servePageMainLinkFn||(e=>e);return{link:l(s,{hostUri:r,entryName:t,virtualPath:n}),name:t.replace(n,"").replace(/^\//,""),flagText:a?"serve":"static",isServed:a?1:0}}));m.push({flagText:"serve",isServed:1,link:urlJoin(r,[i,"/runtime/manifest.json"]),name:"Runtime Manifest"});const s={title:"@flatjs/evolve",modules:m.sort(((e,r)=>r.isServed-e.isServed))};return _.template(a)(s)};
1
+ import{readFileSync}from"node:fs";import{join}from"node:path";import{urlJoin}from"@flatjs/common";import _ from"lodash";import{getPackageDir}from"../../helpers/get-pacakge-dir.js";import{normalizePageProxy}from"../../helpers/normalize-page-proxy.js";import{getSortedModules}from"./get-all-sorted-modules.js";export const getPageMainHtml=async(e,r,t)=>{const o=getPackageDir(),a=readFileSync(join(o,"./templates/main.html"),"utf-8"),i=getSortedModules(t,e,r),n=normalizePageProxy(t.devServer?.pageProxy||"/pages"),m={title:"@flatjs/evolve",modules:i.map((e=>{const{entryName:t,entryContent:o,isServedEntry:a,projectVirtualPath:i,normalizedEntryName:m}=e,l=urlJoin(r,[n,m],{env:"me"}),s=o.options?.servePageMainLinkFn||(e=>e);return{link:s(l,{hostUri:r,entryName:t,virtualPath:i}),name:t.replace(i,"").replace(/^\//,""),flagText:a?"serve":"static",isServed:a?1:0}})).sort(((e,r)=>r.isServed-e.isServed))};return _.template(a)(m)};
@@ -1 +1 @@
1
- import _ from"lodash";import{existsSync,readFileSync}from"node:fs";import{isAbsolute,join}from"node:path";import{ensureSlash,urlJoin}from"@flatjs/common";import{allowPx2remForModule}from"../../helpers/allow-px2rem-for-module.js";import{getHtmlPluginConfig}from"../../helpers/get-html-plugin-config.js";import{getPackageDir}from"../../helpers/get-pacakge-dir.js";import{getRuntimeCDNBase}from"../../helpers/get-runtime-cdn-base.js";import{normalizeEvolveEntryName}from"../../helpers/normalize-entry-map.js";import{normalizePageProxy}from"../../helpers/normalize-page-proxy.js";import{normalizeTemplateInjectTokens}from"../../helpers/normalize-template-inject-tokens.js";import{injectFederationScripts}from"../../helpers/script-injects.js";import{getBundleAsset}from"./get-bundle-asset.js";import{getDevServerHostUri}from"./get-dev-server-host-uri.js";import{getHmrRuntimeChunks}from"./get-hmr-runtime-chunks.js";import{getNormalizedEntryName}from"./get-normalized-entry-name.js";export const getPageModuleHtml=async(e,t,r,o,l)=>{const{entryMap:a,projectVirtualPath:i}=l,n=Object.keys(a).sort(((e,t)=>t.length-e.length)),m=getPackageDir(),s=n.find((e=>{const r=normalizeEvolveEntryName(e,i);return ensureSlash(t.path.replace(/^\//,""),!0).startsWith(ensureSlash(r,!0))}));if(!s){const e=readFileSync(join(m,"./templates/module-404.html"),"utf-8");return _.template(e)({title:"404 Not Found",errorMeta:[{name:"@flatjs/evolve workspace",value:m},{name:"served entry names",value:JSON.stringify(n)},{name:"module path",value:`${t.path}`}]})}const p=a[s],u=p.options,c=getDevServerHostUri(e,s,r),g=u?.serveModuleTemplate||"./templates/module.html",d=join(l.projectCwd,"./templates/module.html"),f=readFileSync(isAbsolute(g)?g:existsSync(d)?d:join(m,"./templates/module.html"),"utf-8"),h=l.devServer,v=h?.defaultServeGlobalData?await h.defaultServeGlobalData(p,r):{},j={mode:"development",envCdn:urlJoin(r,["public"])},y=getNormalizedEntryName(s,i,e,h),S=normalizePageProxy(h?.pageProxy||"/pages"),H=[getRuntimeCDNBase(l.multiHtmlCdn,l.multiHtmlCdnEnvResolver||function cdnResolver(){})],P=normalizeTemplateInjectTokens(j,u),C={title:getHtmlPluginConfig("title",j,u?.title),favicon:getHtmlPluginConfig("favicon",j,u?.favicon),viewport:allowPx2remForModule([s,p],l)?getHtmlPluginConfig("viewport",j,u?.viewport):"",...P,inlineScripts:P.inlineScripts?.concat(H),moduleFederationScripts:injectFederationScripts({me:[urlJoin(r,["public"])]},l.multiHtmlCdnEnvResolver),global:{hostUrl:r,apiBase:urlJoin(r,[o]),virtualPath:join(S,i),moduleName:s.replace(i,"").replace(/^\//,""),...v,...u?.serveGlobalData||{}},styles:[getBundleAsset(c,y,".css")],scripts:[getBundleAsset(c,y,".js")]};C.headBeforeHtmlTags?C.headBeforeHtmlTags=C.headBeforeHtmlTags.slice(0):C.headBeforeHtmlTags=[];return getHmrRuntimeChunks(e,s,y,p,l,c).forEach((e=>{C.headBeforeHtmlTags?.push(`<script src="${e}"><\/script>`)})),_.template(f)(C)};
1
+ import{existsSync,readFileSync}from"node:fs";import{isAbsolute,join}from"node:path";import{ensureSlash,urlJoin}from"@flatjs/common";import _ from"lodash";import{allowPx2remForModule}from"../../helpers/allow-px2rem-for-module.js";import{getHtmlPluginConfig}from"../../helpers/get-html-plugin-config.js";import{getPackageDir}from"../../helpers/get-pacakge-dir.js";import{normalizeEvolveEntryName}from"../../helpers/normalize-entry-map.js";import{normalizePageProxy}from"../../helpers/normalize-page-proxy.js";import{injectFederationScripts}from"../../helpers/script-injects.js";import{getBundleAsset}from"./get-bundle-asset.js";import{getDevServerHostUri}from"./get-dev-server-host-uri.js";import{getHmrRuntimeChunks}from"./get-hmr-runtime-chunks.js";import{getNormalizedEntryName}from"./get-normalized-entry-name.js";export const getPageModuleHtml=async(e,t,r,o,l)=>{const{entryMap:i,projectVirtualPath:a}=l,s=Object.keys(i).sort(((e,t)=>t.length-e.length)),n=getPackageDir(),m=s.find((e=>{const r=normalizeEvolveEntryName(e,a);return ensureSlash(t.path.replace(/^\//,""),!0).startsWith(ensureSlash(r,!0))}));if(!m){const e=readFileSync(join(n,"./templates/module-404.html"),"utf-8");return _.template(e)({title:"404 Not Found",errorMeta:[{name:"@flatjs/evolve workspace",value:n},{name:"served entry names",value:JSON.stringify(s)},{name:"module path",value:`${t.path}`}]})}const p=i[m],g=p.options,u=getDevServerHostUri(e,m,r),d=g?.serveModuleTemplate||"./templates/module.html",f=join(l.projectCwd,"./templates/module.html"),c=readFileSync(isAbsolute(d)?d:existsSync(f)?f:join(n,"./templates/module.html"),"utf-8"),h=l.devServer,v=h?.defaultServeGlobalData?await h.defaultServeGlobalData(p,r):{},S={mode:"development",envCdn:urlJoin(r,["public"])},y=getNormalizedEntryName(m,a,e,h),j=normalizePageProxy(h?.pageProxy||"/pages"),H={title:getHtmlPluginConfig("title",S,g?.title),favicon:getHtmlPluginConfig("favicon",S,g?.favicon),viewport:allowPx2remForModule([m,p],l)?getHtmlPluginConfig("viewport",S,g?.viewport):"",headBeforeHtmlTags:getHtmlPluginConfig("headBeforeHtmlTags",S,g?.headBeforeHtmlTags),inlineScripts:getHtmlPluginConfig("inlineScripts",S,g?.inlineScripts),headBeforeStyles:getHtmlPluginConfig("headBeforeStyles",S,g?.headBeforeStyles),headBeforeScripts:getHtmlPluginConfig("headBeforeScripts",S,g?.headBeforeScripts),bodyAfterScripts:getHtmlPluginConfig("bodyAfterScripts",S,g?.bodyAfterScripts),moduleFederationScripts:injectFederationScripts({me:[urlJoin(r,["public"])]},l.multiHtmlCdnEnvResolver),global:{hostUrl:r,apiBase:urlJoin(r,[o]),virtualPath:join(j,a),moduleName:m.replace(a,"").replace(/^\//,""),...v,...g?.serveGlobalData||{}},styles:[getBundleAsset(u,y,".css")],scripts:[getBundleAsset(u,y,".js")]};H.headBeforeHtmlTags?H.headBeforeHtmlTags=H.headBeforeHtmlTags.slice(0):H.headBeforeHtmlTags=[];return getHmrRuntimeChunks(e,m,y,p,l,u).forEach((e=>{H.headBeforeHtmlTags?.push(`<script src="${e}"><\/script>`)})),_.template(c)(H)};
@@ -0,0 +1,7 @@
1
+ import { type EntryMapItem, type EvolveEntryMap } from '../types/types-entry-map.js';
2
+ import { type FlatEvolveOptions } from '../types/types-options.js';
3
+ /**
4
+ * Only fetch single one entry map once `serve`,`build` recycle.
5
+ * @returns
6
+ */
7
+ export declare const assertOnlySingleEntryItem: (entryMap: EvolveEntryMap, evolveOptions: FlatEvolveOptions) => EntryMapItem;
@@ -0,0 +1 @@
1
+ import{normalizeEvolveEntryName}from"./normalize-entry-map.js";export const assertOnlySingleEntryItem=(e,r)=>{if(Object.keys(e).length>1)throw new Error("Only single one entry map support right now for `serve`, `build`!");let t;for(const[r,o]of Object.entries(e)){t=[r,o];break}if(!t)throw new Error('No entry map found while "serve", "build" process!');const[o,n]=t;return[normalizeEvolveEntryName(o,r.projectVirtualPath),n]};
@@ -11,4 +11,4 @@ export declare const currNow: () => string;
11
11
  * @param serveMode If we are run `serve` mode
12
12
  * @param enableBundleHashName If we need to generate bundle file name with `[contenthash]`
13
13
  */
14
- export declare const getBundleFileName: (type: "css" | "js", serveMode: boolean, enableBundleHashName?: boolean) => string;
14
+ export declare const getBundleFileName: (type: 'css' | 'js', serveMode: boolean, enableBundleHashName?: boolean) => string;
@@ -1,31 +1,17 @@
1
1
  export * from './allow-px2rem-for-module.js';
2
- export * from './assert-group-entry-item.js';
3
- export * from './assert-single-compiler.js';
4
- export * from './check-runtime-env.js';
2
+ export * from './assert-only-single-entry-item.js';
5
3
  export * from './chunk-entry-map.js';
6
- export * from './custom-listr-renderer.js';
7
- export * from './delete-object-keys.js';
8
4
  export * from './enable-bundle-hashname-for-module.js';
9
- export * from './flat-entry-map.js';
10
- export * from './format-spinner-text.js';
11
5
  export * from './get-bundle-file-name.js';
12
6
  export * from './get-html-plugin-config.js';
13
7
  export * from './get-pacakge-dir.js';
14
- export * from './get-runtime-cdn-base.js';
15
- export * from './get-stats-file-name.js';
16
- export * from './is-deep-equal.js';
17
- export * from './json-serializer.js';
18
8
  export * from './merge-babel-options.js';
19
- export * from './normalize-check-entry-options.js';
20
9
  export * from './normalize-entry-map.js';
21
- export * from './normalize-group-name.js';
22
- export * from './normalize-page-proxy.js';
23
- export * from './normalize-resolve-alias.js';
24
- export * from './normalize-template-inject-tokens.js';
25
10
  export * from './open-page.js';
26
11
  export * from './print-log.js';
27
12
  export * from './refresh-evolve-mock-options.js';
28
13
  export * from './script-injects.js';
29
14
  export * from './should-enable-react-fast-refresh.js';
30
- export * from './split-to-entry-group.js';
31
- export * from './verify-group-entry-options.js';
15
+ export * from './split-to-multi-compiler.js';
16
+ export * from './json-serializer.js';
17
+ export * from './normalize-resolve-alias.js';
@@ -1 +1 @@
1
- export*from"./allow-px2rem-for-module.js";export*from"./assert-group-entry-item.js";export*from"./assert-single-compiler.js";export*from"./check-runtime-env.js";export*from"./chunk-entry-map.js";export*from"./custom-listr-renderer.js";export*from"./delete-object-keys.js";export*from"./enable-bundle-hashname-for-module.js";export*from"./flat-entry-map.js";export*from"./format-spinner-text.js";export*from"./get-bundle-file-name.js";export*from"./get-html-plugin-config.js";export*from"./get-pacakge-dir.js";export*from"./get-runtime-cdn-base.js";export*from"./get-stats-file-name.js";export*from"./is-deep-equal.js";export*from"./json-serializer.js";export*from"./merge-babel-options.js";export*from"./normalize-check-entry-options.js";export*from"./normalize-entry-map.js";export*from"./normalize-group-name.js";export*from"./normalize-page-proxy.js";export*from"./normalize-resolve-alias.js";export*from"./normalize-template-inject-tokens.js";export*from"./open-page.js";export*from"./print-log.js";export*from"./refresh-evolve-mock-options.js";export*from"./script-injects.js";export*from"./should-enable-react-fast-refresh.js";export*from"./split-to-entry-group.js";export*from"./verify-group-entry-options.js";
1
+ export*from"./allow-px2rem-for-module.js";export*from"./assert-only-single-entry-item.js";export*from"./chunk-entry-map.js";export*from"./enable-bundle-hashname-for-module.js";export*from"./get-bundle-file-name.js";export*from"./get-html-plugin-config.js";export*from"./get-pacakge-dir.js";export*from"./merge-babel-options.js";export*from"./normalize-entry-map.js";export*from"./open-page.js";export*from"./print-log.js";export*from"./refresh-evolve-mock-options.js";export*from"./script-injects.js";export*from"./should-enable-react-fast-refresh.js";export*from"./split-to-multi-compiler.js";export*from"./json-serializer.js";export*from"./normalize-resolve-alias.js";
@@ -1 +1 @@
1
- import vm from"node:vm";function stringifyWithFns(n){return JSON.stringify(n,(function(n,t){if("function"==typeof t)try{return makeFunctionFromString(t),t.toString()}catch{return`function ${t.toString()}`}return t}))}function looksLikeAFunctionString(n){return!![/^function[^(]*\(([^()]*)\)\s*\{[\s\S]*\}$/m,/^(\s*async\s*)?(\w*\s*)\(([^)]*)\)\s*=>\s*(.*)$/m,/^\s*\w+\s*=>/m].find((t=>t.test(n)))}function makeFunctionFromString(n){return vm.runInNewContext("("+n+")")}function parseWithFns(n){try{return JSON.parse(n,(function(n,t){return looksLikeAFunctionString(t)?makeFunctionFromString(t):t}))}catch{return{}}}export const jsonSerializer={stringify:stringifyWithFns,parse:parseWithFns};
1
+ function stringifyWithFns(n){return JSON.stringify(n,(function(n,t){if("function"==typeof t)try{return makeFunctionFromString(t),t.toString()}catch(n){return`function ${t.toString()}`}return t}))}function looksLikeAFunctionString(n){return!![/^function[^(]*\(([^()]*)\)\s*\{[\s\S]*\}$/m,/^(\s*async\s*)?(\w*\s*)\(([^)]*)\)\s*=>\s*(.*)$/m,/^\s*\w+\s*=>/m].find((t=>t.test(n)))}function makeFunctionFromString(funcString){return eval("("+funcString+")")}function parseWithFns(n){try{return JSON.parse(n,(function(n,t){return looksLikeAFunctionString(t)?makeFunctionFromString(t):t}))}catch(n){return{}}}export const jsonSerializer={stringify:stringifyWithFns,parse:parseWithFns};
@@ -11,6 +11,5 @@ export declare const normalizeEvolveEntryName: (entryName: string, projectVirtua
11
11
  * Merge default entry item configuration values.
12
12
  * @param activedEntryMap actived entries
13
13
  * @param definedEntryMap defined entries in flatjs.evolve.js
14
- * @param projectVirtualPath virtual path for current `project`
15
14
  */
16
15
  export declare const normalizeEvolveEntryMap: (activedEntryMap?: EvolveEntryMap, definedEntryMap?: EvolveEntryMap) => EvolveEntryMap;
@@ -1 +1 @@
1
- import _ from"lodash";import{join}from"node:path";const normalizeEntryGroupOptions=o=>o&&o.groupName?{groupName:o.groupName,groupingSource:"manual"}:{groupingSource:"auto"};export const normalizeEvolveEntryName=(o,r)=>{const e=o.replace(/^\//,""),n=r.replace(/^\//,"");return(e.startsWith(n)?e:join(n,e)).replace(/\/$/,"")};export const normalizeEvolveEntryMap=(o={},r={})=>{const e={};for(const[n,t]of Object.entries(r)){const r={options:{}};if(o[n]){const p=normalizeEntryGroupOptions(t);e[n]=_.merge({},r,t,o[n],p)}}return e};
1
+ import{join}from"node:path";import _ from"lodash";export const normalizeEvolveEntryName=(o,e)=>{const r=o.replace(/^\//,""),t=e.replace(/^\//,"");return(r.startsWith(t)?r:join(t,r)).replace(/\/$/,"")};export const normalizeEvolveEntryMap=(o={},e={})=>{const r={};for(const[t,n]of Object.entries(e)){const e={options:{}};o[t]&&(r[t]=_.merge({},e,n,o[t])),_.merge(n,e)}return r};
@@ -1 +1 @@
1
- import opn from"better-opn";export const openPage=n=>{try{opn(n)}catch{console.warn("Unable to open browser. If you are running in a headless environment\n")}};
1
+ import opn from"better-opn";export const openPage=n=>{try{opn(n)}catch(n){console.warn("Unable to open browser. If you are running in a headless environment\n")}};
@@ -1 +1 @@
1
- import _ from"lodash";import{requireResolve}from"@flatjs/common";import{getMockCwd,loadMockConfig}from"@flatjs/mock";export const refreshEvolveMockOptions=async(o,t,e)=>{const s=t.devServer,r=e?.esmLoaderOptions,i=r?.externals||[],n={projectCwd:o,resolve:requireResolve},c=await loadMockConfig(n,o,s?.mockOptions||{},_.merge({},e,{configFile:"flatjs-mock",esmLoaderOptions:{externals:[...i,"@flatjs/mock"]}}));if(s){s.mockOptions=c||{},s.mockOptions&&!s.mockOptions.https&&(s.mockOptions.https=s?.https);const o=getMockCwd(c);Array.isArray(s?.watchOptions?.ignored)&&s?.watchOptions?.ignored.push(o)}return t};
1
+ import{requireResolve}from"@flatjs/common";import{loadMockConfig,getMockCwd}from"@flatjs/mock";import _ from"lodash";export const refreshEvolveMockOptions=async(o,t,e)=>{const s=t.devServer,r=e?.esmLoaderOptions,i=r?.externals||[],n={projectCwd:o,resolve:requireResolve},c=await loadMockConfig(n,o,s?.mockOptions||{},_.merge({},e,{configFile:"flatjs-mock",esmLoaderOptions:{externals:[...i,"@flatjs/mock"]}}));if(s){s.mockOptions=c||{},s.mockOptions&&!s.mockOptions.https&&(s.mockOptions.https=s?.https);const o=getMockCwd(c);Array.isArray(s?.watchOptions?.ignored)&&s?.watchOptions?.ignored.push(o)}return t};
@@ -1,4 +1,4 @@
1
- import { type EvolveMultiCDNConfig, type EvolveMultiCDNEnvResolver, type EvolveMultiCdnEnvType } from '../types/types-multi-html.js';
1
+ import { type EvolveMultiCdnEnvType, type EvolveMultiCDNConfig, type EvolveMultiCDNEnvResolver } from '../types/types-multi-html.js';
2
2
  export declare function httpUrlJoin(first?: string, second?: string): string;
3
3
  /**
4
4
  * To extract the best matched CDN configuration url address, either use URL `query.env` or customize the `envRresolver`
@@ -1 +1 @@
1
- export const shouldEnableReactFastRefresh=(e,o,t)=>{const r=o[1],s=!!r.options?.moduleFederation,a=!!r.options?.output?.library;return e&&"react"===t.loaderOptions.babelOptions?.usePreset&&!s&&!a&&!0!==t.devServer?.liveReload};
1
+ export const shouldEnableReactFastRefresh=(e,o,t)=>{const r=o[1],s=!!r.options?.moduleFederation;return e&&"react"===t.loaderOptions.babelOptions?.usePreset&&!s&&!0!==t.devServer?.liveReload};
@@ -0,0 +1,8 @@
1
+ import { type Configuration } from 'webpack';
2
+ import { type EvolveEntryMap } from '../types/types-entry-map.js';
3
+ import { type FlatEvolveOptions } from '../types/types-options.js';
4
+ /**
5
+ * Split the `webpack` to make sure that we have separated compiler process for each module
6
+ * @param webpackConfig `Omit<Configuration, 'entry'>` webpack final configuration
7
+ */
8
+ export declare function splitToMultiCompilerConfigs(servedEntries: EvolveEntryMap, webpackConfig: Omit<Configuration, 'entry'>, evolveOptions: FlatEvolveOptions, enabledHmr?: boolean): Configuration[];
@@ -0,0 +1 @@
1
+ import{join}from"path";import{mergeOptions}from"@flatjs/common";import{devReactFastRefresh}from"../constants.js";import{normalizeEvolveEntryName}from"./normalize-entry-map.js";export function splitToMultiCompilerConfigs(e,t,r,o=!1){const n=[];for(const[t,o]of Object.entries(e)){const e=normalizeEvolveEntryName(t,r.projectVirtualPath);n.push({[e]:o.entry})}return n.map((e=>{const r=Object.keys(e)[0];if(o){e[join(r,devReactFastRefresh.reactRefreshSetup)]=["@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js"]}return mergeOptions(t,{name:r,entry:e})}))}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from './define-config/index.js';
2
2
  export * from './load-config/index.js';
3
3
  export * from './main/index.js';
4
- export * from './types/types-entry-map.js';
5
4
  export * from './types/types-options.js';
5
+ export * from './types/types-entry-map.js';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export*from"./define-config/index.js";export*from"./load-config/index.js";export*from"./main/index.js";export*from"./types/types-entry-map.js";export*from"./types/types-options.js";
1
+ export*from"./define-config/index.js";export*from"./load-config/index.js";export*from"./main/index.js";export*from"./types/types-options.js";export*from"./types/types-entry-map.js";
@@ -1 +1 @@
1
- import{searchConfig}from"@armit/config-loader";import{logger,mergeOptions}from"@flatjs/common";import{configFileName,moduleName}from"../constants.js";import{defaultEvolveOptions}from"../default-options.js";import{normalizeResolveAlias}from"../helpers/normalize-resolve-alias.js";import{refreshEvolveMockOptions}from"../helpers/refresh-evolve-mock-options.js";export const loadEvolveConfig=async(o,e,i={},s={configFile:configFileName,esmLoaderOptions:{externals:[/^@flatjs\/.*/]}})=>{const{configFile:r,esmLoaderOptions:l}=s,a=await searchConfig(r,e,{esm:{...l,projectCwd:e}});let n={};n="function"==typeof a?.config?await(a?.config(o)):a?.config||{};const t=mergeOptions(defaultEvolveOptions,n),m=mergeOptions(t,i),f=mergeOptions(m,{projectCwd:e}),c="build"===o.command?f:await refreshEvolveMockOptions(e,f,s);return logger.debug(`Load evolve config:\n${JSON.stringify(c,null,2)}`,moduleName),c.webpack?.resolve?.alias&&(c.webpack.resolve.alias=normalizeResolveAlias(e,c.webpack?.resolve?.alias)),c};
1
+ import{searchConfig}from"@armit/config-loader";import{mergeOptions,logger}from"@flatjs/common";import{configFileName,moduleName}from"../constants.js";import{defaultEvolveOptions}from"../default-options.js";import{normalizeResolveAlias}from"../helpers/normalize-resolve-alias.js";import{refreshEvolveMockOptions}from"../helpers/refresh-evolve-mock-options.js";export const loadEvolveConfig=async(o,e,i={},s={configFile:configFileName,esmLoaderOptions:{externals:[/^@flatjs\/.*/]}})=>{const{configFile:r,esmLoaderOptions:l}=s,a=await searchConfig(r,e,{esm:{...l,projectCwd:e}});let n={};n="function"==typeof a?.config?await(a?.config(o)):a?.config||{};const t=mergeOptions(defaultEvolveOptions,n),m=mergeOptions(t,i),f=mergeOptions(m,{projectCwd:e}),c="build"===o.command?f:await refreshEvolveMockOptions(e,f,s);return logger.debug(`Load evolve config:\n${JSON.stringify(c,null,2)}`,moduleName),c.webpack?.resolve?.alias&&(c.webpack.resolve.alias=normalizeResolveAlias(e,c.webpack?.resolve?.alias)),c};
@@ -9,8 +9,7 @@ const svgOptimize = (buffer, svgoOption) => {
9
9
  return data;
10
10
  };
11
11
  const iconLoader = function iconLoader(source) {
12
- if (this.cacheable)
13
- this.cacheable(true);
12
+ this.cacheable && this.cacheable(true);
14
13
  const options = this.getOptions();
15
14
  const callback = this.async();
16
15
  try {
@@ -1,31 +1,16 @@
1
- import Tinypool from 'tinypool';
2
- import { type ThreadsOptions } from '../types/types-threads-options.js';
3
- import startBuildWorker from './start-build-worker.js';
4
- interface BaseThreadPool {
5
- startBuildWorker: (options: Parameters<typeof startBuildWorker>[0]) => ReturnType<typeof startBuildWorker>;
6
- terminate(): void;
1
+ import { type PoolInterface, type BaseWorker } from '@armit/worker-threads';
2
+ import { startBuildWorker } from './start-build-worker.js';
3
+ declare class ThreadPoolForUnittest implements BaseWorker {
4
+ private workerSize;
5
+ constructor(workerSize: number);
6
+ startBuildWorker(...args: Parameters<typeof startBuildWorker>): Promise<import("src/main/start-one-entry-build.js").EvolveBuildResult>;
7
+ get pool(): PoolInterface;
7
8
  }
8
- /**
9
- * Represents a thread pool for unit testing.
10
- */
11
- declare class ThreadPoolForUnittest implements BaseThreadPool {
12
- startBuildWorker(options: Parameters<typeof startBuildWorker>[0]): Promise<import("./start-group-entry-build.js").EvolveBuildResult>;
13
- terminate(): void;
14
- }
15
- /**
16
- * Represents a thread pool for executing tasks using the TinyPool library.
17
- */
18
- declare class ThreadPoolForTinyPool implements BaseThreadPool {
19
- pool: Tinypool;
20
- /**
21
- * Creates a new instance of the `ThreadPoolForTinyPool` class.
22
- * @param workerPath The path to the worker file.
23
- * @param workerSize The number of worker threads to create.
24
- * @param options Optional configuration options for the worker pool.
25
- */
26
- constructor(workerPath: string, options?: ThreadsOptions);
27
- startBuildWorker(options: Parameters<typeof startBuildWorker>[0]): ReturnType<typeof startBuildWorker>;
28
- terminate(): void;
29
- }
30
- export declare const createThreadWorker: (options?: ThreadsOptions) => ThreadPoolForUnittest | ThreadPoolForTinyPool;
9
+ export declare const createThreadWorker: (workerSize: number) => Promise<ThreadPoolForUnittest | (BaseWorker & {
10
+ all: {
11
+ readonly startBuildWorker: (projectCwd: string, entryKey: string, serializedEvolveOptions: string, configLoaderOptions?: import("src/load-config/types.js").ConfigLoaderOptions | undefined) => Promise<import("src/main/start-one-entry-build.js").EvolveBuildResult>;
12
+ };
13
+ } & {
14
+ readonly startBuildWorker: (projectCwd: string, entryKey: string, serializedEvolveOptions: string, configLoaderOptions?: import("src/load-config/types.js").ConfigLoaderOptions | undefined) => Promise<import("src/main/start-one-entry-build.js").EvolveBuildResult>;
15
+ })>;
31
16
  export {};
@@ -1 +1 @@
1
- import Tinypool from"tinypool";import{mergeOptions}from"@flatjs/common";import{customMessageChannel}from"../helpers/custom-message-channel.js";import{getWorkerPath}from"./get-worker-path.js";import startBuildWorker from"./start-build-worker.js";class ThreadPoolForUnittest{startBuildWorker(e){return startBuildWorker(e)}terminate(){console.warn('[WARNING] Using fake "terminate" for unittest!')}}class ThreadPoolForTinyPool{constructor(e,r){const{idleTimeout:o=6e4,minThreads:t=1,maxThreads:s}=r||{};this.pool=new Tinypool({runtime:"worker_threads",filename:e,minThreads:t,maxThreads:s,idleTimeout:o})}startBuildWorker(e){const{port1:r}=customMessageChannel.createMessageChannel(),o=mergeOptions(e,{messagePort:r});return this.pool.run(o,{transferList:[r]})}terminate(){this.pool.destroy(),customMessageChannel.dispose()}}export const createThreadWorker=e=>{const r=getWorkerPath();return"test"===process.env.NODE_ENV?(console.warn("[WARNING] Using fake thread pool worker for unittest!"),new ThreadPoolForUnittest):new ThreadPoolForTinyPool(r,e)};
1
+ import EventEmitter from"events";import{createThreadPool}from"@armit/worker-threads";import{getWorkerPath}from"./get-worker-path.js";import{startBuildWorker}from"./start-build-worker.js";class ThreadPoolForUnittest{constructor(r){this.workerSize=r}startBuildWorker(...r){return startBuildWorker(...r)}get pool(){const r=new EventEmitter,e={terminate(){console.warn('[WARNING] Using fake "terminate" for unittest!')},refill(){console.warn('[WARNING] Using fake "refill" for unittest!')},async drain(){console.warn('[WARNING] Using fake "drain" for unittest!')},size:this.workerSize,isTerminated:!1,threads:new Map};return Object.assign(r,e)}}export const createThreadWorker=async r=>{const e=getWorkerPath();return"test"===process.env.NODE_ENV?(console.warn("[WARNING] Using fake thread pool worker for unittest!"),new ThreadPoolForUnittest(r)):await createThreadPool(e,{size:r})};
@@ -1,4 +1,4 @@
1
1
  export * from './start-build.js';
2
- export * from './start-build-dynamic.js';
3
2
  export * from './start-serve.js';
4
3
  export * from './start-static.js';
4
+ export * from './start-build-dynamic.js';
@@ -1 +1 @@
1
- export*from"./start-build.js";export*from"./start-build-dynamic.js";export*from"./start-serve.js";export*from"./start-static.js";
1
+ export*from"./start-build.js";export*from"./start-serve.js";export*from"./start-static.js";export*from"./start-build-dynamic.js";
@@ -1,10 +1,9 @@
1
- import { FlatCliOptions } from '../types/types-cli-options.js';
2
- import { type EvolveEntryMap } from '../types/types-entry-map.js';
1
+ import { type EntryMapItem } from '../types/types-entry-map.js';
3
2
  import { type FlatEvolveOptions } from '../types/types-options.js';
4
- import { type EvolveBuildResult } from './start-group-entry-build.js';
3
+ import { type EvolveBuildResult } from './start-one-entry-build.js';
5
4
  /**
6
5
  * The main entry to start an evolve `build`
7
6
  * @param entryMapItem The `entryMapItem` for one entry build task
8
7
  * @param evolveOptions FlatEvolveOptions
9
8
  */
10
- export declare const prepareBuild: (groupEntries: EvolveEntryMap, evolveOptions: FlatEvolveOptions, cliOptions?: FlatCliOptions) => Promise<EvolveBuildResult>;
9
+ export declare const prepareBuild: (entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => Promise<EvolveBuildResult>;
@@ -1 +1 @@
1
- import{ensureSlash,mergeOptions}from"@flatjs/common";import{ignoreEntryOptionKeys}from"../constants.js";import{EvolveBuildError}from"../errors/evolve-build-error.js";import{printCompilerError}from"../helpers/print-log.js";import{verifyGroupEntryOptions}from"../helpers/verify-group-entry-options.js";import{startGroupEntryBuild}from"./start-group-entry-build.js";export const prepareBuild=async(r,o,t)=>{const e=Object.values(r)[0];if(!verifyGroupEntryOptions(r,ignoreEntryOptionKeys,!0))throw new Error("The entry options in a group must be the same.");const n=o.multiHtmlCdn?.prod||[];if(!n.length)throw new Error(`No CDN config for env:"prod", groupName: ${e.groupName}`);const i=ensureSlash(n[Math.floor(Math.random()*n.length)],!0);try{const n=e.options?.useRelativeAssetPath,s=mergeOptions(o,{webpack:{publicPath:n?"auto":i}});return await startGroupEntryBuild(r,s,t)}catch(r){const o=printCompilerError(r);throw new EvolveBuildError("BUILD_ERROR",o)}};
1
+ import{ensureSlash,mergeOptions}from"@flatjs/common";import{EvolveBuildError}from"../errors/evolve-build-error.js";import{printCompilerError}from"../helpers/print-log.js";import{startOneEntryBuild}from"./start-one-entry-build.js";export const prepareBuild=async(r,o)=>{const[t,e]=r,n=o.multiHtmlCdn?.prod||[];if(!n.length)throw new Error(`No CDN config for env:"prod", moduleName: ${t}`);const i=ensureSlash(n[Math.floor(Math.random()*n.length)],!0),l={[t]:e};try{const r=e.options?.useRelativeAssetPath,t=mergeOptions(o,{webpack:{publicPath:r?"auto":i}});return await startOneEntryBuild(l,t)}catch(r){const o=printCompilerError(r);throw new EvolveBuildError("BUILD_ERROR",o)}};
@@ -6,4 +6,4 @@ import { type FlatEvolveOptions } from '../types/types-options.js';
6
6
  * @param servedEntries All normalized webpack entries we have served.
7
7
  * @param evolveOptions FlatEvolveOptions
8
8
  */
9
- export declare const prepareServe: (projectCwd: string, servedEntries: EvolveEntryMap, evolveOptions: FlatEvolveOptions) => Promise<import("express-serve-static-core").Express | undefined>;
9
+ export declare const prepareServe: (projectCwd: string, servedEntries: EvolveEntryMap, evolveOptions: FlatEvolveOptions) => Promise<import("express-serve-static-core").Express>;