@flatjs/evolve 2.1.7 → 2.2.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/build-server/base-compiler-watching.d.ts +26 -0
  2. package/dist/build-server/base-compiler-watching.js +1 -0
  3. package/dist/build-server/compiler-server-manager.d.ts +30 -0
  4. package/dist/build-server/compiler-server-manager.js +1 -0
  5. package/dist/build-server/compiler-server.d.ts +38 -0
  6. package/dist/build-server/compiler-server.js +1 -0
  7. package/dist/build-server/create-compiler-watching.d.ts +14 -0
  8. package/dist/build-server/create-compiler-watching.js +1 -0
  9. package/dist/build-server/create-global-compiler-watching.d.ts +13 -0
  10. package/dist/build-server/create-global-compiler-watching.js +1 -0
  11. package/dist/build-server/global-compiler-server.d.ts +8 -0
  12. package/dist/build-server/global-compiler-server.js +1 -0
  13. package/dist/build-server/index.d.ts +5 -0
  14. package/dist/build-server/index.js +1 -0
  15. package/dist/compiler/create-build-server-compiler.d.ts +5 -0
  16. package/dist/compiler/create-build-server-compiler.js +1 -0
  17. package/dist/compiler/create-build-server-global-compiler.d.ts +3 -0
  18. package/dist/compiler/create-build-server-global-compiler.js +1 -0
  19. package/dist/compiler/create-global-compiler.d.ts +2 -0
  20. package/dist/compiler/create-global-compiler.js +1 -1
  21. package/dist/helpers/split-to-entry-group.d.ts +7 -3
  22. package/dist/helpers/split-to-entry-group.js +1 -1
  23. package/dist/index.d.ts +1 -0
  24. package/dist/index.js +1 -1
  25. package/dist/main/create-build-server.d.ts +15 -0
  26. package/dist/main/create-build-server.js +1 -0
  27. package/dist/main/index.d.ts +2 -0
  28. package/dist/main/index.js +1 -1
  29. package/package.json +42 -41
