@flatjs/evolve 2.1.0-next.1 → 2.1.0-next.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. package/dist/constants.d.ts +9 -0
  2. package/dist/constants.js +1 -1
  3. package/dist/create-webpack/create-optimization.d.ts +1 -1
  4. package/dist/create-webpack/create-optimization.js +1 -1
  5. package/dist/create-webpack/create-plugins.d.ts +1 -1
  6. package/dist/create-webpack/create-plugins.js +1 -1
  7. package/dist/create-webpack/create-rule-sets.d.ts +1 -1
  8. package/dist/create-webpack/create-rule-sets.js +1 -1
  9. package/dist/create-webpack/load-webpack-config.js +1 -1
  10. package/dist/create-webpack/rule-sets/rule-assets.d.ts +2 -2
  11. package/dist/create-webpack/rule-sets/rule-assets.js +1 -1
  12. package/dist/default-options.js +1 -1
  13. package/dist/dev-server/create-dev-server-compiler-task.d.ts +3 -0
  14. package/dist/dev-server/create-dev-server-compiler-task.js +1 -0
  15. package/dist/dev-server/create-dev-server-entries.d.ts +1 -1
  16. package/dist/dev-server/create-dev-server-entries.js +1 -1
  17. package/dist/dev-server/index.d.ts +1 -1
  18. package/dist/dev-server/index.js +1 -1
  19. package/dist/dev-server/middlewares/get-page-main-html.js +1 -1
  20. package/dist/dev-server/middlewares/get-page-module-html.js +1 -1
  21. package/dist/helpers/assert-group-entry-item.d.ts +7 -0
  22. package/dist/helpers/assert-group-entry-item.js +1 -0
  23. package/dist/helpers/assert-single-compiler.d.ts +15 -0
  24. package/dist/helpers/assert-single-compiler.js +1 -0
  25. package/dist/helpers/delete-object-keys.d.ts +11 -0
  26. package/dist/helpers/delete-object-keys.js +1 -0
  27. package/dist/helpers/flat-entry-map.d.ts +8 -0
  28. package/dist/helpers/flat-entry-map.js +1 -0
  29. package/dist/helpers/get-runtime-cdn-base.d.ts +2 -0
  30. package/dist/helpers/get-runtime-cdn-base.js +1 -0
  31. package/dist/helpers/index.d.ts +12 -2
  32. package/dist/helpers/index.js +1 -1
  33. package/dist/helpers/is-deep-equal.d.ts +9 -0
  34. package/dist/helpers/is-deep-equal.js +1 -0
  35. package/dist/helpers/normalize-check-entry-options.d.ts +10 -0
  36. package/dist/helpers/normalize-check-entry-options.js +1 -0
  37. package/dist/helpers/normalize-entry-map.d.ts +1 -0
  38. package/dist/helpers/normalize-entry-map.js +1 -1
  39. package/dist/helpers/normalize-group-name.d.ts +8 -0
  40. package/dist/helpers/normalize-group-name.js +1 -0
  41. package/dist/helpers/normalize-template-inject-tokens.d.ts +16 -0
  42. package/dist/helpers/normalize-template-inject-tokens.js +1 -0
  43. package/dist/helpers/should-enable-react-fast-refresh.js +1 -1
  44. package/dist/helpers/split-to-entry-group.d.ts +53 -0
  45. package/dist/helpers/split-to-entry-group.js +1 -0
  46. package/dist/helpers/verify-group-entry-options.d.ts +9 -0
  47. package/dist/helpers/verify-group-entry-options.js +1 -0
  48. package/dist/main/create-thread-worker.d.ts +29 -14
  49. package/dist/main/create-thread-worker.js +1 -1
  50. package/dist/main/prepare-build.d.ts +3 -3
  51. package/dist/main/prepare-build.js +1 -1
  52. package/dist/main/prepare-serve.d.ts +1 -1
  53. package/dist/main/prepare-serve.js +1 -1
  54. package/dist/main/start-build-dynamic.d.ts +2 -2
  55. package/dist/main/start-build-dynamic.js +1 -1
  56. package/dist/main/start-build-worker.d.ts +12 -6
  57. package/dist/main/start-build-worker.js +1 -1
  58. package/dist/main/start-build.d.ts +1 -1
  59. package/dist/main/start-build.js +1 -1
  60. package/dist/main/start-group-entry-build.d.ts +14 -0
  61. package/dist/main/start-group-entry-build.js +1 -0
  62. package/dist/main/start-serve.d.ts +1 -1
  63. package/dist/plugins/clean-webpack/index.d.ts +1 -1
  64. package/dist/plugins/clean-webpack/index.js +1 -1
  65. package/dist/plugins/module-federation/module-federation.d.ts +1 -1
  66. package/dist/plugins/module-federation/module-federation.js +1 -1
  67. package/dist/plugins/multi-html/index.d.ts +1 -1
  68. package/dist/plugins/multi-html/index.js +1 -1
  69. package/dist/plugins/multi-html/multi-html-cdn-plugin.js +1 -1
  70. package/dist/plugins/multi-html/multi-html-plugin.d.ts +1 -1
  71. package/dist/plugins/multi-html/multi-html-plugin.js +1 -1
  72. package/dist/plugins/ts-checker/index.d.ts +1 -0
  73. package/dist/plugins/ts-checker/index.js +1 -0
  74. package/dist/plugins/ts-checker/ts-checker-plugin.d.ts +4 -0
  75. package/dist/plugins/ts-checker/ts-checker-plugin.js +1 -0
  76. package/dist/types/types-entry-map.d.ts +16 -2
  77. package/dist/types/types-options.d.ts +18 -10
  78. package/dist/types/types-threads-options.d.ts +25 -0
  79. package/dist/types/types-threads-options.js +1 -0
  80. package/package.json +61 -56
  81. package/templates/html-plugin/index-dev.html +2 -2
  82. package/templates/html-plugin/index-inte.html +2 -2
  83. package/templates/html-plugin/index-inte2.html +2 -2
  84. package/templates/html-plugin/index-inte3.html +2 -2
  85. package/templates/html-plugin/index-inte4.html +2 -2
  86. package/templates/html-plugin/index-me.html +2 -2
  87. package/templates/html-plugin/index-prod.html +2 -2
  88. package/templates/html-plugin/index-rc.html +2 -2
  89. package/templates/html-plugin/index-uat.html +2 -2
  90. package/templates/module.html +2 -2
  91. package/dist/dev-server/create-dev-server-compiler-tasks.d.ts +0 -3
  92. package/dist/dev-server/create-dev-server-compiler-tasks.js +0 -1
  93. package/dist/helpers/assert-only-single-entry-item.d.ts +0 -7
  94. package/dist/helpers/assert-only-single-entry-item.js +0 -1
  95. package/dist/helpers/split-to-multi-compiler.d.ts +0 -8
  96. package/dist/helpers/split-to-multi-compiler.js +0 -1
  97. package/dist/main/start-one-entry-build.d.ts +0 -13
  98. package/dist/main/start-one-entry-build.js +0 -1
