@flatjs/evolve 1.8.1-next.102 → 1.8.1-next.104

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @flatjs/evolve
2
2
 
3
+ ## 1.8.1-next.104
4
+
5
+ ### Patch Changes
6
+
7
+ - 3a8aa0b: Add `graphTreeNodeFilter` allow customized filter wihile dynamic build
8
+ - 9f098ad: Bump version
9
+ - Updated dependencies [9f098ad]
10
+ - @flatjs/forge-postcss-plugin-pixel@1.8.1-next.37
11
+ - @flatjs/evolve-preset-babel@1.8.1-next.22
12
+ - @flatjs/common@1.8.1-next.37
13
+ - @flatjs/graph@1.8.1-next.54
14
+ - @flatjs/mock@1.8.1-next.78
15
+
16
+ ## 1.8.1-next.103
17
+
18
+ ### Patch Changes
19
+
20
+ - 663e3c4: bump version
21
+ - Updated dependencies [663e3c4]
22
+ - @flatjs/forge-postcss-plugin-pixel@1.8.1-next.36
23
+ - @flatjs/evolve-preset-babel@1.8.1-next.21
24
+ - @flatjs/common@1.8.1-next.36
25
+ - @flatjs/graph@1.8.1-next.53
26
+ - @flatjs/mock@1.8.1-next.77
27
+
3
28
  ## 1.8.1-next.102
4
29
 
5
30
  ### Patch Changes
@@ -2,7 +2,7 @@ import { type PartialDeep } from 'type-fest';
2
2
  import { type ConfigLoaderOptions } from '../load-config/load-evolve-config.js';
3
3
  import { type FlatEvolveOptions } from '../types/types-options.js';
4
4
  import { type EvolveBuildResult } from './start-one-entry-build.js';