@@ -0,0 +1,26 @@
1
+ import type { Compiler, Configuration, Stats, Watching } from 'webpack';
2
+ export type CompilerServerState = 'idle' | 'ready';
3
+ export type StatsObjectOptions = Exclude<Configuration['stats'], boolean | string | undefined>;
4
+ export type CallbackKey = 'done' | 'watchRun' | 'invalid';
5
+ export type CallbackValue = ((stats?: Stats, error?: Error | Error[]) => void) | undefined;
6
+ export type BaseCompilerWatchingContext = {
7
+ compiler: Compiler;
8
+ watching?: Watching;
9
+ state: CompilerServerState;
10
+ callbacks: {
11
+ [key in CallbackKey]: CallbackValue[];
12
+ };
13
+ stats?: Stats;
14
+ };
15
+ export declare const normalizeStatsOptions: (statsOptions: Configuration["stats"]) => StatsObjectOptions;
16
+ export declare abstract class BaseCompilerWatching {
17
+ private context;
18
+ constructor(compiler: Compiler);
19
+ setupWatching(): void;
20
+ isReady(): boolean;
21
+ setCallback(key: CallbackKey, callback: CallbackValue): void;
22
+ invalidate(): Promise<void | Error>;
23
+ resume(): Promise<void>;
24
+ suspend(): Promise<void>;
25
+ close(): Promise<void | Error>;
26
+ }
@@ -0,0 +1 @@
1
+ import{logger}from"@flatjs/common";export const normalizeStatsOptions=t=>(void 0===t?t={preset:"normal"}:"boolean"==typeof t?t=t?{preset:"normal"}:{preset:"none"}:"string"==typeof t&&(t={preset:t}),t);const setupHooks=t=>{const e=t.compiler;e.hooks.watchRun.tap("flatjs-build-server",(function watchRun(){const e=t.callbacks.watchRun;for(const t of e)t?.();t.state="idle",t.stats=void 0,t.callbacks.watchRun=[]})),e.hooks.invalid.tap("flatjs-build-server",(function invalid(){"ready"===t.state&&logger.info("Compilation starting..."),t.state="idle",t.stats=void 0})),e.hooks.done.tap("flatjs-build-server",(function done(s){t.state="ready",t.stats=s,process.nextTick((()=>{const{callbacks:o}=t;if("ready"!==t.state)return;logger.debug(`Compilation finished: ${t.compiler.name}`);const n=normalizeStatsOptions(e.options.stats),i=s.toString(n);i&&logger.info(i);for(const t of o.done)t?.(s);t.callbacks.done=[]}))}))};export class BaseCompilerWatching{constructor(t){this.context={compiler:t,watching:void 0,state:"idle",callbacks:{done:[],watchRun:[],invalid:[]},stats:void 0},setupHooks(this.context),this.setupWatching()}setupWatching(){if(this.context.compiler.watching)this.context.watching=this.context.compiler.watching;else{const t=this.context.compiler.options.watchOptions||{};this.context.watching=this.context.compiler.watch({...t,aggregateTimeout:1e4,poll:!1},(t=>{this.context.state="ready",t&&logger.error(t)}))}}isReady(){return"ready"===this.context.state}setCallback(t,e){this.context.callbacks[t]||(this.context.callbacks[t]=[]),this.context.callbacks[t]?.push(e)}invalidate(){return new Promise(((t,e)=>{this.setCallback("done",((s,o)=>{o?e(o):t()})),this.context.watching?.invalidate()}))}resume(){return new Promise((t=>{this.context.watching?.suspended?(this.setCallback("watchRun",(()=>{t()})),this.context.watching?.resume()):t()}))}suspend(){return this.context.watching?.suspended||this.context.watching?.suspend(),Promise.resolve()}close(){return new Promise(((t,e)=>{this.context.compiler.close((s=>{s?e(s):t()}))}))}}
@@ -0,0 +1,30 @@
1
+ import type { ConfigLoaderOptions } from '../load-config/types.js';
2
+ import type { EvolveBuildResult } from '../main/start-group-entry-build.js';
3
+ import type { EvolveEntryMap } from '../types/types-entry-map.js';
4
+ import type { FlatEvolveOptions } from '../types/types-options.js';
5
+ /**
6
+ * Compares two arrays of build modules and returns a new array containing modules that are present in the second array but not in the first.
7
+ * @param originalBuildModules - The original array of build modules.
8
+ * @param buildModules - The new array of build modules to compare with the original.
9
+ * @returns A promise that resolves to an array of new build modules not present in the original array.
10
+ */
11
+ export declare const diffBuildModules: (originalBuildModules: string[], buildModules: string[]) => Promise<string[]>;
12
+ /**
13
+ * Splits the entry map into groups based on the given build modules and options.
14
+ * @param buildModules - The list of build modules to filter the entry map by.
15
+ * @param newEvolveOptions - The evolve options to use for splitting the entry map.
16
+ * @param groupCount - The number of groups to split the entry map into. Defaults to 0.
17
+ * @returns A promise that resolves to an array of EvolveEntryMap, each representing a group.
18
+ */
19
+ export declare const splitGroupEntryMap: (buildModules: string[], newEvolveOptions: FlatEvolveOptions, groupCount?: number) => Promise<EvolveEntryMap[]>;
20
+ declare class CompilerServerManager {
21
+ private factoryList;
22
+ private globalCompilerServer;
23
+ private createNormalCompilerServerFactory;
24
+ prepareNormalCompiler(projectCwd: string, buildModules: string[], evolveOptions: FlatEvolveOptions, configLoaderOptions?: ConfigLoaderOptions): Promise<string[]>;
25
+ prepareGlobalCompiler(evolveOptions: FlatEvolveOptions): Promise<void>;
26
+ checkGlobalCompiler(): Promise<void>;
27
+ recompile(): Promise<EvolveBuildResult[]>;
28
+ }
29
+ export declare const compilerServerManager: CompilerServerManager;
30
+ export {};
@@ -0,0 +1 @@
1
+ import{requireResolve}from"@armit/package";import{logger}from"@flatjs/common";import{createBuildServerCompiler}from"../compiler/create-build-server-compiler.js";import{createBuildServerGlobalCompiler}from"../compiler/create-build-server-global-compiler.js";import{ignoreEntryOptionKeys}from"../constants.js";import{filterActivedEntriesByModule}from"../helpers/filter-actived-entries.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{envVerify}from"../main/env-verify.js";import{CompilerServer}from"./compiler-server.js";import{GlobalCompilerServer}from"./global-compiler-server.js";export const diffBuildModules=async(r,e)=>{const o=[];for(const t of e){r.find((r=>r===t))||o.push(t)}return o};export const splitGroupEntryMap=async(r,e,o=0)=>{const t=filterActivedEntriesByModule(e.entryMap,r),i=normalizeEvolveEntryMap(t,e.entryMap);return splitToEntryGroup(i,e,ignoreEntryOptionKeys,!1,o)};class CompilerServerManager{constructor(){this.factoryList=[]}async createNormalCompilerServerFactory(r,e){const o=[];for(const t of r){const r=await createBuildServerCompiler(t,e),i=new CompilerServer(r,{watchFiles:[],setupExitSignals:!1});await i.start(),this.factoryList.push({compilerName:r.name,compilerServer:i,entryMap:t}),o.push(r.name)}return o}async prepareNormalCompiler(r,e,o,t){const i=this.factoryList.map((r=>Object.keys(r.entryMap))).flat(),l=await diffBuildModules(i,e);if(!l.length)return logger.debug("Build modules is empty!"),[];const a={projectCwd:r,command:"build",resolve:requireResolve},s=await loadEvolveConfig(a,r,o,t);await envVerify(r,s);const p=this.factoryList.length,n=await splitGroupEntryMap(l,s,p);return n.length?this.createNormalCompilerServerFactory(n,s):(logger.debug("Build entries is empty!"),[])}async prepareGlobalCompiler(r){if(this.globalCompilerServer)return;const e=await createBuildServerGlobalCompiler(r);e&&(this.globalCompilerServer=new GlobalCompilerServer(e),await this.globalCompilerServer.start())}async checkGlobalCompiler(){await this.globalCompilerServer.recompile()}async recompile(){if(!this.factoryList.length)return[];for(const r of this.factoryList){const{compilerServer:e}=r;await e.recompile()}return this.factoryList.map((r=>({name:Object.keys(r.entryMap)})))}}export const compilerServerManager=new CompilerServerManager;
@@ -0,0 +1,38 @@
1
+ import type { ChokidarOptions } from 'chokidar';
2
+ import type { Compiler } from 'webpack';
3
+ export type WatchFiles = {
4
+ paths: string[] | string;
5
+ options?: ChokidarOptions;
6
+ };
7
+ export type CompilerServerOptions = {
8
+ watchFiles: WatchFiles[];
9
+ setupExitSignals?: boolean;
10
+ onStaticChanged?: (item: any) => void;
11
+ };
12
+ export declare class CompilerServer {
13
+ private readonly compiler;
14
+ private readonly options;
15
+ private staticWatchers;
16
+ private watching;
17
+ private listeners;
18
+ constructor(compiler: Compiler, options: CompilerServerOptions);
19
+ start(): Promise<void>;
20
+ recompile(): Promise<void>;
21
+ /**
22
+ * Start the compiler server with a callback
23
+ * @param callback - The callback function
24
+ */
25
+ startCallback(callback?: (err?: Error) => void): void;
26
+ /**
27
+ * Stop the compiler server
28
+ */
29
+ stop(): Promise<void>;
30
+ /**
31
+ * Stop the compiler server with a callback
32
+ * @param callback - The callback function
33
+ */
34
+ stopCallback(callback?: (err?: Error) => void): void;
35
+ private initialize;
36
+ private setupWatchFiles;
37
+ private watchFiles;
38
+ }
@@ -0,0 +1 @@
1
+ import chokidar from"chokidar";import{logger}from"@flatjs/common";import{createCompilerWatching}from"./create-compiler-watching.js";export class CompilerServer{constructor(t,s){this.compiler=t,this.options=s,this.staticWatchers=[],this.listeners=[],this.watching=createCompilerWatching(t)}async start(){await this.initialize(),await this.setupWatchFiles(),logger.debug("Compiler server started")}async recompile(){try{await this.watching.resume(),await this.watching.invalidate()}finally{await this.watching.suspend()}}startCallback(t=()=>{}){this.start().then((()=>t()),t).catch(t)}async stop(){await Promise.all(this.staticWatchers.map((t=>t.close()))),this.staticWatchers=[];for(const t of this.listeners)process.removeListener(t.name,t.listener);this.listeners=[]}stopCallback(t=()=>{}){this.stop().then((()=>t()),t).catch(t)}initialize(){if(this.options.setupExitSignals){const t=["SIGINT","SIGTERM"];let s=!1;for(const i of t){const listener=()=>{s&&process.exit(),logger.info("Gracefully shutting down. To force exit, press ^C again. Please wait..."),s=!0,this.stopCallback((()=>{"function"==typeof this.compiler.close?this.compiler.close((()=>{process.exit()})):process.exit()}))};this.listeners.push({name:i,listener:listener}),process.on(i,listener),process.on(i,(()=>this.stop()))}}}setupWatchFiles(){const t=this.options.watchFiles;if(t.length>0)for(const s of t)this.watchFiles(s.paths,s.options)}watchFiles(t,s){const i=chokidar.watch(t,s);i.on("change",(t=>{this.options.onStaticChanged&&this.options.onStaticChanged(t)})),this.staticWatchers.push(i)}}
@@ -0,0 +1,14 @@
1
+ import type { Compiler, Stats } from 'webpack';
2
+ import { BaseCompilerWatching } from './base-compiler-watching.js';
3
+ export declare class CompilerWatching extends BaseCompilerWatching {
4
+ private readonly compiler;
5
+ constructor(compiler: Compiler);
6
+ private ready;
7
+ waitUntilValid: (callback?: (stats?: Stats) => void) => void;
8
+ }
9
+ /**
10
+ * Creates a new instance of CompilerWatching with the given compiler.
11
+ * @param compiler - The compiler instance to be watched.
12
+ * @returns A new instance of CompilerWatcher.
13
+ */
14
+ export declare const createCompilerWatching: (compiler: Compiler) => CompilerWatching;
@@ -0,0 +1 @@
1
+ import{logger}from"@flatjs/common";import{BaseCompilerWatching}from"./base-compiler-watching.js";export class CompilerWatching extends BaseCompilerWatching{constructor(i){super(i),this.compiler=i,this.waitUntilValid=i=>{this.ready(i)}}ready(i){if(this.isReady())i?.();else{const e=this.compiler.options.name;logger.info("wait until bundle finished"+(e?`: ${e}`:"")),i&&this.setCallback("done",i)}}}export const createCompilerWatching=i=>new CompilerWatching(i);
@@ -0,0 +1,13 @@
1
+ import type { Compiler } from 'webpack';
2
+ import { BaseCompilerWatching } from './base-compiler-watching.js';
3
+ export type GlobalCompilerWatchingContext = {
4
+ compiler: Compiler;
5
+ tsCheckerCallback?: (err: null | Error) => void;
6
+ };
7
+ export declare class GlobalCompilerWatching extends BaseCompilerWatching {
8
+ readonly compiler: Compiler;
9
+ private globalContext;
10
+ constructor(compiler: Compiler);
11
+ checkTsErrors(): Promise<void | Error>;
12
+ }
13
+ export declare const createGlobalCompilerWatching: (compiler: Compiler) => GlobalCompilerWatching;
@@ -0,0 +1 @@
1
+ import ForkTsCheckerWebpackPlugin from"fork-ts-checker-webpack-plugin";import{BaseCompilerWatching}from"./base-compiler-watching.js";const setupTsCheckerHooks=e=>{const{compiler:r}=e;ForkTsCheckerWebpackPlugin.getCompilerHooks(r).issues.tap("flatjs-build-server",(function issues(r){const o=r.filter((e=>"error"===e.severity)),s=o.length?new Error(`TS_CHECKER_ERROR: \n ${JSON.stringify(o,null,2)}`):null;return e.tsCheckerCallback?.(s),e.tsCheckerCallback=void 0,r}))};export class GlobalCompilerWatching extends BaseCompilerWatching{constructor(e){super(e),this.compiler=e,this.globalContext={compiler:e,tsCheckerCallback:void 0},setupTsCheckerHooks(this.globalContext)}async checkTsErrors(){return new Promise(((e,r)=>{this.globalContext.tsCheckerCallback=o=>{o?r(o.message):e()}}))}}export const createGlobalCompilerWatching=e=>new GlobalCompilerWatching(e);
@@ -0,0 +1,8 @@
1
+ import type { Compiler } from 'webpack';
2
+ export declare class GlobalCompilerServer {
3
+ readonly compiler: Compiler;
4
+ private watching;
5
+ constructor(compiler: Compiler);
6
+ start(): Promise<void>;
7
+ recompile(): Promise<void>;
8
+ }
@@ -0,0 +1 @@
1
+ import{logger}from"@flatjs/common";import{createGlobalCompilerWatching}from"./create-global-compiler-watching.js";export class GlobalCompilerServer{constructor(a){this.compiler=a,this.watching=createGlobalCompilerWatching(a)}async start(){logger.debug("Global compiler server started")}async recompile(){try{await this.watching.resume(),await this.watching.invalidate(),await this.watching.checkTsErrors()}finally{await this.watching.suspend()}}}
@@ -0,0 +1,5 @@
1
+ export * from './compiler-server.js';
2
+ export * from './compiler-server-manager.js';
3
+ export * from './create-compiler-watching.js';
4
+ export * from './create-compiler-watching.js';
5
+ export * from './create-global-compiler-watching.js';
@@ -0,0 +1 @@
1
+ export*from"./compiler-server.js";export*from"./compiler-server-manager.js";export*from"./create-compiler-watching.js";export*from"./create-compiler-watching.js";export*from"./create-global-compiler-watching.js";
@@ -0,0 +1,5 @@
1
+ import type { Compiler } from 'webpack';
2
+ import type { FlatCliOptions } from '../types/types-cli-options.js';
3
+ import { type EvolveEntryMap } from '../types/types-entry-map.js';
4
+ import { type FlatEvolveOptions } from '../types/types-options.js';
5
+ export declare const createBuildServerCompiler: (groupEntries: EvolveEntryMap, evolveOptions: FlatEvolveOptions, cliOptions?: FlatCliOptions) => Promise<Compiler>;
@@ -0,0 +1 @@
1
+ import webpack from"webpack";import{ensureSlash,mergeOptions}from"@flatjs/common";import{ignoreEntryOptionKeys}from"../constants.js";import{loadWebpackConfig}from"../create-webpack/load-webpack-config.js";import{EvolveBuildError}from"../errors/evolve-build-error.js";import{assertSingleCompiler}from"../helpers/assert-single-compiler.js";import{printCompilerError}from"../helpers/print-log.js";import{verifyGroupEntryOptions}from"../helpers/verify-group-entry-options.js";export const createBuildServerCompiler=async(r,o,e)=>{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 i=o.multiHtmlCdn?.prod||[];if(!i.length)throw new Error(`No CDN config for env:"prod", groupName: ${t.groupName}`);const n=ensureSlash(i[Math.floor(Math.random()*i.length)],!0);try{const i=t.options?.useRelativeAssetPath,p=mergeOptions(o,{webpack:{publicPath:i?"auto":n}}),s=await loadWebpackConfig("production",r,p,e),a=assertSingleCompiler(r,s,p,!1);return webpack(a)}catch(r){const o=printCompilerError(r);throw new EvolveBuildError("BUILD_ERROR",o)}};
@@ -0,0 +1,3 @@
1
+ import webpack from 'webpack';
2
+ import type { FlatEvolveOptions } from '../types/types-options.js';
3
+ export declare const createBuildServerGlobalCompiler: (evolveOptions: FlatEvolveOptions) => Promise<webpack.Compiler | undefined>;
@@ -0,0 +1 @@
1
+ import webpack from"webpack";import{logger}from"@flatjs/common";import{createGlobalCompilerConfig}from"../compiler/create-global-compiler.js";export const createBuildServerGlobalCompiler=async r=>{const o=createGlobalCompilerConfig(!0,r);if(!o)return;return webpack(o,(r=>{r&&logger.error(r)}))};
@@ -1,2 +1,4 @@
1
+ import webpack from 'webpack';
1
2
  import { type FlatEvolveOptions } from '../types/types-options.js';
