@flatjs/evolve 2.1.0-next.22 → 2.1.0-next.24
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/compiler/create-global-compiler.js +1 -1
- package/dist/create-webpack/create-resolve.js +1 -1
- package/dist/create-webpack/load-webpack-config.js +1 -1
- package/dist/create-webpack/rule-sets/rule-scripts.js +1 -1
- package/dist/dev-server/create-dev-server-compiler-task.d.ts +1 -1
- package/dist/dev-server/create-dev-server-compiler-task.js +1 -1
- package/dist/helpers/check-runtime-env.d.ts +4 -0
- package/dist/helpers/check-runtime-env.js +1 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.js +1 -1
- package/dist/main/prepare-serve.js +1 -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/minimizer/create-minimizers.js +1 -1
- package/dist/types/types-entry-map.d.ts +1 -1
- package/dist/types/types-webpack.d.ts +4 -1
- package/package.json +5 -4
- package/dist/create-webpack/load-watch-options.d.ts +0 -12
- package/dist/create-webpack/load-watch-options.js +0 -1
@@ -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=(e,r)=>{const{projectCwd:t,webpack:o,devServer:a}=r,c=e?"development":"production",
|
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 +1 @@
|
|
1
|
-
import{join}from"node:path";import{TsconfigPathsPlugin}from"tsconfig-paths-webpack-plugin";import{mergeOptions}from"@flatjs/common";export const createResolve=(s,o)=>{const
|
1
|
+
import{join}from"node:path";import{TsconfigPathsPlugin}from"tsconfig-paths-webpack-plugin";import{mergeOptions}from"@flatjs/common";export const createResolve=(s,o)=>{const t={mainFields:["browser","module","main"],extensions:[".ts",".tsx",".js",".jsx",".mjs",".cjs",".mts",".cts",".json"],extensionAlias:{".js":[".js",".ts"],".cjs":[".cjs",".cts"],".mjs":[".mjs",".mts"],".jsx":[".jsx",".tsx"]},plugins:[new TsconfigPathsPlugin({configFile:join(s,"tsconfig.json"),extensions:[".ts",".tsx",".js",".jsx",".mjs"]})]};return mergeOptions(t,o?.resolve||{})};
|
@@ -1 +1 @@
|
|
1
|
-
import{assertGroupEntryItem}from"../helpers/assert-group-entry-item.js";import{createExternals}from"./create-externals.js";import{createOptimization}from"./create-optimization.js";import{createOutput}from"./create-output.js";import{createPerformance}from"./create-performance.js";import{createPlugins}from"./create-plugins.js";import{createResolve}from"./create-resolve.js";import{createRuleSets}from"./create-rule-sets.js";
|
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=assertGroupEntryItem(t,r),p=c?.watchOptions,i=createRuleSets(a,n,r),m=await createPlugins(a,n,r),l=n[0];return{mode:e,plugins:m,watchOptions:p,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:"errors-warnings"},cache:{type:"memory"}}};
|
@@ -1 +1 @@
|
|
1
|
-
import{requireResolve}from"@flatjs/common";import{mergeBabelOption}from"../../helpers/merge-babel-options.js";import{shouldEnableReactFastRefresh}from"../../helpers/should-enable-react-fast-refresh.js";export const ruleBabel=e=>({test:/\.(tsx|ts|js|jsx)$/,use:[{loader:requireResolve(import.meta.url,"babel-loader"),options:e}]});export const ruleScripts=(e,r,s)=>{const{babelOptions:
|
1
|
+
import{requireResolve}from"@flatjs/common";import{mergeBabelOption}from"../../helpers/merge-babel-options.js";import{shouldEnableReactFastRefresh}from"../../helpers/should-enable-react-fast-refresh.js";export const ruleBabel=e=>({test:/\.(tsx|ts|js|jsx|mjs|cjs|mts|cts)$/,use:[{loader:requireResolve(import.meta.url,"babel-loader"),options:e}]});export const ruleScripts=(e,r,s)=>{const{babelOptions:t={},modularImports:o=[]}=s.loaderOptions,l=mergeBabelOption(o,t);return shouldEnableReactFastRefresh(e,r,s)&&(l.plugins?l.plugins.push(requireResolve(import.meta.url,"react-refresh/babel")):l.plugins=[requireResolve(import.meta.url,"react-refresh/babel")]),ruleBabel(l)};
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { type FlatEvolveOptions } from '../types/types-options.js';
|
2
2
|
import { type EvolveDevServerEntryMap } from './middlewares/types.js';
|
3
|
-
export declare const createDevServerCompilerTask: (
|
3
|
+
export declare const createDevServerCompilerTask: (publicIp: string, servedDevServerEntries: EvolveDevServerEntryMap, servedDevServerEntryList: Array<EvolveDevServerEntryMap>, evolveOptions: FlatEvolveOptions) => Promise<boolean>;
|
@@ -1 +1 @@
|
|
1
|
-
import
|
1
|
+
import webpack from"webpack";import{mergeOptions,urlJoin}from"@flatjs/common";import{loadWebpackConfig}from"../create-webpack/load-webpack-config.js";import{assertSingleCompiler}from"../helpers/assert-single-compiler.js";import{flatEntryMap}from"../helpers/flat-entry-map.js";import{shouldEnableReactFastRefresh}from"../helpers/should-enable-react-fast-refresh.js";import{addCompilerToDevServer}from"./add-compiler-to-dev-server.js";export const createDevServerCompilerTask=async(e,r,o,t)=>{const[s,a]=Object.entries(r)[0],{devServerPort:n,devServerHostUri:i}=a;for(const[,e]of Object.entries(r)){const r=e.entryConfig,t=r.options?.moduleFederation,s=t?.remotes||[],a=flatEntryMap(o);s.forEach((e=>{e.endpoint=e=>{const r=a[e];if(!r)throw new Error(`No servedDevServerEntry found via "${e}"`);return urlJoin(r?.devServerHostUri,["/public"])}}))}const p=Object.keys(r).reduce(((e,o)=>(e[o]=r[o].entryConfig,e)),{}),l=urlJoin(i,["public"]),c=await loadWebpackConfig("development",p,mergeOptions(t,{webpack:{publicPath:l}})),m=shouldEnableReactFastRefresh(!0,[s,a.entryConfig],t),f=assertSingleCompiler(p,c,t,m),d=webpack(f);return addCompilerToDevServer(d,m,n,e,t)};
|
@@ -0,0 +1 @@
|
|
1
|
+
import ci from"ci-info";export const isCI=()=>ci.isCI;
|
package/dist/helpers/index.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
export * from './allow-px2rem-for-module.js';
|
2
2
|
export * from './assert-group-entry-item.js';
|
3
3
|
export * from './assert-single-compiler.js';
|
4
|
+
export * from './check-runtime-env.js';
|
4
5
|
export * from './chunk-entry-map.js';
|
5
6
|
export * from './custom-listr-renderer.js';
|
6
7
|
export * from './delete-object-keys.js';
|
package/dist/helpers/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export*from"./allow-px2rem-for-module.js";export*from"./assert-group-entry-item.js";export*from"./assert-single-compiler.js";export*from"./chunk-entry-map.js";export*from"./custom-listr-renderer.js";export*from"./delete-object-keys.js";export*from"./enable-bundle-hashname-for-module.js";export*from"./flat-entry-map.js";export*from"./format-spinner-text.js";export*from"./get-bundle-file-name.js";export*from"./get-html-plugin-config.js";export*from"./get-pacakge-dir.js";export*from"./get-runtime-cdn-base.js";export*from"./is-deep-equal.js";export*from"./json-serializer.js";export*from"./merge-babel-options.js";export*from"./normalize-check-entry-options.js";export*from"./normalize-entry-map.js";export*from"./normalize-group-name.js";export*from"./normalize-page-proxy.js";export*from"./normalize-resolve-alias.js";export*from"./normalize-template-inject-tokens.js";export*from"./open-page.js";export*from"./print-log.js";export*from"./refresh-evolve-mock-options.js";export*from"./script-injects.js";export*from"./should-enable-react-fast-refresh.js";export*from"./split-to-entry-group.js";export*from"./verify-group-entry-options.js";
|
1
|
+
export*from"./allow-px2rem-for-module.js";export*from"./assert-group-entry-item.js";export*from"./assert-single-compiler.js";export*from"./check-runtime-env.js";export*from"./chunk-entry-map.js";export*from"./custom-listr-renderer.js";export*from"./delete-object-keys.js";export*from"./enable-bundle-hashname-for-module.js";export*from"./flat-entry-map.js";export*from"./format-spinner-text.js";export*from"./get-bundle-file-name.js";export*from"./get-html-plugin-config.js";export*from"./get-pacakge-dir.js";export*from"./get-runtime-cdn-base.js";export*from"./is-deep-equal.js";export*from"./json-serializer.js";export*from"./merge-babel-options.js";export*from"./normalize-check-entry-options.js";export*from"./normalize-entry-map.js";export*from"./normalize-group-name.js";export*from"./normalize-page-proxy.js";export*from"./normalize-resolve-alias.js";export*from"./normalize-template-inject-tokens.js";export*from"./open-page.js";export*from"./print-log.js";export*from"./refresh-evolve-mock-options.js";export*from"./script-injects.js";export*from"./should-enable-react-fast-refresh.js";export*from"./split-to-entry-group.js";export*from"./verify-group-entry-options.js";
|
@@ -1 +1 @@
|
|
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:
|
1
|
+
import{arrayUnique,chalk,logger,urlJoin}from"@flatjs/common";import{attachMockMiddlewares}from"@flatjs/mock";import{ignoreEntryOptionKeys,moduleName}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:a,devHostUri:p,publicIp:s}=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 m=a;const l=[];for(const e of t){if(!verifyGroupEntryOptions(e,ignoreEntryOptionKeys,!0))throw new Error("The entry options in a group must be the same.");m++;const r=await createDevServerEntries(m,e,o);l.push(r)}const v=flatEntryMap(l);createAppPageRoute(e,i,p,v,o);const y=normalizePageProxy(o.devServer?.pageProxy||"/pages"),f=urlJoin(p,[y]);o.devServer?.autoOpen&&openPage(f);for(const e of l){const r=createDevServerCompilerTask(s,e,l,o);n.push(r)}return Promise.all(n).then((()=>(logger.info(`debug page ➩ ${chalk(["cyan"])(f)}`,moduleName),i)))};
|
@@ -1 +1 @@
|
|
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{CustomListrRenderer}from"../helpers/custom-listr-renderer.js";import{filterActivedEntriesByEntryInputs,filterActivedEntriesByModule}from"../helpers/filter-actived-entries.js";import{formatSpinnerText}from"../helpers/format-spinner-text.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{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";export async function getBuildEntryFiles(e,r,t,o,i){const n=[],s=[];for(const e of t)r.includes(e)?n.push(e):s.push(e);if(i&&logger.info("Use custom graph traverse filter",moduleName),s.length){const t=await traverseGraph({input:s,projectCwd:e,treeNodeFilter:i||(()=>!0),lessImportOptions:{projectCwd:e,aliases:o}});if(!t)return n;logger.debug(`DependencyGraph:\n${JSON.stringify(t,null,2)}`);for(const e of s){const o=t[e]||[];arraysIntersect(o,r)&&n.push(e)}}return n}export async function dynamicCheckBuildEntryMap(e,r,t,o,i){const n={projectCwd:e,command:"build",resolve:requireResolve},s=await loadEvolveConfig(n,e,o,i);if(s.ci?.fixedBuildModules&&s.ci?.fixedBuildModules.length){logger.info("Use `fixedBuildModules` configuration to build...");return{buildEntries:filterActivedEntriesByModule(s.entryMap,s.ci?.fixedBuildModules),newEvolveOptions:s}}if(logger.info("Dynamicly checking code changed modules ..."),!r){const e=s.ci?.basedBranch||"origin/master";r=await getCommitIdOfBranch(e),logger.info(`Resolving base branch "${e}" commit hash "${r}" ...`)}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:s};const p=await resolveEntryMapInputFiles(e,s.entryMap),c=await getBuildEntryFiles(e,a,p,s.webpack?.resolve?.alias,s.ci?.graphTreeNodeFilter);logger.debug(`To build entry files: \n${JSON.stringify(c,null,2)}`);return{buildEntries:await filterActivedEntriesByEntryInputs(e,s.entryMap,c),newEvolveOptions:s}}export const startDynamicBuild=async(e,r,t,o={},i)=>{const{buildEntries:n,newEvolveOptions:s}=await dynamicCheckBuildEntryMap(e,r,t,o,i);await envVerify(e,s);const a=normalizeEvolveEntryMap(n,s.entryMap),l=splitToEntryGroup(a,s,ignoreEntryOptionKeys,!1);if(!l.length)return logger.warn("No build entries provided!"),[];await createGlobalCompiler(!1,s);const{threads:p={}}=s,c=getMaxProcessTasks(l.length,p?.maxThreads);logger.info(`Start dynamic build with (${chalk(["magenta"])(String(c))}) workers`);const m=createThreadWorker({...p,maxThreads:c}),
|
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{formatSpinnerText}from"../helpers/format-spinner-text.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{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";export async function getBuildEntryFiles(e,r,t,o,i){const n=[],s=[];for(const e of t)r.includes(e)?n.push(e):s.push(e);if(i&&logger.info("Use custom graph traverse filter",moduleName),s.length){const t=await traverseGraph({input:s,projectCwd:e,treeNodeFilter:i||(()=>!0),lessImportOptions:{projectCwd:e,aliases:o}});if(!t)return n;logger.debug(`DependencyGraph:\n${JSON.stringify(t,null,2)}`);for(const e of s){const o=t[e]||[];arraysIntersect(o,r)&&n.push(e)}}return n}export async function dynamicCheckBuildEntryMap(e,r,t,o,i){const n={projectCwd:e,command:"build",resolve:requireResolve},s=await loadEvolveConfig(n,e,o,i);if(s.ci?.fixedBuildModules&&s.ci?.fixedBuildModules.length){logger.info("Use `fixedBuildModules` configuration to build...");return{buildEntries:filterActivedEntriesByModule(s.entryMap,s.ci?.fixedBuildModules),newEvolveOptions:s}}if(logger.info("Dynamicly checking code changed modules ..."),!r){const e=s.ci?.basedBranch||"origin/master";r=await getCommitIdOfBranch(e),logger.info(`Resolving base branch "${e}" commit hash "${r}" ...`)}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:s};const p=await resolveEntryMapInputFiles(e,s.entryMap),c=await getBuildEntryFiles(e,a,p,s.webpack?.resolve?.alias,s.ci?.graphTreeNodeFilter);logger.debug(`To build entry files: \n${JSON.stringify(c,null,2)}`);return{buildEntries:await filterActivedEntriesByEntryInputs(e,s.entryMap,c),newEvolveOptions:s}}export const startDynamicBuild=async(e,r,t,o={},i)=>{const{buildEntries:n,newEvolveOptions:s}=await dynamicCheckBuildEntryMap(e,r,t,o,i);await envVerify(e,s);const a=normalizeEvolveEntryMap(n,s.entryMap),l=splitToEntryGroup(a,s,ignoreEntryOptionKeys,!1);if(!l.length)return logger.warn("No build entries provided!"),[];await createGlobalCompiler(!1,s);const{threads:p={}}=s,c=getMaxProcessTasks(l.length,p?.maxThreads);logger.info(`Start dynamic build with (${chalk(["magenta"])(String(c))}) workers`);const m=createThreadWorker({...p,maxThreads:c}),f=new Listr([],{concurrent:c,exitOnError:!0,renderer:isCI()?void 0:CustomListrRenderer}),d=[];for(const r of l){const t=Object.values(r)?.[0]?.groupName||"",n=Object.keys(r);let s=`Group ${chalk(["magenta"])(t)} $STATUS \n${formatSpinnerText(n)}`;isCI()&&(s=`Group ${chalk(["magenta"])(t)} compiling... \n${formatSpinnerText(n)}`),f.add({title:s,task:async()=>{const r=await m.startBuildWorker({projectCwd:e,entryKeys:n,serializedEvolveOptions:jsonSerializer.stringify(o),configLoaderOptions:i});d.push(r)}})}if(f.tasks.length)try{await f.run()}catch(e){throw m.terminate(),e}return m.terminate(),d};
|
@@ -1 +1 @@
|
|
1
|
-
import{configLoggerStdWriteSteam,loggerSimpleStdWriteSteam,requireResolve}from"@flatjs/common";import{ignoreEntryOptionKeys}from"../constants.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=>{configLoggerStdWriteSteam();const{projectCwd:r,entryKeys:o,serializedEvolveOptions:t,configLoaderOptions:i,messagePort:
|
1
|
+
import{configLoggerStdWriteSteam,loggerSimpleStdWriteSteam,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:r,entryKeys:o,serializedEvolveOptions:t,configLoaderOptions:i,messagePort:s}=e,n={projectCwd:r,command:"build",resolve:requireResolve},p=jsonSerializer.parse(t)||{},l=await loadEvolveConfig(n,r,p,i),a=o.map((e=>new RegExp(`^${e}$`))),m=filterActivedEntriesByModule(l.entryMap,a),d=normalizeEvolveEntryMap(m,l.entryMap),f=splitToEntryGroup(d,l,ignoreEntryOptionKeys,!1);return prepareBuild(f[0],l).then((e=>(isCI()||loggerSimpleStdWriteSteam.postMessage(s),e)))};
|
package/dist/main/start-build.js
CHANGED
@@ -1 +1 @@
|
|
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{CustomListrRenderer}from"../helpers/custom-listr-renderer.js";import{filterActivedEntriesByModule}from"../helpers/filter-actived-entries.js";import{formatSpinnerText}from"../helpers/format-spinner-text.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{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";export const startBuild=async(r,e,t={},o)=>{const i={projectCwd:r,command:"build",resolve:requireResolve},s=await loadEvolveConfig(i,r,t,o);await envVerify(r,s);const
|
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{formatSpinnerText}from"../helpers/format-spinner-text.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{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";export const startBuild=async(r,e,t={},o)=>{const i={projectCwd:r,command:"build",resolve:requireResolve},s=await loadEvolveConfig(i,r,t,o);await envVerify(r,s);const n=filterActivedEntriesByModule(s.entryMap,e),a=normalizeEvolveEntryMap(n,s.entryMap),l=splitToEntryGroup(a,s,ignoreEntryOptionKeys,!1);if(!l.length)return logger.warn("No build entries provided!"),[];await createGlobalCompiler(!1,s);const{threads:m={}}=s,p=getMaxProcessTasks(l.length,m?.maxThreads);logger.info(`Start standard build with (${chalk(["magenta"])(String(p))}) workers`);const c=createThreadWorker({...m,maxThreads:p}),f=new Listr([],{concurrent:p,exitOnError:!0,renderer:isCI()?void 0:CustomListrRenderer}),d=[];for(const e of l){const i=Object.values(e)?.[0]?.groupName||"",s=Object.keys(e);let n=`Group ${chalk(["magenta"])(i)} $STATUS \n${formatSpinnerText(s)}`;isCI()&&(n=`Group ${chalk(["magenta"])(i)} compiling... \n${formatSpinnerText(s)}`),f.add({title:n,task:async()=>{const e=await c.startBuildWorker({projectCwd:r,entryKeys:s,serializedEvolveOptions:jsonSerializer.stringify(t),configLoaderOptions:o});d.push(e)}})}if(f.tasks.length)try{await f.run()}catch(r){throw c.terminate(),r}return c.terminate(),d};
|
@@ -1 +1 @@
|
|
1
|
-
import{logger}from"@flatjs/common";import{moduleName}from"../constants.js";import{printInfo}from"../helpers/print-log.js";import{imageMinimizer}from"./image-minimizer.js";import{terserMinimizer}from"./terser-minimizer.js";export const createMinimizers=(i,r)=>{const e=[];if(i)return logger.debug("Ignore minimizer plugin for `serve` mode",moduleName),e;if(!1===r?.minimizer)return printInfo("Note `minimizer` has been disabled for now"),e;if(r?.minimizer?.imageMin){const i=imageMinimizer();i&&e.push(i)}const m=terserMinimizer(r?.minimizer?.terserOptions||{});return e.push(m),e};
|
1
|
+
import{logger}from"@flatjs/common";import{moduleName}from"../constants.js";import{printInfo}from"../helpers/print-log.js";import{imageMinimizer}from"./image-minimizer.js";import{terserMinimizer}from"./terser-minimizer.js";export const createMinimizers=(i,r)=>{const e=[];if(i)return logger.debug("Ignore minimizer plugin for `serve` mode",moduleName),e;if(!1===r?.minimizer)return printInfo("Note `minimizer` has been disabled for now"),e;if(r?.minimizer?.imageMin){const i=imageMinimizer();i&&e.push(i)}if(!1===r?.minimizer?.terserOptions)return e;const m=terserMinimizer(r?.minimizer?.terserOptions||{});return e.push(m),e};
|
@@ -78,7 +78,7 @@ export interface EvolveEntryItemOption extends MultiHtmlCDNEntryItem {
|
|
78
78
|
* ```
|
79
79
|
* @default undefined
|
80
80
|
*/
|
81
|
-
output?: Configuration['output']
|
81
|
+
output?: Omit<Required<Configuration>['output'], 'chunkFilename' | 'cssChunkFilename'>;
|
82
82
|
}
|
83
83
|
export type EvolveEntryMapContent = {
|
84
84
|
entry: [string, ...string[]];
|
@@ -62,7 +62,10 @@ export interface FlatEvolveWebpackOptions extends Pick<Configuration, 'performan
|
|
62
62
|
* @default `terser` minimizer has been enabled fro `production`
|
63
63
|
*/
|
64
64
|
minimizer?: false | {
|
65
|
-
|
65
|
+
/**
|
66
|
+
* Allow to disable terser minimizer. or customized terser options.
|
67
|
+
*/
|
68
|
+
terserOptions?: false | TerserMinimizerOptions;
|
66
69
|
/**
|
67
70
|
* @default false
|
68
71
|
*/
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@flatjs/evolve",
|
3
|
-
"version": "2.1.0-next.
|
3
|
+
"version": "2.1.0-next.24",
|
4
4
|
"license": "MIT",
|
5
5
|
"type": "module",
|
6
6
|
"exports": {
|
@@ -44,13 +44,14 @@
|
|
44
44
|
"@flatjs/common": "2.1.0-next.8",
|
45
45
|
"@flatjs/evolve-preset-babel": "2.1.0-next.8",
|
46
46
|
"@flatjs/forge-postcss-plugin-pixel": "2.1.0-next.8",
|
47
|
-
"@flatjs/graph": "2.1.0-next.
|
48
|
-
"@flatjs/mock": "2.1.0-next.
|
47
|
+
"@flatjs/graph": "2.1.0-next.11",
|
48
|
+
"@flatjs/mock": "2.1.0-next.12",
|
49
49
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
|
50
50
|
"@types/babel__core": "^7.20.5",
|
51
51
|
"babel-loader": "^9.1.3",
|
52
52
|
"better-opn": "^3.0.2",
|
53
53
|
"case-sensitive-paths-webpack-plugin": "^2.4.0",
|
54
|
+
"ci-info": "^4.0.0",
|
54
55
|
"css-loader": "^7.1.2",
|
55
56
|
"cssnano": "^7.0.3",
|
56
57
|
"express": "^4.19.2",
|
@@ -84,7 +85,7 @@
|
|
84
85
|
"@dimjs/model": "1.2.3",
|
85
86
|
"@dimjs/model-react": "1.2.3",
|
86
87
|
"@dimjs/utils": "1.5.1",
|
87
|
-
"@flatjs/testing": "2.1.0-next.
|
88
|
+
"@flatjs/testing": "2.1.0-next.9",
|
88
89
|
"@hyperse/eslint-config-hyperse": "^1.0.10",
|
89
90
|
"@swc/core": "1.6.6",
|
90
91
|
"@types/express": "4.17.21",
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import { type FlatEvolveDevServerOptions } from '../types/types-dev-server.js';
|
2
|
-
import { EntryMapItem } from '../types/types-entry-map.js';
|
3
|
-
import { type FlatEvolveOptions } from '../types/types-options.js';
|
4
|
-
/**
|
5
|
-
* Loads the watch options for webpack configuration.
|
6
|
-
*
|
7
|
-
* @param entryMapItemList - The list of entry map items.
|
8
|
-
* @param evolveOptions - The options for the evolve process.
|
9
|
-
* @param originalOptions - The original watch options to be merged with.
|
10
|
-
* @returns The updated watch options for webpack configuration.
|
11
|
-
*/
|
12
|
-
export declare const loadWatchOptions: (entryMapItemList: EntryMapItem[], evolveOptions: FlatEvolveOptions, originalOptions?: FlatEvolveDevServerOptions["watchOptions"]) => FlatEvolveDevServerOptions["watchOptions"];
|
@@ -1 +0,0 @@
|
|
1
|
-
import{normalizeEvolveEntryName}from"../helpers/normalize-entry-map.js";export const loadWatchOptions=(e,o,r={})=>{const{ignored:n=[]}=r,{entryMap:t,projectVirtualPath:a}=o;for(const[o]of Object.entries(t)){const r=normalizeEvolveEntryName(o,a);e.findIndex((e=>e[0]===r))<0&&n.push(`**/${r}/**/*`)}return{...r,ignored:n}};
|