@flatjs/evolve 1.8.1-next.87 → 1.8.1-next.89

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @flatjs/evolve
2
2
 
3
+ ## 1.8.1-next.89
4
+
5
+ ### Patch Changes
6
+
7
+ - 6d16245: bump armit, update `flat update` cli
8
+ - Updated dependencies [6d16245]
9
+ - @flatjs/common@1.8.1-next.33
10
+ - @flatjs/graph@1.8.1-next.46
11
+ - @flatjs/mock@1.8.1-next.69
12
+ - @flatjs/evolve-preset-babel@1.8.1-next.16
13
+ - @flatjs/forge-postcss-plugin-pixel@1.8.1-next.33
14
+
15
+ ## 1.8.1-next.88
16
+
17
+ ### Patch Changes
18
+
19
+ - b4f60b0: Expose `env`.`resolve` to allow dynamic resolve `esm` node modules from `flatjs-evolve.config.ts`
20
+
3
21
  ## 1.8.1-next.87
4
22
 
5
23
  ### Patch Changes
@@ -1,7 +1,24 @@
1
1
  import { type UserConfigExport, type ConfigEnvBase } from '@armit/config-loader';
2
+ import { type requireResolve } from '@flatjs/common';
2
3
  import { type PartialDeep } from 'type-fest';
3
4
  import { type FlatEvolveOptions } from '../types/types-options.js';
4
5
  export interface EvolveConfigBase extends ConfigEnvBase {
5
6
  command: 'build' | 'serve' | 'static';
7
+ /**
8
+ * Expose `env`.`resolve` to allow dynamic resolve `esm` node modules from `flatjs-evolve.config.ts`
9
+ * @example
10
+ * ```ts
11
+ * export default defineConfig((env) => {
12
+ * console.log(env.resolve(import.meta.url, 'tailwindcss'));
13
+ * ...
14
+ * }
15
+ * // Note may you need to change `module` to `ESNext` at your `tsconfig.json`
16
+ * `tsconfig.json`
17
+ * {
18
+ * "module": "ESNext"
19
+ * }
20
+ * ```
21
+ */
22
+ resolve: typeof requireResolve;
6
23
  }
7
24
  export declare const defineConfig: (userConfig: UserConfigExport<PartialDeep<FlatEvolveOptions>, EvolveConfigBase>) => UserConfigExport<import("type-fest/source/partial-deep.js").PartialObjectDeep<FlatEvolveOptions, {}>, EvolveConfigBase>;