3
+ export declare const createGlobalCompilerConfig: (serveMode: boolean, evolveOptions: FlatEvolveOptions) => false | webpack.Configuration;
2
4
  export declare const createGlobalCompiler: (serveMode: boolean, evolveOptions: FlatEvolveOptions) => Promise<boolean>;
@@ -1 +1 @@
1
- import webpack from"webpack";import{getDirname}from"@armit/file-utility";import{createExternals}from"../create-webpack/create-externals.js";import{createResolve}from"../create-webpack/create-resolve.js";import{ruleBabel}from"../create-webpack/rule-sets/rule-scripts.js";import{createTsCheckerPlugins}from"../plugins/ts-checker/ts-checker-plugin.js";export const createGlobalCompiler=async(e,r)=>{const{projectCwd:t,webpack:o,devServer:a,globalCompilerOptions:c}=r,{runTsChecker:l=!0}=c||{};if(!l)return!1;const s=e?"development":"production",n=a?.watchOptions||{},p=[ruleBabel({})],i=[...createTsCheckerPlugins(e,r)],m={context:t,mode:s,watch:e,name:"flat/evolve/global-compiler",entry:{".global-compiler-bundle":["."]},resolve:createResolve(t,o),module:{rules:p},plugins:i,watchOptions:n,devtool:!1,externals:createExternals(o?.externals),cache:{type:"memory"},performance:{},output:{environment:{},path:getDirname(import.meta.url,"./")}};return new Promise(((e,r)=>{webpack(m,(t=>{if(t)return r(t.message);e(!0)}))}))};
1
+ import webpack from"webpack";import{getDirname}from"@armit/file-utility";import{createExternals}from"../create-webpack/create-externals.js";import{createResolve}from"../create-webpack/create-resolve.js";import{ruleBabel}from"../create-webpack/rule-sets/rule-scripts.js";import{createTsCheckerPlugins}from"../plugins/ts-checker/ts-checker-plugin.js";export const createGlobalCompilerConfig=(e,r)=>{const{projectCwd:t,webpack:o,devServer:a,globalCompilerOptions:l}=r,{runTsChecker:c=!0}=l||{};if(!c)return!1;const n=e?"development":"production",s=a?.watchOptions||{},p=[ruleBabel({})],i=[...createTsCheckerPlugins(e,r)];return{context:t,mode:n,watch:e,name:"flat/evolve/global-compiler",entry:{".global-compiler-bundle":["."]},resolve:createResolve(t,o),module:{rules:p},plugins:i,watchOptions:s,devtool:!1,externals:createExternals(o?.externals),cache:{type:"memory"},performance:{},output:{environment:{},path:getDirname(import.meta.url,"./")}}};export const createGlobalCompiler=async(e,r)=>{const t=createGlobalCompilerConfig(e,r);return!!t&&new Promise(((e,r)=>{webpack(t,(t=>{if(t)return r(t.message);e(!0)}))}))};
@@ -28,7 +28,7 @@ export declare const autoGroupingReduce: (autoEntries: (EvolveEntryMapContent &
28
28
  * @param evolveEntryMapList - The list of evolve entry maps.
29
29
  * @returns The updated list of evolve entry maps with group names assigned.
30
30
  */
31
- export declare const autoAssignGroupName: (evolveOptions: FlatEvolveOptions, evolveEntryMapList: Array<EvolveEntryMap>) => Array<EvolveEntryMap>;
31
+ export declare const autoAssignGroupName: (evolveOptions: FlatEvolveOptions, evolveEntryMapList: Array<EvolveEntryMap>, originalGroupCount?: number) => Array<EvolveEntryMap>;
32
32
  /**
33
33
  * Groups the given autoEntries into multiple EvolveEntryMap based on their options.
34
34
  * If the group size exceeds the maximum group size, it will be sliced into smaller groups.
@@ -37,16 +37,20 @@ export declare const autoAssignGroupName: (evolveOptions: FlatEvolveOptions, evo
37
37
  * @param autoEntries - An array of EvolveEntryMapContent objects with an additional entryName property.
38
38
  * @param ignoreOptionKeys - An array of keys to ignore in the EvolveEntryItemOption object.
39
39
  * @param serveMode - A boolean indicating whether the serve mode is enabled.
40
+ * @param originalGroupCount - The original group count.
40
41
  * @returns An array of EvolveEntryMap representing the grouped entries.
41
42
  */
42
43
  export declare const autoGrouping: (evolveOptions: FlatEvolveOptions, autoEntries: (EvolveEntryMapContent & {
43
44
  entryName: string;
44
- })[], ignoreOptionKeys: Array<keyof EvolveEntryItemOption> | undefined, serveMode: boolean) => Array<EvolveEntryMap>;
45
+ })[], ignoreOptionKeys: Array<keyof EvolveEntryItemOption> | undefined, serveMode: boolean, originalGroupCount?: number) => Array<EvolveEntryMap>;
45
46
  /**
46
47
  * Splits the served entries into groups based on the given options.
47
48
  *
48
49
  * @param evolveEntries - The map of served entries.
50
+ * @param evolveOptions - The FlatEvolveOptions object.
49
51
  * @param ignoreOptionKeys - The list of option keys to ignore.
52
+ * @param serveMode - A boolean indicating whether the serve mode is enabled.
53
+ * @param originalGroupCount - The original group count.
50
54
  * @returns An array of evolve entry maps representing the groups.
51
55
  */