5
- export declare function getBuildEntryFiles(projectCwd: string, diffFiles: string[], allEntryInputs: string[], resolveAlias?: Record<string, string>): Promise<string[]>;
5
+ export declare function getBuildEntryFiles(projectCwd: string, diffFiles: string[], allEntryInputs: string[], resolveAlias?: Record<string, string>, graphTreeNodeFilter?: (moduleId: string) => boolean): Promise<string[]>;
6
6
  /**
7
7
  * Dynamic check which entry modules need to build.
8
8
  * @returns
@@ -1 +1 @@
1
- import{isAbsolute,join}from"node:path";import{getDiffFiles,getCommitIdOfBranch}from"@armit/git";import{createThreadPool}from"@armit/worker-threads";import{arraysIntersect,chalk,logger,requireResolve}from"@flatjs/common";import{traverseGraph}from"@flatjs/graph";import Listr from"listr";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{resolveEntryMapInputFiles}from"../helpers/resolve-entry-map-input-files.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{envVerify}from"./env-verify.js";import{getWorkerPath}from"./get-worker-path.js";export async function getBuildEntryFiles(e,t,r,i){const o=[],n=[];for(const e of r)t.includes(e)?o.push(e):n.push(e);if(n.length){const r=await traverseGraph({input:n,projectCwd:e,treeNodeFilter:()=>!0,lessImportOptions:{projectCwd:e,aliases:i}});if(!r)return o;logger.debug(`DependencyGraph:\n${JSON.stringify(r,null,2)}`);for(const e of n){const i=r[e]||[];arraysIntersect(i,t)&&o.push(e)}}return o}export async function dynamicCheckBuildEntryMap(e,t,r,i,o){const n={command:"build",resolve:requireResolve},s=await loadEvolveConfig(n,e,i,o);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 ..."),!t){const e=s.ci?.basedBranch||"origin/master";t=await getCommitIdOfBranch(e),logger.info(`Resolving base branch "${e}" commit hash "${t}" ...`)}let a=t?await getDiffFiles(t,r):[];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 c=await resolveEntryMapInputFiles(e,s.entryMap),d=await getBuildEntryFiles(e,a,c,s.webpack?.resolve?.alias);logger.debug(`To build entry files: \n${JSON.stringify(d,null,2)}`);return{buildEntries:await filterActivedEntriesByEntryInputs(e,s.entryMap,d),newEvolveOptions:s}}export const startDynamicBuild=async(e,t,r,i={},o)=>{const{buildEntries:n,newEvolveOptions:s}=await dynamicCheckBuildEntryMap(e,t,r,i,o);await envVerify(e,s);const a=Object.keys(n);if(!a.length)return logger.warn("No build entries providered!"),[];const l=getMaxProcessTasks(a.length,s.maxProcesses);logger.info(`Start dynamic build with (${chalk(["magenta"])(String(l))}) workers:\n${JSON.stringify({buildEntries:a},null,2)}`);const c=getWorkerPath(),d=await createThreadPool(c,{size:l}),f=new Listr([],{concurrent:l,exitOnError:!0}),g=[];for(const[t]of Object.entries(n))f.add({title:`Build module ${chalk(["magenta"])(t)} ...`,task:async()=>{const r=await d.startBuildWorker(e,t,jsonSerializer.stringify(i),o);g.push(r)}});return f.tasks.length&&await f.run(),d.pool.terminate(),g};
1
+ import{isAbsolute,join}from"node:path";import{getDiffFiles,getCommitIdOfBranch}from"@armit/git";import{createThreadPool}from"@armit/worker-threads";import{arraysIntersect,chalk,logger,requireResolve}from"@flatjs/common";import{traverseGraph}from"@flatjs/graph";import Listr from"listr";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{resolveEntryMapInputFiles}from"../helpers/resolve-entry-map-input-files.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{envVerify}from"./env-verify.js";import{getWorkerPath}from"./get-worker-path.js";export async function getBuildEntryFiles(e,t,r,i,o){const n=[],s=[];for(const e of r)t.includes(e)?n.push(e):s.push(e);if(s.length){const r=await traverseGraph({input:s,projectCwd:e,treeNodeFilter:o||(()=>!0),lessImportOptions:{projectCwd:e,aliases:i}});if(!r)return n;logger.debug(`DependencyGraph:\n${JSON.stringify(r,null,2)}`);for(const e of s){const i=r[e]||[];arraysIntersect(i,t)&&n.push(e)}}return n}export async function dynamicCheckBuildEntryMap(e,t,r,i,o){const n={command:"build",resolve:requireResolve},s=await loadEvolveConfig(n,e,i,o);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 ..."),!t){const e=s.ci?.basedBranch||"origin/master";t=await getCommitIdOfBranch(e),logger.info(`Resolving base branch "${e}" commit hash "${t}" ...`)}let a=t?await getDiffFiles(t,r):[];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 c=await resolveEntryMapInputFiles(e,s.entryMap),d=await getBuildEntryFiles(e,a,c,s.webpack?.resolve?.alias,s.ci?.graphTreeNodeFilter);logger.debug(`To build entry files: \n${JSON.stringify(d,null,2)}`);return{buildEntries:await filterActivedEntriesByEntryInputs(e,s.entryMap,d),newEvolveOptions:s}}export const startDynamicBuild=async(e,t,r,i={},o)=>{const{buildEntries:n,newEvolveOptions:s}=await dynamicCheckBuildEntryMap(e,t,r,i,o);await envVerify(e,s);const a=Object.keys(n);if(!a.length)return logger.warn("No build entries providered!"),[];const l=getMaxProcessTasks(a.length,s.maxProcesses);logger.info(`Start dynamic build with (${chalk(["magenta"])(String(l))}) workers:\n${JSON.stringify({buildEntries:a},null,2)}`);const c=getWorkerPath(),d=await createThreadPool(c,{size:l}),f=new Listr([],{concurrent:l,exitOnError:!0}),g=[];for(const[t]of Object.entries(n))f.add({title:`Build module ${chalk(["magenta"])(t)} ...`,task:async()=>{const r=await d.startBuildWorker(e,t,jsonSerializer.stringify(i),o);g.push(r)}});return f.tasks.length&&await f.run(),d.pool.terminate(),g};
@@ -5,6 +5,12 @@
5
5
  * 3. Normally build manually using (`flat build evolve -m "a;b"`)
6
6
  */