@@ -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}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=await loadEvolveConfig({command:"build"},e,i,o);if(n.ci?.fixedBuildModules&&n.ci?.fixedBuildModules.length){logger.info("Use `fixedBuildModules` configuration to build...");return{buildEntries:filterActivedEntriesByModule(n.entryMap,n.ci?.fixedBuildModules),newEvolveOptions:n}}if(logger.info("Dynamicly checking code changed modules ..."),!t){const e=n.ci?.basedBranch||"master";logger.info(`Resolving base branch "${e}" commit hash ...`),t=await getCommitIdOfBranch(e)}let s=t?await getDiffFiles(t,r):[];const a=getGitRoot(e);if(!a)throw new Error(`No .git root (${e}) found`);if(s=s.map((e=>isAbsolute(e)?e:join(a,e))),logger.debug(`Diff files: \n${JSON.stringify(s,null,2)}`),!s.length)return logger.warn("It seems that there are no code files changed."),{buildEntries:{},newEvolveOptions:n};const l=await resolveEntryMapInputFiles(e,n.entryMap),c=await getBuildEntryFiles(e,s,l,n.webpack?.resolve?.alias);logger.debug(`To build entry files: \n${JSON.stringify(c,null,2)}`);return{buildEntries:await filterActivedEntriesByEntryInputs(e,n.entryMap,c),newEvolveOptions:n}}export const startDynamicBuild=async(e,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){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||"master";logger.info(`Resolving base branch "${e}" commit hash ...`),t=await getCommitIdOfBranch(e)}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 +1 @@
1
- import{filterActivedEntriesByModule}from"../helpers/filter-actived-entries.js";import{jsonSerializer}from"../helpers/json-serializer.js";import{normalizeEvolveEntryMap}from"../helpers/normalize-entry-map.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{prepareBuild}from"./prepare-build.js";export const startBuildWorker=async(e,r,o,i)=>{const t=jsonSerializer.parse(o)||{},l=await loadEvolveConfig({command:"build"},e,t,i),n=filterActivedEntriesByModule(l.entryMap,[new RegExp(`^${r}$`)]);if(!Object.keys(n).length)throw new Error(`No build entry resolved via "${r}" on "startBuildWorker"!`);const a=normalizeEvolveEntryMap(n,l.entryMap)[r];return prepareBuild([r,a],l)};
1
+ import{requireResolve}from"@flatjs/common";import{filterActivedEntriesByModule}from"../helpers/filter-actived-entries.js";import{jsonSerializer}from"../helpers/json-serializer.js";import{normalizeEvolveEntryMap}from"../helpers/normalize-entry-map.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{prepareBuild}from"./prepare-build.js";export const startBuildWorker=async(e,r,o,i)=>{const l={command:"build",resolve:requireResolve},t=jsonSerializer.parse(o)||{},n=await loadEvolveConfig(l,e,t,i),a=filterActivedEntriesByModule(n.entryMap,[new RegExp(`^${r}$`)]);if(!Object.keys(a).length)throw new Error(`No build entry resolved via "${r}" on "startBuildWorker"!`);const s=normalizeEvolveEntryMap(a,n.entryMap)[r];return prepareBuild([r,s],n)};
@@ -1 +1 @@
1
- import{createThreadPool}from"@armit/worker-threads";import{chalk,logger}from"@flatjs/common";import Listr from"listr";import{filterActivedEntriesByModule}from"../helpers/filter-actived-entries.js";import{getMaxProcessTasks}from"../helpers/get-max-process-tasks.js";import{jsonSerializer}from"../helpers/json-serializer.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{envVerify}from"./env-verify.js";import{getWorkerPath}from"./get-worker-path.js";export const startBuild=async(r,e,t={},o)=>{const i=await loadEvolveConfig({command:"build"},r,t,o);await envVerify(r,i);const s=filterActivedEntriesByModule(i.entryMap,e),a=Object.keys(s);if(!a.length)return logger.warn("No build entries providered!"),[];const n=getMaxProcessTasks(a.length,i.maxProcesses);logger.info(`Start standard build with (${chalk(["magenta"])(String(n))}) workers:\n${JSON.stringify({buildEntries:a},null,2)}`);const l=getWorkerPath(),c=await createThreadPool(l,{size:n}),m=new Listr([],{concurrent:n,exitOnError:!0}),d=[];for(const[e]of Object.entries(s))m.add({title:`Build module ${chalk(["magenta"])(e)} ...`,task:async()=>{const i=await c.startBuildWorker(r,e,jsonSerializer.stringify(t),o);d.push(i)}});return m.tasks.length&&await m.run(),c.pool.terminate(),d};
1
+ import{createThreadPool}from"@armit/worker-threads";import{chalk,logger,requireResolve}from"@flatjs/common";import Listr from"listr";import{filterActivedEntriesByModule}from"../helpers/filter-actived-entries.js";import{getMaxProcessTasks}from"../helpers/get-max-process-tasks.js";import{jsonSerializer}from"../helpers/json-serializer.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{envVerify}from"./env-verify.js";import{getWorkerPath}from"./get-worker-path.js";export const startBuild=async(e,r,t={},o)=>{const i={command:"build",resolve:requireResolve},s=await loadEvolveConfig(i,e,t,o);await envVerify(e,s);const a=filterActivedEntriesByModule(s.entryMap,r),n=Object.keys(a);if(!n.length)return logger.warn("No build entries providered!"),[];const l=getMaxProcessTasks(n.length,s.maxProcesses);logger.info(`Start standard build with (${chalk(["magenta"])(String(l))}) workers:\n${JSON.stringify({buildEntries:n},null,2)}`);const c=getWorkerPath(),m=await createThreadPool(c,{size:l}),d=new Listr([],{concurrent:l,exitOnError:!0}),f=[];for(const[r]of Object.entries(a))d.add({title:`Build module ${chalk(["magenta"])(r)} ...`,task:async()=>{const i=await m.startBuildWorker(e,r,jsonSerializer.stringify(t),o);f.push(i)}});return d.tasks.length&&await d.run(),m.pool.terminate(),f};
@@ -1 +1 @@
1
- import{logger}from"@flatjs/common";import{filterActivedEntriesByModule}from"../helpers/filter-actived-entries.js";import{normalizeEvolveEntryMap}from"../helpers/normalize-entry-map.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{prepareServe}from"./prepare-serve.js";export const startServe=async(e,r,o={},t)=>{const n=await loadEvolveConfig({command:"serve"},e,o,t),i=filterActivedEntriesByModule(n.entryMap,r),l=Object.keys(i);if(!l.length)return logger.warn("No served entries providered!"),[];logger.info({servedEntries:l});const a=normalizeEvolveEntryMap(i,n.entryMap);return prepareServe(e,a,n)};
1
+ import{logger,requireResolve}from"@flatjs/common";import{filterActivedEntriesByModule}from"../helpers/filter-actived-entries.js";import{normalizeEvolveEntryMap}from"../helpers/normalize-entry-map.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{prepareServe}from"./prepare-serve.js";export const startServe=async(e,r,o={},t)=>{const i={command:"serve",resolve:requireResolve},n=await loadEvolveConfig(i,e,o,t),l=filterActivedEntriesByModule(n.entryMap,r),s=Object.keys(l);if(!s.length)return logger.warn("No served entries providered!"),[];logger.info({servedEntries:s});const v=normalizeEvolveEntryMap(l,n.entryMap);return prepareServe(e,v,n)};
@@ -1 +1 @@
1
- import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{prepareStatic}from"./prepare-static.js";export const startStatic=async(o,t={},a)=>{const r=await loadEvolveConfig({command:"static"},o,t,a);return prepareStatic(o,r)};
1
+ import{requireResolve}from"@flatjs/common";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{prepareStatic}from"./prepare-static.js";export const startStatic=async(o,e={},r)=>{const t={command:"static",resolve:requireResolve},a=await loadEvolveConfig(t,o,e,r);return prepareStatic(o,a)};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatjs/evolve",
3
- "version": "1.8.1-next.87",
3
+ "version": "1.8.1-next.89",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -37,17 +37,17 @@
37
37
  "typecheck": "tsc --project ./tsconfig.json --noEmit"