52
- export declare const splitToEntryGroup: (evolveEntries: EvolveEntryMap, evolveOptions: FlatEvolveOptions, ignoreOptionKeys: Array<keyof EvolveEntryItemOption> | undefined, serveMode: boolean) => Array<EvolveEntryMap>;
56
+ export declare const splitToEntryGroup: (evolveEntries: EvolveEntryMap, evolveOptions: FlatEvolveOptions, ignoreOptionKeys: Array<keyof EvolveEntryItemOption> | undefined, serveMode: boolean, originalGroupCount?: number) => Array<EvolveEntryMap>;
@@ -1 +1 @@
1
- import _ from"lodash";import{ignoreEntryOptionKeys}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)=>{const{maxEntryGroupSize:n=10}=o,s=autoGroupingReduce(e,t,r),u=[];for(const[,o]of Object.entries(s)){const e=Object.keys(o);if(e.length>n)for(let t=0;t<e.length;t+=n){const r=e.slice(t,t+n).reduce(((e,t)=>(e[t]=o[t],e)),{});u.push(r)}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,r)]};
1
+ import _ from"lodash";import{ignoreEntryOptionKeys}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,t=0)=>{const{projectVirtualPath:r}=o,n=[];let s=t;for(const o of e){const e={},t=normalizeGroupName(r,s++);for(const[r,n]of Object.entries(o))n.groupName=t,e[r]=n;n.push(e)}return n};export const autoGrouping=(o,e,t=[],r,n=0)=>{const{maxEntryGroupSize:s=10}=o,u=autoGroupingReduce(e,t,r),i=[];for(const[,o]of Object.entries(u)){const e=Object.keys(o);if(e.length>s)for(let t=0;t<e.length;t+=s){const r=e.slice(t,t+s).reduce(((e,t)=>(e[t]=o[t],e)),{});i.push(r)}else i.push(o)}return autoAssignGroupName(o,i,n)};export const splitToEntryGroup=(o,e,t=ignoreEntryOptionKeys,r,n=0)=>{const{isolation:s=!1}=e;if(s){const e=[];for(const[t,r]of Object.entries(o))r.groupName=t,e.push({[t]:r});return e}const u=_.flatMap(o,((o,e)=>({...o,entryName:e}))),i=_.groupBy(u,(o=>o.groupingSource));return[...manualGrouping(i.manual),...autoGrouping(e,i.auto,t,r,n)]};
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './build-server/index.js';
1
2
  export * from './define-config/index.js';