7
7
  export type FlatEvolveCI = {
8
+ /**
9
+ * A function used to determine if a module (also include root node) should be included in the dependency tree
10
+ * @param moduleId The imported module
11
+ * @default `() => true`
12
+ */
13
+ graphTreeNodeFilter?: (moduleId: string) => boolean;
8
14
  /**
9
15
  * The build module patterns, `Highest Priority First`
10
16
  * Support "a;b;c" RegExp pattern; `new RegExp(`${pattern}`).test(entryKey)`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatjs/evolve",
3
- "version": "1.8.1-next.102",
3
+ "version": "1.8.1-next.104",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -37,18 +37,18 @@
37
37
  "typecheck": "tsc --project ./tsconfig.json --noEmit"
38
38
  },
39
39
  "dependencies": {
40
- "@armit/config-loader": "^0.0.51",
41
- "@armit/file-utility": "^0.0.28",
42
- "@armit/git": "^0.0.36",
43
- "@armit/package": "^0.0.45",
44
- "@armit/worker-threads": "^0.0.5",
45
- "@babel/core": "7.22.9",
46
- "@flatjs/common": "1.8.1-next.35",
47
- "@flatjs/evolve-preset-babel": "1.8.1-next.20",
48
- "@flatjs/forge-postcss-plugin-pixel": "1.8.1-next.35",
49
- "@flatjs/graph": "1.8.1-next.52",
50
- "@flatjs/mock": "1.8.1-next.76",
51
- "@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
40
+ "@armit/config-loader": "^0.0.53",
41
+ "@armit/file-utility": "^0.0.30",
42
+ "@armit/git": "^0.0.38",
43
+ "@armit/package": "^0.0.47",
44
+ "@armit/worker-threads": "^0.0.7",
45
+ "@babel/core": "7.22.10",
46
+ "@flatjs/common": "1.8.1-next.37",
47
+ "@flatjs/evolve-preset-babel": "1.8.1-next.22",
48
+ "@flatjs/forge-postcss-plugin-pixel": "1.8.1-next.37",
49
+ "@flatjs/graph": "1.8.1-next.54",
50
+ "@flatjs/mock": "1.8.1-next.78",
51
+ "@pmmmwh/react-refresh-webpack-plugin": "0.5.11",
52
52
  "@types/babel__core": "7.20.1",
53
53
  "babel-loader": "9.1.3",
54
54
  "babel-merge": "3.0.0",
@@ -59,43 +59,43 @@
59
59
  "cssnano": "6.0.1",
60
60
  "express": "4.18.2",
61
61
  "fork-ts-checker-webpack-plugin": "8.0.0",
62
- "happy-dom": "10.6.3",
62
+ "happy-dom": "10.10.0",
63
63
  "html-webpack-plugin": "5.5.3",
64
64
  "image-minimizer-webpack-plugin": "3.8.3",
65
- "less": "4.1.3",
65
+ "less": "4.2.0",
66
66
  "less-loader": "11.1.3",
67
67
  "listr": "0.14.3",
68
68
  "lodash": "4.17.21",
69
69
  "mini-css-extract-plugin": "2.7.6",
70
- "postcss": "8.4.27",
70
+ "postcss": "8.4.28",
71
71
  "postcss-loader": "7.3.3",
72
72
  "react-refresh": "0.14.0",
73
73
  "svgo": "3.0.2",
74
74
  "tarjan-graph": "3.0.0",
75
75
  "terser-webpack-plugin": "5.3.9",
76
76
  "tsconfig-paths-webpack-plugin": "4.1.0",
77
- "type-fest": "^4.1.0",
77
+ "type-fest": "^4.2.0",
78
78
  "webpack": "5.88.2",
79
79
  "webpack-bundle-analyzer": "4.9.0",
80
80
  "webpack-dev-server": "4.15.1",
81
81
  "webpack-sources": "3.2.3"
82
82
  },
83
83
  "devDependencies": {
84
- "@armit/eslint-config-bases": "^0.0.23",
85
- "@flatjs/testing": "1.8.1-next.37",
86
- "@swc/core": "1.3.74",
84
+ "@armit/eslint-config-bases": "^0.0.25",
85
+ "@flatjs/testing": "1.8.1-next.39",
86
+ "@swc/core": "1.3.77",
87
87
  "@types/express": "4.17.17",
88
88
  "@types/listr": "0.14.4",
89
- "@types/node": "20.4.6",
89
+ "@types/node": "20.5.0",
90
90
  "@vitest/coverage-istanbul": "0.34.1",
91
91
  "@vitest/ui": "0.34.1",
92
- "eslint": "8.46.0",
92
+ "eslint": "8.47.0",
93
93
  "imagemin-gifsicle": "7.0.0",
94
94
  "imagemin-jpegtran": "7.0.0",
95
95
  "imagemin-pngquant": "9.0.2",
96
96
  "imagemin-svgo": "10.0.1",
97
97
  "npm-run-all": "4.1.5",
98
- "prettier": "3.0.0",
98
+ "prettier": "3.0.2",
99
99
  "react": "18.2.0",
100
100
  "rimraf": "5.0.1",
101
101
  "swc-unplugin-ts": "1.0.2",