38
38
  },
39
39
  "dependencies": {
40
- "@armit/config-loader": "^0.0.48",
40
+ "@armit/config-loader": "^0.0.50",
41
41
  "@armit/file-utility": "^0.0.27",
42
42
  "@armit/git": "^0.0.34",
43
- "@armit/package": "^0.0.42",
43
+ "@armit/package": "^0.0.44",
44
44
  "@armit/worker-threads": "^0.0.4",
45
45
  "@babel/core": "7.22.9",
46
- "@flatjs/common": "1.8.1-next.32",
46
+ "@flatjs/common": "1.8.1-next.33",
47
47
  "@flatjs/evolve-preset-babel": "1.8.1-next.16",
48
- "@flatjs/forge-postcss-plugin-pixel": "1.8.1-next.32",
49
- "@flatjs/graph": "1.8.1-next.45",
50
- "@flatjs/mock": "1.8.1-next.68",
48
+ "@flatjs/forge-postcss-plugin-pixel": "1.8.1-next.33",
49
+ "@flatjs/graph": "1.8.1-next.46",
50
+ "@flatjs/mock": "1.8.1-next.69",
51
51
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
52
52
  "@types/babel__core": "7.20.1",
53
53
  "babel-loader": "9.1.3",
@@ -81,7 +81,7 @@
81
81
  },
82
82
  "devDependencies": {
83
83
  "@armit/eslint-config-bases": "^0.0.22",
84
- "@flatjs/testing": "1.8.1-next.33",
84
+ "@flatjs/testing": "1.8.1-next.34",
85
85
  "@swc/core": "1.3.70",
86
86
  "@types/express": "4.17.17",
87
87
  "@types/listr": "0.14.4",