2
3
  export * from './load-config/index.js';
3
4
  export * from './main/index.js';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export*from"./define-config/index.js";export*from"./load-config/index.js";export*from"./main/index.js";export*from"./types/types-entry-map.js";export*from"./types/types-options.js";
1
+ export*from"./build-server/index.js";export*from"./define-config/index.js";export*from"./load-config/index.js";export*from"./main/index.js";export*from"./types/types-entry-map.js";export*from"./types/types-options.js";
@@ -0,0 +1,15 @@
1
+ import { type PartialDeep } from 'type-fest';
2
+ import { type ConfigLoaderOptions } from '../load-config/types.js';
3
+ import { type FlatEvolveOptions } from '../types/types-options.js';
4
+ export declare class BuildServer {
5
+ /**
6
+ * Build the modules
7
+ * @param earlyCommit - The early commit
8
+ * @param lastCommit - The last commit
9
+ * @param overrideEvolveOptions - The override evolve options
10
+ * @param configLoaderOptions - The config loader options
11
+ * @returns The build results
12
+ */
13
+ build(projectCwd: string, earlyCommit?: string, lastCommit?: string, overrideEvolveOptions?: PartialDeep<FlatEvolveOptions>, configLoaderOptions?: ConfigLoaderOptions): Promise<import("./start-group-entry-build.js").EvolveBuildResult[]>;
14
+ }
15
+ export declare const createBuildServer: () => BuildServer;
@@ -0,0 +1 @@
1
+ import{compilerServerManager}from"../build-server/compiler-server-manager.js";import{dynamicCheckBuildEntryMap}from"./start-build-dynamic.js";export class BuildServer{async build(e,r,a,i={},l){const{buildEntries:o,newEvolveOptions:c}=await dynamicCheckBuildEntryMap(e,r,a,i,l);await compilerServerManager.prepareGlobalCompiler(c),await compilerServerManager.checkGlobalCompiler();const p=Object.keys(o);await compilerServerManager.prepareNormalCompiler(e,p,c,l);return await compilerServerManager.recompile()}}export const createBuildServer=()=>new BuildServer;
@@ -1,4 +1,6 @@
1
+ export * from './create-build-server.js';
1
2
  export * from './start-build.js';