@@ -1,3 +1,4 @@
1
+ import { type EvolveEntryItemOption } from './types/types-entry-map.js';
1
2
  export declare const moduleName = "@flatjs/evolve";
2
3
  /**
3
4
  * the configuration file of `flat-evolve`
@@ -22,3 +23,11 @@ export declare const devReactFastRefresh: {
22
23
  runtime: string;
23
24
  reactRefreshSetup: string;
24
25
  };
26
+ /**
27
+ * Array of keys to ignore in the verifyGroupEntryOptions step
28
+ */
29
+ export declare const ignoreEntryOptionKeys: Array<keyof EvolveEntryItemOption>;
30
+ /**
31
+ * The maximum size of an entry group.
32
+ */
33
+ export declare const maxEntryGroupSize = 10;
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"};
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 maxEntryGroupSize=10;
@@ -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, entryItem: EntryMapItem) => Configuration['optimization'];
4
+ export declare const createOptimization: (serveMode: boolean, evolveOptions: FlatEvolveOptions, entryMapItem: 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:()=>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
+ 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,4 +1,4 @@
1
1
  import { type EntryMapItem } from '../types/types-entry-map.js';
2
2
  import { type FlatEvolveOptions } from '../types/types-options.js';
3
3
  import { type FlatEvolveWebpackOptions } from '../types/types-webpack.js';
4
- export declare const createPlugins: (serveMode: boolean, entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => Promise<FlatEvolveWebpackOptions['plugins']>;
4
+ export declare const createPlugins: (serveMode: boolean, entryMapItemList: EntryMapItem[], evolveOptions: FlatEvolveOptions) => Promise<FlatEvolveWebpackOptions['plugins']>;
@@ -1 +1 @@
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
+ import{logger}from"@flatjs/common";import ReactRefreshWebpackPlugin from"@pmmmwh/react-refresh-webpack-plugin";import CaseSensitivePathsPlugin from"case-sensitive-paths-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";import{createTsCheckerPlugins}from"../plugins/ts-checker/index.js";export const createPlugins=async(e,a,n)=>{const r=a[0],[l,i]=r,s=enableBundleHashNameForModule(n,i?.options),t=[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),...createTsCheckerPlugins(e,a,n)];n.analyzer&&t.push(new BundleAnalyzerPlugin({analyzerPort:"auto",analyzerMode:"server",...n.analyzer}));const o=shouldEnableReactFastRefresh(e,r,n);o&&t.push(new ReactRefreshWebpackPlugin({overlay:!1})),!o&&e&&(n.devServer?.liveReload?logger.warn('The HMR disabled cause of "liveReload" specificed'):logger.warn(`The HMR disabled cause of \`"moduleFederation":"${l}"\``));const c=n.webpack?.plugins||[];return t.concat(c)};
@@ -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, entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => RuleSetRule[];
4
+ export declare const createRuleSets: (serveMode: boolean, entryMapItemList: 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=[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
+ 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 +1 @@
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"}}};
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";export const loadWebpackConfig=async(e,t,r)=>{const a="development"===e,{projectCwd:o,webpack:s,devServer:c}=r,n=c?.watchOptions,p=assertGroupEntryItem(t,r),i=createRuleSets(a,p,r),m=await createPlugins(a,p,r),l=p[0];return{mode:e,plugins:m,watchOptions:n,output:await createOutput(a,r,l),context:o,target:s?.target??["web","es5"],resolve:createResolve(o,s),module:{rules:i},devtool:a?"eval-source-map":s?.sourceMap||!1,externalsType:s?.externalsType,externals:createExternals(s?.externals,l),performance:createPerformance(a,s?.performance),optimization:createOptimization(a,r,l),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 entryItem The available entries, `development` it contains multiple enties, `production` only one entry in once build.
8
+ * @param entryMapItemList The available entries, `development` it contains multiple enties, `production`
9
9
  */
10
- export declare const ruleAssets: (entryItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => RuleSetRule;
10
+ export declare const ruleAssets: (entryMapItemList: EntryMapItem[], evolveOptions: FlatEvolveOptions) => RuleSetRule;
@@ -1 +1 @@
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
+ 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)=>{for(const o of t){const[t,s]=o,{projectCwd:a,projectVirtualPath:i}=r;let n=dirname(join(i,e.replace(/^src/,"")));const l=s.entry.map((e=>dirname(join(a,e)))),m=resolve(a,e),c=l.find((e=>m.startsWith(e)));return c&&(n=dirname(join(t,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
- 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
+ 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},ci:{basedBranch:"origin/master"}};
@@ -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 createDevServerCompilerTask: (projectCwd: string, mainPage: string, publicIp: string, servedDevServerEntries: EvolveDevServerEntryMap, servedDevServerEntryList: Array<EvolveDevServerEntryMap>, evolveOptions: FlatEvolveOptions) => 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{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,a,n)=>{const[i,s]=Object.entries(t)[0],{devServerPort:l,devServerHostUri:p}=s;for(const[,e]of Object.entries(t)){const r=e.entryConfig,o=r.options?.moduleFederation,t=o?.remotes||[],n=flatEntryMap(a);t.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 c=Object.keys(t).reduce(((e,r)=>(e[r]=t[r].entryConfig,e)),{}),m=urlJoin(p,["public"]),f=await loadWebpackConfig("development",c,mergeOptions(n,{webpack:{publicPath:m}})),d=shouldEnableReactFastRefresh(!0,[i,s.entryConfig],n),v=assertSingleCompiler(c,f,n,d),g=webpack(v),h=addCompilerToDevServer(g,d,l,o,n),b=g.name||"";return g.hooks.invalid.tap("fileChange",(r=>{const o=relative(e,r||"");logger.info(`file change ➩ ${chalk(["cyan"])(o)}`,b)})),g.hooks.done.tap("compileDone",(()=>{logger.info(`debug page ➩ ${chalk(["cyan"])(r)}`,b)})),h};
@@ -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: (startPort: number, servedEntries: EvolveEntryMap, evolveOptions: FlatEvolveOptions) => Promise<EvolveDevServerEntryMap>;
4
+ export declare const createDevServerEntries: (lastPort: 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={};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
+ 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};
@@ -3,4 +3,4 @@ export * from './add-compiler-to-dev-server.js';
3
3
  export * from './create-dev-server.js';
4
4
  export * from './create-app-page-route.js';
5
5
  export * from './create-dev-server-entries.js';
6
- export * from './create-dev-server-compiler-tasks.js';
6
+ export * from './create-dev-server-compiler-task.js';
@@ -1 +1 @@
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
+ 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-task.js";
@@ -1 +1 @@
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
+ 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"),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 +1 @@
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)};
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{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)};
@@ -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 group entry map once `serve`,`build` recycle.
5
+ * @returns
6
+ */
7
+ export declare const assertGroupEntryItem: (entryMap: EvolveEntryMap, evolveOptions: FlatEvolveOptions) => EntryMapItem[];
@@ -0,0 +1 @@
1
+ import{normalizeEvolveEntryName}from"./normalize-entry-map.js";export const assertGroupEntryItem=(r,e)=>{const o=[];for(const[e,t]of Object.entries(r))o.push([e,t]);if(!o.length)throw new Error('No entry map found while "serve", "build" process!');return o.map((([r,o])=>[normalizeEvolveEntryName(r,e.projectVirtualPath),o]))};
@@ -0,0 +1,15 @@
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
+ * Asserts a single compiler configuration by generating a new entry object based on the served entries,
6
+ * webpack configuration, evolve options, and enabled HMR flag.
7
+ *
8
+ * @param servedEntries - The served entries object.
9
+ * @param webpackConfig `Omit<Configuration, 'entry'>` webpack final configuration
10
+ * @param evolveOptions - The flat evolve options object.
11
+ * @param enabledHmr - Flag indicating whether Hot Module Replacement (HMR) is enabled. Default is false.
12
+ * @returns The merged webpack configuration object with the new entry object.
13
+ * @throws Error if the react-refresh-webpack-plugin package directory is not found.
14
+ */
15
+ export declare function assertSingleCompiler(servedEntries: EvolveEntryMap, webpackConfig: Omit<Configuration, 'entry'>, evolveOptions: FlatEvolveOptions, enabledHmr?: boolean): Configuration;
@@ -0,0 +1 @@
1
+ import{dirname,join}from"path";import{searchPackageDir}from"@armit/package";import{mergeOptions,requireResolve}from"@flatjs/common";import{devReactFastRefresh}from"../constants.js";import{normalizeEvolveEntryName}from"./normalize-entry-map.js";export function assertSingleCompiler(e,r,t,o=!1){const a={};for(const[r,n]of Object.entries(e)){const e=normalizeEvolveEntryName(r,t.projectVirtualPath);if(a[e]=n.entry,o){const r=join(e,devReactFastRefresh.reactRefreshSetup),t=requireResolve(import.meta.url,"@pmmmwh/react-refresh-webpack-plugin"),o=searchPackageDir({cwd:dirname(t)});if(!o)throw new Error("react-refresh-webpack-plugin package directory not found");a[r]=[join(o,"/client/ReactRefreshEntry.js")]}}const n=Object.values(e)[0].groupName;return mergeOptions(r,{name:n,entry:a})}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Deletes specified keys from an object and returns a new object without those keys.
3
+ * If the input object is undefined, the function returns undefined.
4
+ *
5
+ * @param obj - The input object.
6
+ * @param keys - An array of keys to be deleted from the object.
7
+ * @returns A new object without the specified keys, or undefined if the input object is undefined.
8
+ *
9
+ * @template T - The type of the input object.
10
+ */
11
+ export declare const deleteObjectKeys: <T>(obj?: T, keys?: Array<keyof T>) => Partial<T> | undefined;
@@ -0,0 +1 @@
1
+ export const deleteObjectKeys=(e,t=[])=>{if(!e)return;const r={...e};return t.forEach((e=>{delete r[e]})),r};
@@ -0,0 +1,8 @@
1
+ import { type EvolveDevServerEntryMap } from '../dev-server/middlewares/types.js';
2
+ /**
3
+ * Flattens an array of `EvolveDevServerEntryMap` objects into a single `EvolveDevServerEntryMap`.
4
+ *
5
+ * @param servedDevServerEntryList - The array of `EvolveDevServerEntryMap` objects to flatten.
6
+ * @returns The flattened `EvolveDevServerEntryMap`.
7
+ */
8
+ export declare const flatEntryMap: (servedDevServerEntryList: Array<EvolveDevServerEntryMap>) => EvolveDevServerEntryMap;
@@ -0,0 +1 @@
1
+ export const flatEntryMap=t=>t.reduce(((t,e)=>Object.assign(t,e)),{});
@@ -0,0 +1,2 @@
1
+ import type { EvolveMultiCDNEnvResolver, EvolveMultiCDNConfig } from '../types/types-multi-html.js';
2
+ export declare const getRuntimeCDNBase: (config: EvolveMultiCDNConfig, cdnResolver: EvolveMultiCDNEnvResolver, requireFn?: string) => string;
@@ -0,0 +1 @@
1
+ import{cdnFinder}from"./script-injects.js";export const getRuntimeCDNBase=(n,e,i="")=>{const t=[`\n (function () {\n var flatjsMultiCdn = {\n cdnConfig: ${JSON.stringify(n||{})},\n cdnResolver: ${e.toString()},\n cdnFinder: ${cdnFinder.toString()}\n };\n var runtimeCDNBase = flatjsMultiCdn.cdnFinder(flatjsMultiCdn.cdnConfig, flatjsMultiCdn.cdnResolver);\n window.$evolve = window.$evolve || {};\n window.$evolve.runtimeCDNBase=runtimeCDNBase;\n `];return i&&t.push(`${i} = runtimeCDNBase || ${i};`),t.push("})();"),t.join("\n")};
@@ -1,10 +1,11 @@
1
1
  export * from './allow-px2rem-for-module.js';
2
- export * from './assert-only-single-entry-item.js';
2
+ export * from './assert-group-entry-item.js';
3
3
  export * from './chunk-entry-map.js';
4
4
  export * from './enable-bundle-hashname-for-module.js';
5
5
  export * from './get-bundle-file-name.js';
6
6
  export * from './get-html-plugin-config.js';
7
7
  export * from './get-pacakge-dir.js';
8
+ export * from './get-runtime-cdn-base.js';
8
9
  export * from './merge-babel-options.js';
9
10
  export * from './normalize-entry-map.js';
10
11
  export * from './open-page.js';
@@ -12,6 +13,15 @@ export * from './print-log.js';
12
13
  export * from './refresh-evolve-mock-options.js';
13
14
  export * from './script-injects.js';
14
15
  export * from './should-enable-react-fast-refresh.js';
15
- export * from './split-to-multi-compiler.js';
16
16
  export * from './json-serializer.js';
17
17
  export * from './normalize-resolve-alias.js';
18
+ export * from './is-deep-equal.js';
19
+ export * from './verify-group-entry-options.js';
20
+ export * from './split-to-entry-group.js';
21
+ export * from './delete-object-keys.js';
22
+ export * from './normalize-page-proxy.js';
23
+ export * from './flat-entry-map.js';
24
+ export * from './normalize-template-inject-tokens.js';
25
+ export * from './normalize-check-entry-options.js';
26
+ export * from './assert-single-compiler.js';
27
+ export * from './normalize-group-name.js';
@@ -1 +1 @@
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
+ export*from"./allow-px2rem-for-module.js";export*from"./assert-group-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"./get-runtime-cdn-base.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"./json-serializer.js";export*from"./normalize-resolve-alias.js";export*from"./is-deep-equal.js";export*from"./verify-group-entry-options.js";export*from"./split-to-entry-group.js";export*from"./delete-object-keys.js";export*from"./normalize-page-proxy.js";export*from"./flat-entry-map.js";export*from"./normalize-template-inject-tokens.js";export*from"./normalize-check-entry-options.js";export*from"./assert-single-compiler.js";export*from"./normalize-group-name.js";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Checks if two values are deeply equal.
3
+ *
4
+ * @template T - The type of the values being compared.
5
+ * @param a - The first value to compare.
6
+ * @param b - The second value to compare.
7
+ * @returns `true` if the values are deeply equal, `false` otherwise.
8
+ */
9
+ export declare function isDeepEqual(a: any, b: any): boolean;
@@ -0,0 +1 @@
1
+ export function isDeepEqual(t,e){if(t===e)return!0;if("function"==typeof t&&"function"==typeof e)return t.toString()===e.toString();if(t&&e&&"object"==typeof t&&"object"==typeof e){const r=Array.isArray(t),n=Array.isArray(e);let i,f,o;if(r&&n){if(f=t.length,f!==e.length)return!1;for(i=f;0!=i--;)if(!isDeepEqual(t[i],e[i]))return!1;return!0}if(r!==n)return!1;const u=t instanceof Date,c=e instanceof Date;if(u!==c)return!1;if(u&&c)return t.getTime()===e.getTime();const s=t instanceof RegExp,a=e instanceof RegExp;if(s!==a)return!1;if(s&&a)return t.toString()===e.toString();const p=Object.keys(t);if(f=p.length,f!==Object.keys(e).length)return!1;for(i=f;0!=i--;)if(!Object.prototype.hasOwnProperty.call(e,p[i]))return!1;for(i=f;0!=i--;)if(o=p[i],!isDeepEqual(t[o],e[o]))return!1;return!0}return t!=t&&e!=e}
@@ -0,0 +1,10 @@
1
+ import { type EvolveEntryItemOption } from '../types/types-entry-map.js';
2
+ /**
3
+ * Normalizes the check entry options.
4
+ *
5
+ * @param serveMode - A boolean indicating whether the serve mode is enabled.
6
+ * @param currEntryOption - The current entry option.
7
+ * @param ignoreOptionKeys - An array of keys to ignore in the entry option.
8
+ * @returns The normalized entry options.
9
+ */
10
+ export declare const normalizeCheckEntryOptions: (serveMode: boolean, currEntryOption?: EvolveEntryItemOption, ignoreOptionKeys?: Array<keyof EvolveEntryItemOption>) => Partial<EvolveEntryItemOption> | undefined;
@@ -0,0 +1 @@
1
+ import{urlJoin}from"@flatjs/common";import{ignoreEntryOptionKeys}from"../constants.js";import{deleteObjectKeys}from"./delete-object-keys.js";import{normalizeTemplateInjectTokens}from"./normalize-template-inject-tokens.js";export const normalizeCheckEntryOptions=(e,t,o=ignoreEntryOptionKeys)=>{const n={mode:e?"development":"production",envCdn:urlJoin(e?"http://dev.flatjs.com":"https://file.40017.cn/jinfu",["public"])},r=normalizeTemplateInjectTokens(n,t),i={...t,...r};return deleteObjectKeys(i,o)};
@@ -11,5 +11,6 @@ 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`
14
15
  */
15
16
  export declare const normalizeEvolveEntryMap: (activedEntryMap?: EvolveEntryMap, definedEntryMap?: EvolveEntryMap) => EvolveEntryMap;
@@ -1 +1 @@
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
+ import{join}from"node:path";import _ from"lodash";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};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Normalizes the group name based on the project virtual path and index.
3
+ *
4
+ * @param projectVirtualPath - The virtual path of the project.
5
+ * @param index - The index used to generate the group name.
6
+ * @returns The normalized group name.
7
+ */
8
+ export declare const normalizeGroupName: (projectVirtualPath: string, index: number) => string;
@@ -0,0 +1 @@
1
+ import{normalizeEvolveEntryName}from"./normalize-entry-map.js";export const normalizeGroupName=(r,o)=>{const e=Array.from({length:26},((r,o)=>String.fromCharCode(65+o))),m=[...Array.from({length:26},((r,o)=>String.fromCharCode(97+o))),...e],n=Math.floor(o/52);return normalizeEvolveEntryName(`${m[o%52]}${n||""}`,r)};
@@ -0,0 +1,16 @@
1
+ import { type EvolveEntryItemOption } from '../types/types-entry-map.js';
2
+ import { type HtmlPluginConfigConfigData } from './get-html-plugin-config.js';
3
+ /**
4
+ * Normalizes the template inject tokens based on the provided configuration data and entry options.
5
+ *
6
+ * @param configData - The configuration data for the HTML plugin.
7
+ * @param currEntryOption - The current entry option for the evolve item.
8
+ * @returns An object containing the normalized template inject tokens.
9
+ */
10
+ export declare const normalizeTemplateInjectTokens: (configData: HtmlPluginConfigConfigData, currEntryOption?: EvolveEntryItemOption) => {
11
+ headBeforeHtmlTags?: string[];
12
+ inlineScripts?: string[];
13
+ headBeforeStyles?: string[];
14
+ headBeforeScripts: string[];
15
+ bodyAfterScripts: string[];
16
+ };
@@ -0,0 +1 @@
1
+ import{getHtmlPluginConfig}from"./get-html-plugin-config.js";export const normalizeTemplateInjectTokens=(e,t)=>({headBeforeHtmlTags:getHtmlPluginConfig("headBeforeHtmlTags",e,t?.headBeforeHtmlTags),inlineScripts:getHtmlPluginConfig("inlineScripts",e,t?.inlineScripts),headBeforeStyles:getHtmlPluginConfig("headBeforeStyles",e,t?.headBeforeStyles),headBeforeScripts:getHtmlPluginConfig("headBeforeScripts",e,t?.headBeforeScripts),bodyAfterScripts:getHtmlPluginConfig("bodyAfterScripts",e,t?.bodyAfterScripts)});
@@ -1 +1 @@
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};
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};
@@ -0,0 +1,53 @@
1
+ import { type EvolveEntryMapContent, type EvolveEntryItemOption, type EvolveEntryMap } from '../types/types-entry-map.js';
2
+ import { type FlatEvolveOptions } from '../types/types-options.js';
3
+ /**
4
+ * Groups the manual entries based on their group names.
5
+ * @param manualEntries - The map of manual entries.
6
+ * @returns An array of grouped manual entries.
7
+ */
8
+ export declare const manualGrouping: (manualEntries: (EvolveEntryMapContent & {
9
+ entryName: string;
10
+ })[]) => Array<EvolveEntryMap>;
11
+ /**
12
+ * Reduces an array of autoEntries into groups based on their options.
13
+ * Each group is represented by a groupKey and contains an EvolveEntryMap.
14
+ *
15
+ * @param evolveOptions - The FlatEvolveOptions object.
16
+ * @param autoEntries - An array of EvolveEntryMapContent objects with an additional entryName property.
17
+ * @param ignoreOptionKeys - An array of keys to ignore when comparing entry options.
18
+ * @param serveMode - A boolean indicating whether the function is running in serve mode.
19
+ * @returns An object where each key represents a groupKey and its value is an EvolveEntryMap.
20
+ */
21
+ export declare const autoGroupingReduce: (autoEntries: (EvolveEntryMapContent & {
22
+ entryName: string;
23
+ })[], ignoreOptionKeys: (keyof EvolveEntryItemOption)[] | undefined, serveMode: boolean) => Record<string, EvolveEntryMap>;
24
+ /**
25
+ * Assigns a group name to each entry in the evolveEntryMapList based on the projectVirtualPath.
26
+ *
27
+ * @param evolveOptions - The options for the evolve process.
28
+ * @param evolveEntryMapList - The list of evolve entry maps.
29
+ * @returns The updated list of evolve entry maps with group names assigned.
30
+ */
31
+ export declare const autoAssignGroupName: (evolveOptions: FlatEvolveOptions, evolveEntryMapList: Array<EvolveEntryMap>) => Array<EvolveEntryMap>;
32
+ /**
33
+ * Groups the given autoEntries into multiple EvolveEntryMap based on their options.
34
+ * If the group size exceeds the maximum group size, it will be sliced into smaller groups.
35
+ *
36
+ * @param evolveOptions - The FlatEvolveOptions object.
37
+ * @param autoEntries - An array of EvolveEntryMapContent objects with an additional entryName property.
38
+ * @param ignoreOptionKeys - An array of keys to ignore in the EvolveEntryItemOption object.
39
+ * @param maxGroupSize - The maximum size of each group. Defaults to maxEntryGroupSize.
40
+ * @param serveMode - A boolean indicating whether the serve mode is enabled.
41
+ * @returns An array of EvolveEntryMap representing the grouped entries.
42
+ */
43
+ export declare const autoGrouping: (evolveOptions: FlatEvolveOptions, autoEntries: (EvolveEntryMapContent & {
44
+ entryName: string;
45
+ })[], ignoreOptionKeys: (keyof EvolveEntryItemOption)[] | undefined, maxGroupSize: number | undefined, serveMode: boolean) => Array<EvolveEntryMap>;
46
+ /**
47
+ * Splits the served entries into groups based on the given options.
48
+ *
49
+ * @param evolveEntries - The map of served entries.
50
+ * @param ignoreOptionKeys - The list of option keys to ignore.
51
+ * @returns An array of evolve entry maps representing the groups.
52
+ */
53
+ export declare const splitToEntryGroup: (evolveEntries: EvolveEntryMap, evolveOptions: FlatEvolveOptions, ignoreOptionKeys: (keyof EvolveEntryItemOption)[] | undefined, serveMode: boolean) => Array<EvolveEntryMap>;
@@ -0,0 +1 @@
1
+ import _ from"lodash";import{ignoreEntryOptionKeys,maxEntryGroupSize}from"../constants.js";import{isDeepEqual}from"./is-deep-equal.js";import{normalizeCheckEntryOptions}from"./normalize-check-entry-options.js";import{normalizeGroupName}from"./normalize-group-name.js";export const manualGrouping=o=>{const e=_.groupBy(o,(o=>o.groupName)),t=[];for(const[,o]of Object.entries(e)){const e=o.reduce(((o,e)=>(o[e.entryName]=_.omitBy(e,"entryName"),o)),{});t.push(e)}return t};export const autoGroupingReduce=(o,e=[],t)=>_.reduce(o,((o,r,n)=>{let s=`auto_grouping_reduce-${n}`;const u=normalizeCheckEntryOptions(t,r.options,e);for(const[r,n]of Object.entries(o)){const o=Object.values(n)[0],i=normalizeCheckEntryOptions(t,o.options,e);if(isDeepEqual(u,i)){s=r;break}}return o[s]=_.merge(o[s],{[r.entryName]:_.omitBy(r,"entryName")}),o}),{});export const autoAssignGroupName=(o,e)=>{const{projectVirtualPath:t}=o,r=[];let n=0;for(const o of e){const e={},s=normalizeGroupName(t,n++);for(const[t,r]of Object.entries(o))r.groupName=s,e[t]=r;r.push(e)}return r};export const autoGrouping=(o,e,t=[],r=maxEntryGroupSize,n)=>{const s=autoGroupingReduce(e,t,n),u=[];for(const[,o]of Object.entries(s)){const e=Object.keys(o);if(e.length>r)for(let t=0;t<e.length;t+=r){const n=e.slice(t,t+r).reduce(((e,t)=>(e[t]=o[t],e)),{});u.push(n)}else u.push(o)}return autoAssignGroupName(o,u)};export const splitToEntryGroup=(o,e,t=ignoreEntryOptionKeys,r)=>{const{isolation:n=!1}=e;if(n){const e=[];for(const[t,r]of Object.entries(o))r.groupName=t,e.push({[t]:r});return e}const s=_.flatMap(o,((o,e)=>({...o,entryName:e}))),u=_.groupBy(s,(o=>o.groupingSource));return[...manualGrouping(u.manual),...autoGrouping(e,u.auto,t,maxEntryGroupSize,r)]};
@@ -0,0 +1,9 @@
1
+ import { type EvolveEntryItemOption, type EvolveEntryMap } from '../types/types-entry-map.js';
2
+ /**
3
+ * Verifies if the options of all entries in a group are equal, excluding specified keys.
4
+ *
5
+ * @param groupEvolveEntryMap - The map of group entries.
6
+ * @param ignoreOptionKeys - The keys to be ignored when comparing options.
7
+ * @returns A boolean indicating if the options of all entries are equal.
8
+ */
9
+ export declare const verifyGroupEntryOptions: (groupEvolveEntryMap: EvolveEntryMap, ignoreOptionKeys: (keyof EvolveEntryItemOption)[] | undefined, serveMode: boolean) => boolean;
@@ -0,0 +1 @@
1
+ import{ignoreEntryOptionKeys}from"../constants.js";import{isDeepEqual}from"./is-deep-equal.js";import{normalizeCheckEntryOptions}from"./normalize-check-entry-options.js";export const verifyGroupEntryOptions=(n,o=ignoreEntryOptionKeys,t)=>{const e=Object.values(n);if(1===e.length)return!0;const r=e.shift(),i=normalizeCheckEntryOptions(t,r?.options,o);return e.every((n=>isDeepEqual(i,normalizeCheckEntryOptions(t,n.options,o))))};
@@ -1,16 +1,31 @@
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;
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;
8
7
  }
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
- })>;
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]): Promise<import("./start-group-entry-build.js").EvolveBuildResult>;
28
+ terminate(): void;
29
+ }
30
+ export declare const createThreadWorker: (options?: ThreadsOptions) => ThreadPoolForUnittest | ThreadPoolForTinyPool;
16
31
  export {};
@@ -1 +1 @@
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
+ import Tinypool from"tinypool";import{getWorkerPath}from"./get-worker-path.js";import startBuildWorker from"./start-build-worker.js";class ThreadPoolForUnittest{startBuildWorker(r){return startBuildWorker(r)}terminate(){console.warn('[WARNING] Using fake "terminate" for unittest!')}}class ThreadPoolForTinyPool{constructor(r,o){const{runtime:e="worker_threads",idleTimeout:t=6e4,minThreads:n=1,maxThreads:s}=o||{};this.pool=new Tinypool({filename:r,minThreads:n,maxThreads:s,runtime:e,idleTimeout:t})}startBuildWorker(r){return this.pool.run(r)}terminate(){this.pool.destroy()}}export const createThreadWorker=r=>{const o=getWorkerPath();return"test"===process.env.NODE_ENV?(console.warn("[WARNING] Using fake thread pool worker for unittest!"),new ThreadPoolForUnittest):new ThreadPoolForTinyPool(o,r)};
@@ -1,9 +1,9 @@
1
- import { type EntryMapItem } from '../types/types-entry-map.js';
1
+ import { type EvolveEntryMap } from '../types/types-entry-map.js';
2
2
  import { type FlatEvolveOptions } from '../types/types-options.js';
3
- import { type EvolveBuildResult } from './start-one-entry-build.js';
3
+ import { type EvolveBuildResult } from './start-group-entry-build.js';
4
4
  /**
5
5
  * The main entry to start an evolve `build`
6
6
  * @param entryMapItem The `entryMapItem` for one entry build task
7
7
  * @param evolveOptions FlatEvolveOptions
8
8
  */
9
- export declare const prepareBuild: (entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => Promise<EvolveBuildResult>;
9
+ export declare const prepareBuild: (groupEntries: EvolveEntryMap, evolveOptions: FlatEvolveOptions) => Promise<EvolveBuildResult>;
@@ -1 +1 @@
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)}};
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)=>{const t=Object.values(r)[0];if(!verifyGroupEntryOptions(r,ignoreEntryOptionKeys,!0))throw new Error("The entry options in a group must be the same.");const e=o.multiHtmlCdn?.prod||[];if(!e.length)throw new Error(`No CDN config for env:"prod", groupName: ${t.groupName}`);const n=ensureSlash(e[Math.floor(Math.random()*e.length)],!0);try{const e=t.options?.useRelativeAssetPath,i=mergeOptions(o,{webpack:{publicPath:e?"auto":n}});return await startGroupEntryBuild(r,i)}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>;
9
+ export declare const prepareServe: (projectCwd: string, servedEntries: EvolveEntryMap, evolveOptions: FlatEvolveOptions) => Promise<import("express-serve-static-core").Express | undefined>;
@@ -1 +1 @@
1
- import{arrayUnique,urlJoin}from"@flatjs/common";import{attachMockMiddlewares}from"@flatjs/mock";import{createAppPageRoute,createDevServer,createDevServerCompilerTasks,createDevServerEntries}from"../dev-server/index.js";import{openPage}from"../helpers/index.js";import{normalizePageProxy}from"../helpers/normalize-page-proxy.js";import{envVerify}from"./env-verify.js";export const prepareServe=async(e,r,o)=>{await envVerify(e,o);const{app:t,devPort:a,devHostUri:i,publicIp:s}=await createDevServer(o),p=o.devServer?.mockOptions?.mockFilters||[];for(const[,e]of Object.entries(r))p.push(...e.options?.mockFilters||[]);await attachMockMiddlewares(t,{...o.devServer?.mockOptions,mockFilters:arrayUnique(p),projectCwd:e});const n=await createDevServerEntries(a,r,o);createAppPageRoute(e,t,i,n,o);const c=normalizePageProxy(o.devServer?.pageProxy||"/pages"),v=urlJoin(i,[c]);o.devServer?.autoOpen&&openPage(v);const m=await createDevServerCompilerTasks(e,v,s,n,o);return Promise.all(m).then((()=>t))};
1
+ import{arrayUnique,logger,urlJoin}from"@flatjs/common";import{attachMockMiddlewares}from"@flatjs/mock";import{ignoreEntryOptionKeys}from"../constants.js";import{createAppPageRoute,createDevServer,createDevServerCompilerTask,createDevServerEntries}from"../dev-server/index.js";import{flatEntryMap,openPage}from"../helpers/index.js";import{normalizePageProxy}from"../helpers/normalize-page-proxy.js";import{splitToEntryGroup}from"../helpers/split-to-entry-group.js";import{verifyGroupEntryOptions}from"../helpers/verify-group-entry-options.js";import{envVerify}from"./env-verify.js";export const prepareServe=async(e,r,o)=>{await envVerify(e,o);const t=splitToEntryGroup(r,o,ignoreEntryOptionKeys,!0);if(!t.length)return void logger.warn("No served entries provided!");const n=[],{app:i,devPort:s,devHostUri:p,publicIp:a}=await createDevServer(o),c=o.devServer?.mockOptions?.mockFilters||[];for(const[,e]of Object.entries(r))c.push(...e.options?.mockFilters||[]);await attachMockMiddlewares(i,{...o.devServer?.mockOptions,mockFilters:arrayUnique(c),projectCwd:e});let v=s;const m=[];for(const e of t){if(!verifyGroupEntryOptions(e,ignoreEntryOptionKeys,!0))throw new Error("The entry options in a group must be the same.");v++;const r=await createDevServerEntries(v,e,o);m.push(r)}const l=flatEntryMap(m);createAppPageRoute(e,i,p,l,o);const y=normalizePageProxy(o.devServer?.pageProxy||"/pages"),f=urlJoin(p,[y]);o.devServer?.autoOpen&&openPage(f);for(const r of m){const t=createDevServerCompilerTask(e,f,a,r,m,o);n.push(t)}return Promise.all(n).then((()=>i))};
@@ -1,14 +1,14 @@
1
1
  import { type PartialDeep } from 'type-fest';
2
2
  import { type ConfigLoaderOptions } from '../load-config/types.js';
3
3
  import { type FlatEvolveOptions } from '../types/types-options.js';
4
- import { type EvolveBuildResult } from './start-one-entry-build.js';
4
+ import { type EvolveBuildResult } from './start-group-entry-build.js';
5
5
  export declare function getBuildEntryFiles(projectCwd: string, diffFiles: string[], allEntryInputs: string[], resolveAlias?: Record<string, string>, graphTreeNodeFilter?: (moduleId: string) => boolean): Promise<string[]>;
6
6
  /**
7
7
  * Dynamic check which entry modules need to build.
8
8
  * @returns
9
9
  */
10
10
  export declare function dynamicCheckBuildEntryMap(projectCwd: string, earlyCommit?: string | null, lastCommit?: string, overrideEvolveOptions?: PartialDeep<FlatEvolveOptions>, configLoaderOptions?: ConfigLoaderOptions): Promise<{
11
- buildEntries: import("src/index.js").EvolveEntryMap;
11
+ buildEntries: import("../index.js").EvolveEntryMap;
12
12
  newEvolveOptions: FlatEvolveOptions;
13
13
  }>;
14
14
  /**