@flatjs/evolve 2.3.2-next.2 → 2.3.2-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.d.ts +7 -0
- package/dist/constants.js +1 -1
- package/dist/core/rspack/create-plugins.js +1 -1
- package/dist/helpers/custom-listr-renderer.js +1 -1
- package/dist/helpers/custom-message-channel.d.ts +17 -0
- package/dist/helpers/custom-message-channel.js +1 -0
- package/dist/main/create-thread-worker.d.ts +31 -0
- package/dist/main/create-thread-worker.js +1 -0
- package/dist/main/get-worker-path.d.ts +1 -0
- package/dist/main/get-worker-path.js +1 -0
- package/dist/main/start-build-dynamic.d.ts +2 -1
- package/dist/main/start-build-dynamic.js +1 -1
- package/dist/main/start-build-worker.js +1 -1
- package/dist/main/start-build.js +1 -1
- package/dist/plugins/rspack/progress-plugin/index.d.ts +4 -0
- package/dist/plugins/rspack/progress-plugin/index.js +1 -0
- package/dist/plugins/rspack/progress-plugin/progress-handler.d.ts +3 -0
- package/dist/plugins/rspack/progress-plugin/progress-handler.js +1 -0
- package/dist/plugins/rspack/progress-plugin/progress-worker.d.ts +7 -0
- package/dist/plugins/rspack/progress-plugin/progress-worker.js +1 -0
- package/dist/plugins/webpack/clean-webpack/clean-webpack-plugin.js +1 -1
- package/dist/rules/rspack/rule-scripts.js +1 -1
- package/package.json +6 -4
package/dist/constants.d.ts
CHANGED
@@ -31,3 +31,10 @@ export declare const ignoreEntryOptionKeys: Array<keyof EvolveEntryItemOption>;
|
|
31
31
|
* The directory where the webpack stats files are stored. relative to projectCwd
|
32
32
|
*/
|
33
33
|
export declare const webpackStatsDir = ".cache/stats";
|
34
|
+
/**
|
35
|
+
* The spinner frames used for build progress indicator
|
36
|
+
* Different frames for Windows and Unix-like systems
|
37
|
+
* Windows: simple ASCII characters
|
38
|
+
* Unix: Braille patterns for smoother animation
|
39
|
+
*/
|
40
|
+
export declare const buildProgressSpinnerFrames: string[];
|
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
|
+
import process from"node:process";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";export const buildProgressSpinnerFrames="win32"===process.platform?["-","\\","|","/"]:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];
|
@@ -1 +1 @@
|
|
1
|
-
import CaseSensitivePathsPlugin from"case-sensitive-paths-webpack-plugin";import{logger}from"@flatjs/common";import{RsdoctorRspackPlugin}from"@rsdoctor/rspack-plugin";import rspack,{CssExtractRspackPlugin}from"@rspack/core";import ReactRefreshPlugin from"@rspack/plugin-react-refresh";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{createBuiltinDefineVariablesRspackPlugins}from"../../plugins/rspack/define-variable/index.js";import{createModuleFederationRspackPlugins}from"../../plugins/rspack/module-federation/index.js";import{createHtmlRspackPlugins}from"../../plugins/rspack/multi-html/index.js";import{createCircularDependencyWebpackPlugins}from"../../plugins/webpack/circular-dependency/index.js";import{createCleanWebpackPlugins}from"../../plugins/webpack/clean-webpack/index.js";import{createStatsWebpackPlugins}from"../../plugins/webpack/stats-webpack/index.js";export const createRspackPlugins=async(e,a,
|
1
|
+
import CaseSensitivePathsPlugin from"case-sensitive-paths-webpack-plugin";import{logger}from"@flatjs/common";import{RsdoctorRspackPlugin}from"@rsdoctor/rspack-plugin";import rspack,{CssExtractRspackPlugin}from"@rspack/core";import ReactRefreshPlugin from"@rspack/plugin-react-refresh";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{createBuiltinDefineVariablesRspackPlugins}from"../../plugins/rspack/define-variable/index.js";import{createModuleFederationRspackPlugins}from"../../plugins/rspack/module-federation/index.js";import{createHtmlRspackPlugins}from"../../plugins/rspack/multi-html/index.js";import{createProgressRspackPlugins}from"../../plugins/rspack/progress-plugin/index.js";import{createCircularDependencyWebpackPlugins}from"../../plugins/webpack/circular-dependency/index.js";import{createCleanWebpackPlugins}from"../../plugins/webpack/clean-webpack/index.js";import{createStatsWebpackPlugins}from"../../plugins/webpack/stats-webpack/index.js";export const createRspackPlugins=async(e,s,a,r)=>{const n=s[0],[i,l]=n,c=enableBundleHashNameForModule(a,l?.options),t=[...createProgressRspackPlugins(s),new rspack.IgnorePlugin({resourceRegExp:/\.d\.[cm]ts$/}),new CaseSensitivePathsPlugin,...createCircularDependencyWebpackPlugins(e,a),new CssExtractRspackPlugin({filename:`[name]/${getBundleFileName("css",e,c)}`,chunkFilename:c?"[id].[contenthash].css":"[id].css"}),...await createBuiltinDefineVariablesRspackPlugins(e,a),...createCleanWebpackPlugins(e,s,a),...createModuleFederationRspackPlugins(e,s,a),...createHtmlRspackPlugins(e,s,a),...createStatsWebpackPlugins(e,a,r)],o=shouldEnableReactFastRefresh(e,n,a);o&&t.push(new ReactRefreshPlugin({overlay:!1,exclude:[/node_modules/]})),!o&&e&&(a.devServer?.liveReload?logger.warn('The HMR disabled cause of "liveReload" specificed'):logger.warn(`The HMR disabled cause of \`"moduleFederation":"${i}"\``)),a.openRsdoctor&&t.push(new RsdoctorRspackPlugin);const p=a.webpack?.plugins||[];return t.concat(p)};
|
@@ -1 +1 @@
|
|
1
|
-
import logUpdate from"log-update";import
|
1
|
+
import logUpdate from"log-update";import{chalk,loggerSimpleStdWriteSteam}from"@flatjs/common";import{buildProgressSpinnerFrames}from"../constants.js";import{formatSpinnerText}from"./format-spinner-text.js";let startIndex=0;export class CustomListrRenderer{constructor(e){this._tasks=[],this.renderTask=()=>{const e=[];startIndex=++startIndex%buildProgressSpinnerFrames.length;const t=buildProgressSpinnerFrames[startIndex];for(const r of this._tasks){const s=r.title.split("$ENTRY_KEYS")||[],i=s[1]||"",o=i?i.split(","):[];r.isCompleted()?e.push(`${chalk(["green"])("✔")} ${this.formatTextByTemp(s[0],"successfully")} \n${formatSpinnerText(o,"✔","green")}`):r.hasFailed()?e.push(`${chalk(["red"])("✘")} ${this.formatTextByTemp(s[0],"failed")} \n${formatSpinnerText(o,"✘","red")}`):r.isSkipped()?e.push(`${chalk(["gray"])("ℹ")} ${this.formatTextByTemp(s[0],"skipped")} \n${formatSpinnerText(o,"ℹ","gray")}`):e.push(`${chalk(["cyan"])(t)} ${this.formatTextByTemp(s[0],"building")} \n${formatSpinnerText(o)}`)}logUpdate(e.join("\n"))},this._tasks=e}static get nonTTY(){return!0}render(){this._id||(this._id=setInterval((()=>{this.renderTask()}),100))}end(){this._id&&(clearInterval(this._id),this._id=void 0),this.renderTask(),logUpdate.done(),this.printMemoryLogs()}formatTextByTemp(e,t,r="$STATUS"){const s={successfully:`${chalk(["green"])("done")}`,failed:`builded ${chalk(["red"])("failed")}`,skipped:`builded ${chalk(["gray"])("skipped")}`,building:chalk(["white"])("compiling...")};return e.replace(r,s[t])}printMemoryLogs(){const{stderr:e=[],stdout:t=[]}=loggerSimpleStdWriteSteam.getStdData();for(const t of e)console.error(t);for(const e of t)console.log(e)}}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { MessageChannel } from 'node:worker_threads';
|
2
|
+
declare class CustomMessageChannel {
|
3
|
+
private stdoutData;
|
4
|
+
private stderrData;
|
5
|
+
private channelList;
|
6
|
+
constructor();
|
7
|
+
createMessageChannel(): MessageChannel;
|
8
|
+
addListener(channel: MessageChannel): void;
|
9
|
+
getStdData(): {
|
10
|
+
stdout: string[];
|
11
|
+
stderr: string[];
|
12
|
+
};
|
13
|
+
dispose(): void;
|
14
|
+
clean(): void;
|
15
|
+
}
|
16
|
+
export declare const customMessageChannel: CustomMessageChannel;
|
17
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
import{MessageChannel}from"node:worker_threads";class CustomMessageChannel{constructor(){this.stdoutData=[],this.stderrData=[],this.channelList=[],this.clean()}createMessageChannel(){const s=new MessageChannel;return this.channelList.push(s),this.addListener(s),s}addListener(s){const{port2:t}=s;t.on("message",(s=>{this.stdoutData.push(...s.stdout),this.stderrData.push(...s.stderr)}))}getStdData(){return{stdout:this.stdoutData,stderr:this.stderrData}}dispose(){for(const s of this.channelList){const{port1:t,port2:e}=s;t.close(),e.close(),e.removeAllListeners("message")}this.channelList=[]}clean(){this.stdoutData=[],this.stderrData=[]}}export const customMessageChannel=new CustomMessageChannel;
|
@@ -0,0 +1,31 @@
|
|
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;
|
7
|
+
}
|
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("../index.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;
|
31
|
+
export {};
|
@@ -0,0 +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)};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const getWorkerPath: () => string;
|
@@ -0,0 +1 @@
|
|
1
|
+
import{pathToFileURL}from"node:url";import{getDirname}from"@armit/file-utility";export const getWorkerPath=()=>pathToFileURL(getDirname(import.meta.url,"./start-build-worker.js")).toString();
|
@@ -2,6 +2,7 @@ import { type PartialDeep } from 'type-fest';
|
|
2
2
|
import { type ConfigLoaderOptions } from '../load-config/types.js';
|
3
3
|
import type { EvolveBuildResult } from '../types/types-build.js';
|
4
4
|
import type { FlatCliOptions } from '../types/types-cli-options.js';
|
5
|
+
import type { EvolveEntryMap } from '../types/types-entry-map.js';
|
5
6
|
import { type FlatEvolveOptions } from '../types/types-options.js';
|
6
7
|
export declare function getBuildEntryFiles(projectCwd: string, diffFiles: string[], allEntryInputs: string[], resolveAlias?: Record<string, string>, graphTreeNodeFilter?: (moduleId: string) => boolean): Promise<string[]>;
|
7
8
|
/**
|
@@ -9,7 +10,7 @@ export declare function getBuildEntryFiles(projectCwd: string, diffFiles: string
|
|
9
10
|
* @returns
|
10
11
|
*/
|
11
12
|
export declare function dynamicCheckBuildEntryMap(projectCwd: string, earlyCommit?: string | null, lastCommit?: string, overrideEvolveOptions?: PartialDeep<FlatEvolveOptions>, configLoaderOptions?: ConfigLoaderOptions): Promise<{
|
12
|
-
buildEntries:
|
13
|
+
buildEntries: EvolveEntryMap;
|
13
14
|
newEvolveOptions: FlatEvolveOptions;
|
14
15
|
}>;
|
15
16
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
import Listr from"listr";import{isAbsolute,join}from"node:path";import{getCommitIdOfBranch,getDiffFiles}from"@armit/git";import{arraysIntersect,chalk,logger,requireResolve
|
1
|
+
import Listr from"listr";import{isAbsolute,join}from"node:path";import{getCommitIdOfBranch,getDiffFiles}from"@armit/git";import{arraysIntersect,chalk,logger,requireResolve}from"@flatjs/common";import{traverseGraph}from"@flatjs/graph";import{createGlobalCompiler}from"../compiler/create-global-compiler.js";import{ignoreEntryOptionKeys,moduleName}from"../constants.js";import{isCI}from"../helpers/check-runtime-env.js";import{CustomListrRenderer}from"../helpers/custom-listr-renderer.js";import{filterActivedEntriesByEntryInputs,filterActivedEntriesByModule}from"../helpers/filter-actived-entries.js";import{getGitRoot}from"../helpers/get-git-root.js";import{getMaxProcessTasks}from"../helpers/get-max-process-tasks.js";import{jsonSerializer}from"../helpers/json-serializer.js";import{normalizeEvolveEntryMap}from"../helpers/normalize-entry-map.js";import{printPromotions}from"../helpers/print-promotion.js";import{resolveEntryMapInputFiles}from"../helpers/resolve-entry-map-input-files.js";import{splitToEntryGroup}from"../helpers/split-to-entry-group.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{createThreadWorker}from"./create-thread-worker.js";import{envVerify}from"./env-verify.js";import startBuildWorker from"./start-build-worker.js";const runWebpackTask=async(e,r,t,o,i,s={})=>{const{threads:n={}}=t,a=getMaxProcessTasks(r.length,n?.maxThreads);logger.info(`Start dynamic build with (${chalk(["magenta"])(String(a))}) workers`);const l=createThreadWorker({...n,maxThreads:a}),p=new Listr([],{concurrent:a,exitOnError:!0,renderer:isCI()?void 0:CustomListrRenderer}),c=[];for(const t of r){const r=Object.values(t)?.[0]?.groupName||"",n=Object.keys(t);let a=`Group ${chalk(["magenta"])(r)} $STATUS $ENTRY_KEYS${n.join(",")}`;isCI()&&(a=`Group ${chalk(["magenta"])(r)} compiling... $ENTRY_KEYS${n.join(",")}`),p.add({title:a,task:async()=>{const t=await l.startBuildWorker({projectCwd:e,entryKeys:n,serializedEvolveOptions:jsonSerializer.stringify(o),configLoaderOptions:i,groupName:r,cliOptions:s});c.push(t)}})}if(p.tasks.length)try{await p.run()}catch(e){throw l.terminate(),e}return l.terminate(),c},runRspackTask=async(e,r,t,o,i={})=>{const s=[];for(const n of r){const r=Object.values(n)?.[0]?.groupName||"",a=Object.keys(n),l=await startBuildWorker({projectCwd:e,entryKeys:a,serializedEvolveOptions:jsonSerializer.stringify(t),configLoaderOptions:o,groupName:r,cliOptions:i});s.push(l)}return s};export async function getBuildEntryFiles(e,r,t,o,i){const s=[],n=[];for(const e of t)r.includes(e)?s.push(e):n.push(e);if(i&&logger.info("Use custom graph traverse filter",moduleName),n.length){const t=await traverseGraph({input:n,projectCwd:e,treeNodeFilter:i||(()=>!0),lessImportOptions:{projectCwd:e,aliases:o}});if(!t)return s;logger.debug(`DependencyGraph:\n${JSON.stringify(t,null,2)}`);for(const e of n){const o=t[e]||[];arraysIntersect(o,r)&&s.push(e)}}return s}export async function dynamicCheckBuildEntryMap(e,r,t,o,i){const s={projectCwd:e,command:"build",resolve:requireResolve},n=await loadEvolveConfig(s,e,o,i);if(n.ci?.fixedBuildModules&&n.ci?.fixedBuildModules.length){logger.info("Use `fixedBuildModules` configuration to build...");return{buildEntries:filterActivedEntriesByModule(n.entryMap,n.ci?.fixedBuildModules),newEvolveOptions:n}}if(logger.info("Dynamicly checking code changed modules ..."),!r){const e=n.ci?.basedBranch||"origin/master";r=await getCommitIdOfBranch(e),logger.info(`Resolving base branch "${e}" commit hash "${r}" ...`)}logger.info(`diffCommits: \n${JSON.stringify({earlyCommit:r,lastCommit:t},null,2)}`,moduleName);let a=r?await getDiffFiles(r,t):[];const l=getGitRoot(e);if(!l)throw new Error(`No .git root (${e}) found`);if(a=a.map((e=>isAbsolute(e)?e:join(l,e))),logger.debug(`Diff files: \n${JSON.stringify(a,null,2)}`),!a.length)return logger.warn("It seems that there are no code files changed."),{buildEntries:{},newEvolveOptions:n};const p=await resolveEntryMapInputFiles(e,n.entryMap),c=await getBuildEntryFiles(e,a,p,n.webpack?.resolve?.alias,n.ci?.graphTreeNodeFilter);logger.debug(`To build entry files: \n${JSON.stringify(c,null,2)}`);return{buildEntries:await filterActivedEntriesByEntryInputs(e,n.entryMap,c),newEvolveOptions:n}}export const startDynamicBuild=async(e,r,t,o={},i,s={})=>{const{compilerType:n="webpack"}=s,{buildEntries:a,newEvolveOptions:l}=await dynamicCheckBuildEntryMap(e,r,t,o,i);printPromotions(s),await envVerify(e,l);const p=normalizeEvolveEntryMap(a,l.entryMap),c=splitToEntryGroup(p,l,ignoreEntryOptionKeys,!1);if(!c.length)return logger.warn("No build entries provided!"),[];await createGlobalCompiler(!1,l);let m=[];return"webpack"===n?m=await runWebpackTask(e,c,l,o,i,s):"rspack"===n&&(m=await runRspackTask(e,c,o,i,s)),m};
|
@@ -1 +1 @@
|
|
1
|
-
import{configLoggerStdWriteSteam,requireResolve}from"@flatjs/common";import{ignoreEntryOptionKeys}from"../constants.js";import{isCI}from"../helpers/check-runtime-env.js";import{filterActivedEntriesByModule}from"../helpers/filter-actived-entries.js";import{jsonSerializer}from"../helpers/json-serializer.js";import{normalizeEvolveEntryMap}from"../helpers/normalize-entry-map.js";import{splitToEntryGroup}from"../helpers/split-to-entry-group.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{prepareBuild}from"./prepare-build.js";export default async e=>{isCI()||configLoggerStdWriteSteam();const{projectCwd:
|
1
|
+
import{configLoggerStdWriteSteam,requireResolve}from"@flatjs/common";import{ignoreEntryOptionKeys}from"../constants.js";import{isCI}from"../helpers/check-runtime-env.js";import{filterActivedEntriesByModule}from"../helpers/filter-actived-entries.js";import{jsonSerializer}from"../helpers/json-serializer.js";import{normalizeEvolveEntryMap}from"../helpers/normalize-entry-map.js";import{splitToEntryGroup}from"../helpers/split-to-entry-group.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{prepareBuild}from"./prepare-build.js";export default async e=>{const{compilerType:r="webpack"}=e.cliOptions||{};isCI()||"webpack"!==r||configLoggerStdWriteSteam();const{projectCwd:o,entryKeys:i,serializedEvolveOptions:t,configLoaderOptions:p,groupName:n="flatjs_evolve_group",cliOptions:s}=e,l={projectCwd:o,command:"build",resolve:requireResolve},a=jsonSerializer.parse(t)||{},m=await loadEvolveConfig(l,o,a,p),c=i.map((e=>new RegExp(`^${e}$`))),f=filterActivedEntriesByModule(m.entryMap,c),d=normalizeEvolveEntryMap(f,m.entryMap),v=splitToEntryGroup(d,m,ignoreEntryOptionKeys,!1)[0];for(const[,e]of Object.entries(v))e.groupName=n;return prepareBuild(v,m,s).then((e=>e))};
|
package/dist/main/start-build.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import Listr from"listr";import{chalk,logger,requireResolve
|
1
|
+
import Listr from"listr";import{chalk,logger,requireResolve}from"@flatjs/common";import{createGlobalCompiler}from"../compiler/create-global-compiler.js";import{ignoreEntryOptionKeys}from"../constants.js";import{isCI}from"../helpers/check-runtime-env.js";import{CustomListrRenderer}from"../helpers/custom-listr-renderer.js";import{filterActivedEntriesByModule}from"../helpers/filter-actived-entries.js";import{getMaxProcessTasks}from"../helpers/get-max-process-tasks.js";import{jsonSerializer}from"../helpers/json-serializer.js";import{normalizeEvolveEntryMap}from"../helpers/normalize-entry-map.js";import{printPromotions}from"../helpers/print-promotion.js";import{splitToEntryGroup}from"../helpers/split-to-entry-group.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{createThreadWorker}from"./create-thread-worker.js";import{envVerify}from"./env-verify.js";import{startAnalyzer}from"./start-analyzer.js";import startBuildWorker from"./start-build-worker.js";const runWebpackTask=async(r,e,t,o,s,i={})=>{const{threads:a={}}=t,n=getMaxProcessTasks(e.length,a?.maxThreads);logger.info(`Start standard build with (${chalk(["magenta"])(String(n))}) workers`);const l=createThreadWorker({...a,maxThreads:n}),p=new Listr([],{concurrent:n,exitOnError:!0,renderer:isCI()?void 0:CustomListrRenderer}),c=[];for(const t of e){const e=Object.values(t)?.[0]?.groupName||"",a=Object.keys(t);let n=`Group ${chalk(["magenta"])(e)} $STATUS $ENTRY_KEYS${a.join(",")}`;isCI()&&(n=`Group ${chalk(["magenta"])(e)} compiling... $ENTRY_KEYS${a.join(",")}`),p.add({title:n,task:async()=>{const t=await l.startBuildWorker({projectCwd:r,entryKeys:a,groupName:e,serializedEvolveOptions:jsonSerializer.stringify(o),configLoaderOptions:s,cliOptions:i});c.push(t)}})}if(p.tasks.length)try{await p.run()}catch(r){throw l.terminate(),r}return l.terminate(),c},runRspackTask=async(r,e,t,o,s={})=>{const i=[];for(const a of e){const e=Object.values(a)?.[0]?.groupName||"",n=Object.keys(a),l=await startBuildWorker({projectCwd:r,entryKeys:n,groupName:e,serializedEvolveOptions:jsonSerializer.stringify(t),configLoaderOptions:o,cliOptions:s});i.push(l)}return i};export const startBuild=async(r,e,t={},o,s={})=>{const{analyzer:i=!1,compilerType:a="webpack"}=s,n={projectCwd:r,command:"build",resolve:requireResolve};printPromotions(s);const l=await loadEvolveConfig(n,r,t,o);await envVerify(r,l);const p=filterActivedEntriesByModule(l.entryMap,e),c=normalizeEvolveEntryMap(p,l.entryMap),m=splitToEntryGroup(c,l,ignoreEntryOptionKeys,!1);if(!m.length)return logger.warn("No build entries provided!"),[];await createGlobalCompiler(!1,l);let d=[];return"webpack"===a?d=await runWebpackTask(r,m,l,t,o,s):"rspack"===a&&(d=await runRspackTask(r,m,t,o,s)),i&&startAnalyzer(l),d};
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import type { Plugin as RspackPlugin } from '@rspack/core';
|
2
|
+
import { type ProgressPluginArgument } from '@rspack/core';
|
3
|
+
import type { EntryMapItem } from '../../../types/types-entry-map.js';
|
4
|
+
export declare const createProgressRspackPlugins: (entryMapItemList: EntryMapItem[], pluginOptions?: ProgressPluginArgument) => RspackPlugin[];
|
@@ -0,0 +1 @@
|
|
1
|
+
import{Worker}from"node:worker_threads";import{resolve}from"path";import{mergeOptions}from"@armit/config-loader";import{getDirname}from"@armit/file-utility";import{ProgressPlugin}from"@rspack/core";import{progressHandler}from"./progress-handler.js";export const createProgressRspackPlugins=(r,e={})=>{if("test"===process.env.NODE_ENV)return console.warn("[WARNING] Using fake thread pool worker for unittest!"),[new ProgressPlugin({prefix:"[ evolve vite progress ]"})];const o=resolve(getDirname(import.meta.url),"./progress-worker.js"),s=new Worker(o,{env:{...process.env,FORCE_COLOR:"3"}}),t=mergeOptions(progressHandler(s,r),e);return[new ProgressPlugin(t),{apply(r){r.hooks.done.tap("shutdown",(()=>{s.terminate()}))}}]};
|
@@ -0,0 +1 @@
|
|
1
|
+
export const progressHandler=(s,t)=>{const e=t[0],[r,a]=e,o=a?.groupName||"",n=t.map((([s])=>s));return(t,e)=>{const r={status:t>0&&t<1?"start":"end",data:{groupName:o,entryKeys:n}};s.postMessage(r)}};
|
@@ -0,0 +1 @@
|
|
1
|
+
import logUpdate from"log-update";import{parentPort}from"worker_threads";import{chalk}from"@flatjs/common";import{buildProgressSpinnerFrames}from"../../../constants.js";import{formatSpinnerText}from"../../../helpers/format-spinner-text.js";let startIndex=0;class ProgressWorker{constructor(){this.intervalId=null}start(r,e){this.intervalId||(this.intervalId=setInterval((()=>{startIndex=++startIndex%buildProgressSpinnerFrames.length;const t=buildProgressSpinnerFrames[startIndex],n=`Group ${chalk(["magenta"])(r)} compiling...`;logUpdate(`${chalk(["cyan"])(t)} ${n} \n${formatSpinnerText(e)}`)}),100))}end(r,e){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null);const t=`Group ${chalk(["magenta"])(r)} ${chalk(["green"])("done")}`;logUpdate(`${chalk(["green"])("✔")} ${t} \n${formatSpinnerText(e,"✔","green")}`),logUpdate.done()}}const progressWorker=new ProgressWorker;parentPort?.on("message",(({status:r,data:e})=>{const{groupName:t,entryKeys:n}=e;"start"===r?progressWorker.start(t,n):"end"===r&&progressWorker.end(t,n)}));
|
@@ -1 +1 @@
|
|
1
|
-
import{rmSync}from"node:fs";import{relative}from"node:path";import{fileWalkSync}from"@armit/file-utility";import{logger}from"@flatjs/common";import{moduleName}from"../../../constants.js";export class CleanWebpackPlugin{constructor(e={}){this.verbose=!0===e.verbose||!1,this.projectCwd=e.projectCwd||process.cwd(),this.cleanStaleWebpackAssets=!0!==e.cleanStaleWebpackAssets&&!1!==e.cleanStaleWebpackAssets||e.cleanStaleWebpackAssets,this.protectWebpackAssets=!0!==e.protectWebpackAssets&&!1!==e.protectWebpackAssets||e.protectWebpackAssets,this.cleanAfterEveryBuildPatterns=Array.isArray(e.cleanAfterEveryBuildPatterns)?e.cleanAfterEveryBuildPatterns:[],this.cleanOnceBeforeBuildPatterns=Array.isArray(e.cleanOnceBeforeBuildPatterns)?e.cleanOnceBeforeBuildPatterns:["**/*"],this.currentAssets=[],this.initialClean=!1,this.outputPath="",this.apply=this.apply.bind(this),this.handleInitial=this.handleInitial.bind(this),this.handleDone=this.handleDone.bind(this),this.removeFiles=this.removeFiles.bind(this)}apply(e){if(!e.options.output||!e.options.output.path)return void logger.warn("clean-webpack-plugin: options.output.path not defined. Plugin disabled...",moduleName);this.outputPath=e.options.output.path;const t=e.hooks;0!==this.cleanOnceBeforeBuildPatterns.length&&t.emit.tap("clean-webpack-plugin",(e=>{this.handleInitial(e)})),t.done.tap("clean-webpack-plugin",(e=>{this.handleDone(e)}))}handleInitial(e){if(this.initialClean)return;e.getStats().hasErrors()||(this.initialClean=!0,this.removeFiles(this.cleanOnceBeforeBuildPatterns))}handleDone(e){if(e.hasErrors())return void(this.verbose&&logger.warn("clean-webpack-plugin: pausing due to webpack errors",moduleName));const t=(e.toJson({assets:!0}).assets||[]).map((e=>e.name)),s=this.currentAssets.filter((e=>!1===t.includes(e)));this.currentAssets=t.sort();const i=[];!0===this.cleanStaleWebpackAssets&&0!==s.length&&i.push(...s),0!==this.cleanAfterEveryBuildPatterns.length&&i.push(...this.cleanAfterEveryBuildPatterns),0!==i.length&&this.removeFiles(i)}removeFiles(e){try{const t=fileWalkSync(e,{absolute:!0,unique:!0,cwd:this.outputPath,dot:!0,ignore:this.protectWebpackAssets?this.currentAssets:[]});for(const e of t)rmSync(e,{force:!0,recursive:!0});this.verbose&&t.forEach((e=>{const t=relative(this.projectCwd,e);logger.debug(`clean-webpack-plugin: removed ${t}`,moduleName)}))}catch(e){if(/Cannot delete files\/folders outside the current working directory\./.test(e.message)){throw new Error("clean-webpack-plugin: Cannot delete files/folders outside the current working directory. Can be overridden with the `dangerouslyAllowCleanPatternsOutsideProject` option.")}throw e}}}
|
1
|
+
import{rmSync}from"node:fs";import{relative}from"node:path";import{fileWalkSync}from"@armit/file-utility";import{logger}from"@flatjs/common";import{moduleName}from"../../../constants.js";export class CleanWebpackPlugin{constructor(e={}){this.verbose=!0===e.verbose||!1,this.projectCwd=e.projectCwd||process.cwd(),this.cleanStaleWebpackAssets=!0!==e.cleanStaleWebpackAssets&&!1!==e.cleanStaleWebpackAssets||e.cleanStaleWebpackAssets,this.protectWebpackAssets=!0!==e.protectWebpackAssets&&!1!==e.protectWebpackAssets||e.protectWebpackAssets,this.cleanAfterEveryBuildPatterns=Array.isArray(e.cleanAfterEveryBuildPatterns)?e.cleanAfterEveryBuildPatterns:[],this.cleanOnceBeforeBuildPatterns=Array.isArray(e.cleanOnceBeforeBuildPatterns)?e.cleanOnceBeforeBuildPatterns:["**/*"],this.currentAssets=[],this.initialClean=!1,this.outputPath="",this.apply=this.apply.bind(this),this.handleInitial=this.handleInitial.bind(this),this.handleDone=this.handleDone.bind(this),this.removeFiles=this.removeFiles.bind(this)}apply(e){if(!e.options.output||!e.options.output.path)return void logger.warn("clean-webpack-plugin: options.output.path not defined. Plugin disabled...",moduleName);this.outputPath=e.options.output.path;const t=e.hooks;0!==this.cleanOnceBeforeBuildPatterns.length&&t.emit.tap("clean-webpack-plugin",(e=>{this.handleInitial(e)})),t.done.tap("clean-webpack-plugin",(e=>{logger.info("start clean cache..."),this.handleDone(e)}))}handleInitial(e){if(this.initialClean)return;e.getStats().hasErrors()||(this.initialClean=!0,this.removeFiles(this.cleanOnceBeforeBuildPatterns))}handleDone(e){if(e.hasErrors())return void(this.verbose&&logger.warn("clean-webpack-plugin: pausing due to webpack errors",moduleName));const t=(e.toJson({assets:!0}).assets||[]).map((e=>e.name)),s=this.currentAssets.filter((e=>!1===t.includes(e)));this.currentAssets=t.sort();const i=[];!0===this.cleanStaleWebpackAssets&&0!==s.length&&i.push(...s),0!==this.cleanAfterEveryBuildPatterns.length&&i.push(...this.cleanAfterEveryBuildPatterns),0!==i.length&&this.removeFiles(i)}removeFiles(e){try{const t=fileWalkSync(e,{absolute:!0,unique:!0,cwd:this.outputPath,dot:!0,ignore:this.protectWebpackAssets?this.currentAssets:[]});for(const e of t)rmSync(e,{force:!0,recursive:!0});this.verbose&&t.forEach((e=>{const t=relative(this.projectCwd,e);logger.debug(`clean-webpack-plugin: removed ${t}`,moduleName)}))}catch(e){if(/Cannot delete files\/folders outside the current working directory\./.test(e.message)){throw new Error("clean-webpack-plugin: Cannot delete files/folders outside the current working directory. Can be overridden with the `dangerouslyAllowCleanPatternsOutsideProject` option.")}throw e}}}
|
@@ -1 +1 @@
|
|
1
|
-
import{assertSwcImportOptions}from"@flatjs/babel-plugin-import/helpers";import{shouldEnableReactFastRefresh}from"../../helpers/should-enable-react-fast-refresh.js";export const rspackRuleScripts=(e,t
|
1
|
+
import{assertSwcImportOptions}from"@flatjs/babel-plugin-import/helpers";import{requireResolve}from"@flatjs/common";import{shouldEnableReactFastRefresh}from"../../helpers/should-enable-react-fast-refresh.js";export const rspackRuleScripts=(e,r,t)=>{const{loaderOptions:s,projectCwd:a}=t,{modularImports:o=[]}=s,p=assertSwcImportOptions(a,o),l=shouldEnableReactFastRefresh(e,r,t);return{test:/\.(jsx|tsx|ts|js|mjs|cjs|mts|cts)$/,exclude:/node_modules/,use:[{loader:"builtin:swc-loader",options:{jsc:{parser:{decorators:!0,syntax:"typescript",tsx:!0},externalHelpers:!0,experimental:{keepImportAttributes:!0,plugins:[[requireResolve(import.meta.url,"@flatjs/swc-plugin-import"),{modularImports:p}]]},transform:{legacyDecorator:!0,react:{runtime:"automatic",pragma:"React.createElement",pragmaFrag:"React.Fragment",throwIfNamespace:!0,development:l,refresh:l}}},env:{mode:"entry",targets:{browsers:["ie >= 11","safari > 10"]}}}}]}};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@flatjs/evolve",
|
3
|
-
"version": "2.3.2-next.
|
3
|
+
"version": "2.3.2-next.3",
|
4
4
|
"license": "MIT",
|
5
5
|
"type": "module",
|
6
6
|
"exports": {
|
@@ -49,13 +49,14 @@
|
|
49
49
|
"@babel/core": "^7.26.10",
|
50
50
|
"@clack/prompts": "^0.10.1",
|
51
51
|
"@discoveryjs/json-ext": "0.6.3",
|
52
|
-
"@flatjs/babel-plugin-import": "2.2.9-next.
|
52
|
+
"@flatjs/babel-plugin-import": "2.2.9-next.2",
|
53
53
|
"@flatjs/common": "2.2.4-next.0",
|
54
54
|
"@flatjs/evolve-preset-babel": "2.2.4-next.0",
|
55
55
|
"@flatjs/forge-postcss-plugin-pixel": "2.2.4-next.0",
|
56
56
|
"@flatjs/forge-ts-checker": "1.1.2-next.0",
|
57
|
-
"@flatjs/graph": "2.2.9-next.
|
58
|
-
"@flatjs/mock": "2.4.1-next.
|
57
|
+
"@flatjs/graph": "2.2.9-next.2",
|
58
|
+
"@flatjs/mock": "2.4.1-next.2",
|
59
|
+
"@flatjs/swc-plugin-import": "1.0.0-next.3",
|
59
60
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.16",
|
60
61
|
"@rsdoctor/rspack-plugin": "^1.1.2",
|
61
62
|
"@rspack/core": "^1.3.10",
|
@@ -87,6 +88,7 @@
|
|
87
88
|
"svgo": "^3.3.2",
|
88
89
|
"tarjan-graph": "^3.0.0",
|
89
90
|
"terser-webpack-plugin": "^5.3.14",
|
91
|
+
"tinypool": "^1.0.2",
|
90
92
|
"tsconfig-paths-webpack-plugin": "^4.2.0",
|
91
93
|
"type-fest": "^4.40.0",
|
92
94
|
"typescript": "^5.8.3",
|