2
3
  export * from './start-build-dynamic.js';
4
+ export * from './start-group-entry-build.js';
3
5
  export * from './start-serve.js';
4
6
  export * from './start-static.js';
@@ -1 +1 @@
1
- export*from"./start-build.js";export*from"./start-build-dynamic.js";export*from"./start-serve.js";export*from"./start-static.js";
1
+ export*from"./create-build-server.js";export*from"./start-build.js";export*from"./start-build-dynamic.js";export*from"./start-group-entry-build.js";export*from"./start-serve.js";export*from"./start-static.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatjs/evolve",
3
- "version": "2.1.7",
3
+ "version": "2.2.0-next.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -35,66 +35,67 @@
35
35
  "typecheck": "tsc --project ./tsconfig.json --noEmit"
36
36
  },
37
37
  "dependencies": {
38
- "@armit/babel-merge": "^0.2.6",
39
- "@armit/config-loader": "^0.3.0",
40
- "@armit/file-utility": "^0.2.6",
41
- "@armit/git": "^0.2.6",
42
- "@armit/package": "^0.2.10",
43
- "@babel/core": "^7.25.9",
44
- "@clack/prompts": "^0.7.0",
45
- "@discoveryjs/json-ext": "0.6.2",
46
- "@flatjs/babel-plugin-import": "2.1.5",
47
- "@flatjs/common": "2.1.5",
48
- "@flatjs/evolve-preset-babel": "2.1.5",
49
- "@flatjs/forge-postcss-plugin-pixel": "2.1.5",
50
- "@flatjs/graph": "2.1.5",
51
- "@flatjs/mock": "2.2.1",
38
+ "@armit/babel-merge": "^0.2.8",
39
+ "@armit/config-loader": "^0.3.2",
40
+ "@armit/file-utility": "^0.2.8",
41
+ "@armit/git": "^0.2.8",
42
+ "@armit/package": "^0.2.12",
43
+ "@babel/core": "^7.26.0",
44
+ "@clack/prompts": "^0.9.0",
45
+ "@discoveryjs/json-ext": "0.6.3",
46
+ "@flatjs/babel-plugin-import": "2.2.0-next.0",
47
+ "@flatjs/common": "2.2.0-next.0",
48
+ "@flatjs/evolve-preset-babel": "2.2.0-next.0",
49
+ "@flatjs/forge-postcss-plugin-pixel": "2.2.0-next.0",
50
+ "@flatjs/graph": "2.2.0-next.0",
51
+ "@flatjs/mock": "2.3.0-next.0",
52
52
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
53
53
  "@types/babel__core": "^7.20.5",
54
54
  "babel-loader": "^9.2.1",
55
55
  "better-opn": "^3.0.2",
56
56
  "case-sensitive-paths-webpack-plugin": "^2.4.0",
57
- "ci-info": "^4.0.0",
57
+ "chokidar": "^4.0.3",
58
+ "ci-info": "^4.1.0",
58
59
  "css-loader": "^7.1.2",
59
60
  "cssnano": "^7.0.6",
60
- "express": "^4.21.1",
61
+ "express": "^4.21.2",
61
62
  "fork-ts-checker-webpack-plugin": "^9.0.2",
62
- "happy-dom": "^15.7.4",
63
+ "happy-dom": "^15.11.7",
63
64
  "html-webpack-plugin": "^5.6.3",
64
- "image-minimizer-webpack-plugin": "^4.1.0",
65
- "less": "^4.2.0",
65
+ "image-minimizer-webpack-plugin": "^4.1.3",
66
+ "less": "^4.2.1",
66
67
  "less-loader": "^12.2.0",
67
68
  "listr": "^0.14.3",
68
69
  "lodash": "^4.17.21",
69
70
  "log-update": "^6.1.0",
70
- "mini-css-extract-plugin": "^2.9.1",
71
- "postcss": "^8.4.47",
71
+ "mini-css-extract-plugin": "^2.9.2",
72
+ "postcss": "^8.4.49",
72
73
  "postcss-loader": "^8.1.1",
73
- "react-refresh": "^0.14.2",
74
+ "react-refresh": "^0.16.0",
74
75
  "svgo": "^3.3.2",
75
76
  "tarjan-graph": "^3.0.0",
76
- "terser-webpack-plugin": "^5.3.10",
77
- "tinypool": "^1.0.1",
78
- "tsconfig-paths-webpack-plugin": "^4.1.0",
79
- "type-fest": "^4.26.1",
80
- "typescript": "^5.6.3",
81
- "webpack": "^5.95.0",
77
+ "terser-webpack-plugin": "^5.3.11",
78
+ "tinypool": "^1.0.2",
79
+ "tsconfig-paths-webpack-plugin": "^4.2.0",
80
+ "type-fest": "^4.30.2",
81
+ "typescript": "^5.7.2",
82
+ "webpack": "^5.97.1",
82
83
  "webpack-bundle-analyzer": "^4.10.2",
83
- "webpack-dev-server": "^5.1.0",
84
+ "webpack-dev-server": "^5.2.0",
84
85
  "webpack-sources": "^3.2.3"
85
86
  },
