@flatjs/evolve 2.1.2 → 2.1.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.
@@ -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{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),m=await getBuildEntryFiles(e,a,p,s.webpack?.resolve?.alias,s.ci?.graphTreeNodeFilter);logger.debug(`To build entry files: \n${JSON.stringify(m,null,2)}`);return{buildEntries:await filterActivedEntriesByEntryInputs(e,s.entryMap,m),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,m=getMaxProcessTasks(l.length,p?.maxThreads);logger.info(`Start dynamic build with (${chalk(["magenta"])(String(m))}) workers`);const c=createThreadWorker({...p,maxThreads:m}),f=new Listr([],{concurrent:m,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 c.startBuildWorker({projectCwd:e,entryKeys:n,serializedEvolveOptions:jsonSerializer.stringify(o),configLoaderOptions:i,groupName:t});d.push(r)}})}if(f.tasks.length)try{await f.run()}catch(e){throw c.terminate(),e}return c.terminate(),d};
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}" ...`)}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:s};const m=await resolveEntryMapInputFiles(e,s.entryMap),p=await getBuildEntryFiles(e,a,m,s.webpack?.resolve?.alias,s.ci?.graphTreeNodeFilter);logger.debug(`To build entry files: \n${JSON.stringify(p,null,2)}`);return{buildEntries:await filterActivedEntriesByEntryInputs(e,s.entryMap,p),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:m={}}=s,p=getMaxProcessTasks(l.length,m?.maxThreads);logger.info(`Start dynamic 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 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 c.startBuildWorker({projectCwd:e,entryKeys:n,serializedEvolveOptions:jsonSerializer.stringify(o),configLoaderOptions:i,groupName:t});d.push(r)}})}if(f.tasks.length)try{await f.run()}catch(e){throw c.terminate(),e}return c.terminate(),d};
@@ -0,0 +1,12 @@
1
+ import { Compiler } from 'webpack';
2
+ import { EntryMapItem } from '../../types/types-entry-map.js';
3
+ /**
4
+ * The MultiHtmlModifyPlugin class is responsible for modifying the HTML output of the webpack compiler.
5
+ * It hooks into the compilation process and replaces occurrences of "<%= title %>" with the title specified in the options.
6
+ */
7
+ export declare class MultiHtmlModifyPlugin {
8
+ private pluginName;
9
+ private entryMapItemList;
10
+ constructor(list: EntryMapItem[]);
11
+ apply(compiler: Compiler): void;
12
+ }
@@ -0,0 +1 @@
1
+ import HtmlWebpackPlugin from"html-webpack-plugin";import{ensureSlash}from"@flatjs/common";const getCurrentEntryOptions=(t=[],i)=>{const e=t.find((t=>i.includes(ensureSlash(t[0],!0))));return e?e[1]?.options:void 0};export class MultiHtmlModifyPlugin{constructor(t){this.pluginName="MultiHtmlModifyPlugin",this.entryMapItemList=t}apply(t){t.hooks.compilation.tap(this.pluginName,(t=>{HtmlWebpackPlugin.getHooks(t).beforeEmit.tapAsync(this.pluginName,((t,i)=>{const e=getCurrentEntryOptions(this.entryMapItemList,t.outputName);/<%= title %>/.test(t.html)&&(t.html=t.html.replace(/<%= title %>/g,e?.title||"")),i(null,t)}))}))}}
@@ -1 +1 @@
1
- import HtmlWebpackPlugin from"html-webpack-plugin";import{existsSync}from"node:fs";import{logger}from"@flatjs/common";import{allowPx2remForModule}from"../../helpers/allow-px2rem-for-module.js";import{getHtmlPluginConfig}from"../../helpers/get-html-plugin-config.js";import{normalizeTemplateInjectTokens}from"../../helpers/normalize-template-inject-tokens.js";import{findEnvCdn}from"../../helpers/script-injects.js";const minifyOpts={minifyJS:!0,removeComments:!0,collapseWhitespace:!0,collapseBooleanAttributes:!1};export const createMultiHtmlWebpackPlugin=(e,t,l,i)=>{const n=l[0],[,o]=n,m=[],{options:r}=o,p=e?"development":"production",s=l.map((e=>e[0]));for(const e of i){const l={mode:p,envCdn:findEnvCdn(t.multiHtmlCdn,e)},i=normalizeTemplateInjectTokens(l,r);let o=getHtmlPluginConfig("templatePath",l,r?.templatePath).replace("{0}",e.trim());existsSync(o)||(logger.warn(`The template file ${o} is not exists, use \`prod\` instead!`),o=getHtmlPluginConfig("templatePath",l,r?.templatePath).replace("{0}","prod")),m.push(new HtmlWebpackPlugin({inject:"body",title:getHtmlPluginConfig("title",l,r?.title),chunks:s,minify:!1!==r?.htmlMinify&&!["me","dev"].includes(e)&&minifyOpts,filename:t=>`${t}/index${"prod"===e?"":`-${e}`}.html`,template:o,templateParameters:{title:getHtmlPluginConfig("title",l,r?.title),favicon:getHtmlPluginConfig("favicon",l,r?.favicon),viewport:allowPx2remForModule(n,t)?getHtmlPluginConfig("viewport",l,r?.viewport):"",...i},multiCdn:{env:e,disabled:(r?.excludeCdnEnvs||["me","dev","ntv"]).includes(e)}}))}return m};
1
+ import HtmlWebpackPlugin from"html-webpack-plugin";import{existsSync}from"node:fs";import{logger}from"@flatjs/common";import{allowPx2remForModule}from"../../helpers/allow-px2rem-for-module.js";import{getHtmlPluginConfig}from"../../helpers/get-html-plugin-config.js";import{normalizeTemplateInjectTokens}from"../../helpers/normalize-template-inject-tokens.js";import{findEnvCdn}from"../../helpers/script-injects.js";import{MultiHtmlModifyPlugin}from"./multi-html-modify-plugin.js";const minifyOpts={minifyJS:!0,removeComments:!0,collapseWhitespace:!0,collapseBooleanAttributes:!1};export const createMultiHtmlWebpackPlugin=(e,t,l,i)=>{const n=l[0],[,o]=n,m=[new MultiHtmlModifyPlugin(l)],{options:r}=o,p=e?"development":"production",s=l.map((e=>e[0]));for(const e of i){const l={mode:p,envCdn:findEnvCdn(t.multiHtmlCdn,e)},i=normalizeTemplateInjectTokens(l,r);let o=getHtmlPluginConfig("templatePath",l,r?.templatePath).replace("{0}",e.trim());existsSync(o)||(logger.warn(`The template file ${o} is not exists, use \`prod\` instead!`),o=getHtmlPluginConfig("templatePath",l,r?.templatePath).replace("{0}","prod")),m.push(new HtmlWebpackPlugin({inject:"body",title:getHtmlPluginConfig("title",l,r?.title),chunks:s,minify:!1!==r?.htmlMinify&&!["me","dev"].includes(e)&&minifyOpts,filename:t=>`${t}/index${"prod"===e?"":`-${e}`}.html`,template:o,templateParameters:{title:"<%= title %>",favicon:getHtmlPluginConfig("favicon",l,r?.favicon),viewport:allowPx2remForModule(n,t)?getHtmlPluginConfig("viewport",l,r?.viewport):"",...i},multiCdn:{env:e,disabled:(r?.excludeCdnEnvs||["me","dev","ntv"]).includes(e)}}))}return m};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatjs/evolve",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -35,20 +35,20 @@
35
35
  "typecheck": "tsc --project ./tsconfig.json --noEmit"