86
87
  "devDependencies": {
87
- "@dimjs/lang": "2.0.0",
88
- "@dimjs/model": "2.0.1",
89
- "@dimjs/model-react": "2.0.1",
90
- "@dimjs/utils": "2.0.2",
91
- "@flatjs/testing": "2.1.5",
92
- "@hyperse/eslint-config-hyperse": "^1.2.6",
93
- "@swc/core": "1.7.39",
88
+ "@dimjs/lang": "2.0.1",
89
+ "@dimjs/model": "2.0.2",
90
+ "@dimjs/model-react": "2.0.2",
91
+ "@dimjs/utils": "2.0.3",
92
+ "@flatjs/testing": "2.2.0-next.0",
93
+ "@hyperse/eslint-config-hyperse": "^1.2.8",
94
+ "@swc/core": "1.10.1",
94
95
  "@types/express": "5.0.0",
95
96
  "@types/listr": "0.14.9",
96
- "@types/node": "22.7.9",
97
- "eslint": "^9.13.0",
97
+ "@types/node": "22.10.2",
98
+ "eslint": "^9.17.0",
98
99
  "imagemin-gifsicle": "7.0.0",
99
100
  "imagemin-jpegtran": "8.0.0",
100
101
  "imagemin-pngquant": "10.0.0",
@@ -102,8 +103,8 @@
102
103
  "npm-run-all": "4.1.5",
103
104
  "react": "18.3.1",
104
105
  "rimraf": "6.0.1",
105
- "vite-tsconfig-paths": "5.0.1",
106
- "vitest": "2.1.3",
106
+ "vite-tsconfig-paths": "5.1.4",
107
+ "vitest": "2.1.8",
107
108
  "vue-loader": "17.4.2"
108
109
  },
109
110
  "peerDependencies": {