36
36
  },
37
37
  "dependencies": {
38
- "@armit/babel-merge": "^0.2.4",
39
- "@armit/config-loader": "^0.2.8",
40
- "@armit/file-utility": "^0.2.4",
41
- "@armit/git": "^0.2.4",
42
- "@armit/package": "^0.2.8",
38
+ "@armit/babel-merge": "^0.2.5",
39
+ "@armit/config-loader": "^0.2.9",
40
+ "@armit/file-utility": "^0.2.5",
41
+ "@armit/git": "^0.2.5",
42
+ "@armit/package": "^0.2.9",
43
43
  "@babel/core": "^7.25.2",
44
44
  "@clack/prompts": "^0.7.0",
45
45
  "@discoveryjs/json-ext": "0.6.1",
46
- "@flatjs/babel-plugin-import": "2.1.2",
47
- "@flatjs/common": "2.1.2",
48
- "@flatjs/evolve-preset-babel": "2.1.2",
49
- "@flatjs/forge-postcss-plugin-pixel": "2.1.2",
50
- "@flatjs/graph": "2.1.2",
51
- "@flatjs/mock": "2.1.2",
46
+ "@flatjs/babel-plugin-import": "2.1.3",
47
+ "@flatjs/common": "2.1.3",
48
+ "@flatjs/evolve-preset-babel": "2.1.3",
49
+ "@flatjs/forge-postcss-plugin-pixel": "2.1.3",
50
+ "@flatjs/graph": "2.1.3",
51
+ "@flatjs/mock": "2.1.3",
52
52
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
53
53
  "@types/babel__core": "^7.20.5",
54
54
  "babel-loader": "^9.1.3",
@@ -56,10 +56,10 @@
56
56
  "case-sensitive-paths-webpack-plugin": "^2.4.0",
57
57
  "ci-info": "^4.0.0",
58
58
  "css-loader": "^7.1.2",
59
- "cssnano": "^7.0.5",
59
+ "cssnano": "^7.0.6",
60
60
  "express": "^4.19.2",
61
61
  "fork-ts-checker-webpack-plugin": "^9.0.2",
62
- "happy-dom": "^14.12.3",
62
+ "happy-dom": "^15.7.3",
63
63
  "html-webpack-plugin": "^5.6.0",
64
64
  "image-minimizer-webpack-plugin": "^4.1.0",
65
65
  "less": "^4.2.0",
@@ -67,20 +67,20 @@
67
67
  "listr": "^0.14.3",
68
68
  "lodash": "^4.17.21",
69
69
  "log-update": "^6.1.0",
70
- "mini-css-extract-plugin": "^2.9.0",
71
- "postcss": "^8.4.41",
70
+ "mini-css-extract-plugin": "^2.9.1",
71
+ "postcss": "^8.4.45",
72
72
  "postcss-loader": "^8.1.1",
73
73
  "react-refresh": "^0.14.2",
74
74
  "svgo": "^3.3.2",
75
75
  "tarjan-graph": "^3.0.0",
76
76
  "terser-webpack-plugin": "^5.3.10",
77
- "tinypool": "^1.0.0",
77
+ "tinypool": "^1.0.1",
78
78
  "tsconfig-paths-webpack-plugin": "^4.1.0",
79
- "type-fest": "^4.24.0",
79
+ "type-fest": "^4.26.0",
80
80
  "typescript": "^5.5.4",
81
- "webpack": "^5.93.0",
81
+ "webpack": "^5.94.0",
82
82
  "webpack-bundle-analyzer": "^4.10.2",
83
- "webpack-dev-server": "^5.0.4",
83
+ "webpack-dev-server": "^5.1.0",
84
84
  "webpack-sources": "^3.2.3"
85
85
  },
86
86
  "devDependencies": {
@@ -88,13 +88,13 @@
88
88
  "@dimjs/model": "2.0.1",
89
89
  "@dimjs/model-react": "2.0.1",
90
90
  "@dimjs/utils": "2.0.1",
91
- "@flatjs/testing": "2.1.2",
91
+ "@flatjs/testing": "2.1.3",
92
92
  "@hyperse/eslint-config-hyperse": "^1.1.3",
93
- "@swc/core": "1.7.10",
93
+ "@swc/core": "1.7.23",
94
94
  "@types/express": "4.17.21",
95
95
  "@types/listr": "0.14.9",
96
- "@types/node": "22.2.0",
97
- "eslint": "^9.9.0",
96
+ "@types/node": "22.5.4",
97
+ "eslint": "^9.9.1",
98
98
  "imagemin-gifsicle": "7.0.0",
99
99
  "imagemin-jpegtran": "7.0.0",
100
100
  "imagemin-pngquant": "10.0.0",