@flatjs/evolve 1.8.1-next.81 → 1.8.1-next.82

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @flatjs/evolve
2
2
 
3
+ ## 1.8.1-next.82
4
+
5
+ ### Patch Changes
6
+
7
+ - 148706e: remove `load-config` from @flatjs/common using armit/config-loader instead
8
+ - Updated dependencies [148706e]
9
+ - Updated dependencies [24e998c]
10
+ - Updated dependencies [f052256]
11
+ - @flatjs/common@1.8.1-next.31
12
+ - @flatjs/mock@1.8.1-next.66
13
+ - @flatjs/graph@1.8.1-next.41
14
+ - @flatjs/forge-postcss-plugin-pixel@1.8.1-next.31
15
+ - @flatjs/evolve-preset-babel@1.8.1-next.15
16
+
3
17
  ## 1.8.1-next.81
4
18
 
5
19
  ### Patch Changes
@@ -1 +1 @@
1
- import{logger}from"@flatjs/common";import ReactRefreshWebpackPlugin from"@pmmmwh/react-refresh-webpack-plugin";import CaseSensitivePathsPlugin from"case-sensitive-paths-webpack-plugin";import ForkTsCheckerWebpackPlugin from"fork-ts-checker-webpack-plugin";import MiniCssExtractPlugin from"mini-css-extract-plugin";import webpack from"webpack";import{BundleAnalyzerPlugin}from"webpack-bundle-analyzer";import{enableBundleHashNameForModule}from"../helpers/enable-bundle-hashname-for-module.js";import{getBundleFileName}from"../helpers/get-bundle-file-name.js";import{shouldEnableReactFastRefresh}from"../helpers/should-enable-react-fast-refresh.js";import{createCleanWebpackPlugin}from"../plugins/clean-webpack/index.js";import{createBuiltinDefineVariables}from"../plugins/define-variable/index.js";import{createModuleFederationPlugin}from"../plugins/module-federation/index.js";import{createHtmlPlugins}from"../plugins/multi-html/index.js";export const createPlugins=async(e,n,a)=>{const[r,i]=n,t=enableBundleHashNameForModule(a,i?.options),l=[new webpack.WatchIgnorePlugin({paths:[/\.d\.[cm]ts$/]}),new CaseSensitivePathsPlugin,new MiniCssExtractPlugin({filename:`[name]/${getBundleFileName("css",e,t)}`,chunkFilename:"[id].[contenthash].css"}),...await createBuiltinDefineVariables(e,a),...createCleanWebpackPlugin(e,n,a),...createModuleFederationPlugin(e,n,a),...createHtmlPlugins(e,n,a)],{analyzer:s,loaderOptions:o}=a,c=(n[1].entry||[]).find((e=>/.vue$/.test(e)));o.runTsChecker&&!c&&l.push(new ForkTsCheckerWebpackPlugin({async:e,typescript:{context:a.projectCwd,memoryLimit:8192}})),s&&l.push(new BundleAnalyzerPlugin({analyzerPort:"auto",analyzerMode:"server",...s}));const u=shouldEnableReactFastRefresh(e,n,a);u&&l.push(new ReactRefreshWebpackPlugin({overlay:!1})),!u&&e&&logger.warn(`The HMR has disabled cause of ("${r}":"moduleFederation")`);const m=a.webpack?.plugins||[];return l.concat(m)};
1
+ import{logger}from"@flatjs/common";import ReactRefreshWebpackPlugin from"@pmmmwh/react-refresh-webpack-plugin";import CaseSensitivePathsPlugin from"case-sensitive-paths-webpack-plugin";import ForkTsCheckerWebpackPlugin from"fork-ts-checker-webpack-plugin";import MiniCssExtractPlugin from"mini-css-extract-plugin";import webpack from"webpack";import{BundleAnalyzerPlugin}from"webpack-bundle-analyzer";import{enableBundleHashNameForModule}from"../helpers/enable-bundle-hashname-for-module.js";import{getBundleFileName}from"../helpers/get-bundle-file-name.js";import{shouldEnableReactFastRefresh}from"../helpers/should-enable-react-fast-refresh.js";import{createCleanWebpackPlugin}from"../plugins/clean-webpack/index.js";import{createBuiltinDefineVariables}from"../plugins/define-variable/index.js";import{createModuleFederationPlugin}from"../plugins/module-federation/index.js";import{createHtmlPlugins}from"../plugins/multi-html/index.js";export const createPlugins=async(e,n,a)=>{const[r,i]=n,t=enableBundleHashNameForModule(a,i?.options),l=[new webpack.WatchIgnorePlugin({paths:[/\.d\.[cm]ts$/]}),new CaseSensitivePathsPlugin,new MiniCssExtractPlugin({filename:`[name]/${getBundleFileName("css",e,t)}`,chunkFilename:"[id].[contenthash].css"}),...await createBuiltinDefineVariables(e,a),...createCleanWebpackPlugin(e,n,a),...createModuleFederationPlugin(e,n,a),...createHtmlPlugins(e,n,a)],{analyzer:s,loaderOptions:o}=a,c=(n[1].entry||[]).find((e=>/.vue$/.test(e)));o.runTsChecker&&!c&&l.push(new ForkTsCheckerWebpackPlugin({async:e,typescript:{context:a.projectCwd,memoryLimit:8192}})),s&&l.push(new BundleAnalyzerPlugin({analyzerPort:"auto",analyzerMode:"server",...s}));const u=shouldEnableReactFastRefresh(e,n,a);u&&l.push(new ReactRefreshWebpackPlugin({overlay:!1})),!u&&e&&logger.warn(`The HMR has disabled cause of \`"${r}":"moduleFederation"\``);const m=a.webpack?.plugins||[];return l.concat(m)};
@@ -1,4 +1,4 @@
1
- import { type UserConfigExport, type ConfigEnvBase } from '@flatjs/common';
1
+ import { type UserConfigExport, type ConfigEnvBase } from '@armit/config-loader';
2
2
  import { type PartialDeep } from 'type-fest';
3
3
  import { type FlatEvolveOptions } from '../types/types-options.js';
4
4
  export interface EvolveConfigBase extends ConfigEnvBase {
@@ -1 +1 @@
1
- import{defineConfig as myDefineConfig}from"@flatjs/common";export const defineConfig=f=>myDefineConfig(f);
1
+ import{defineConfig as myDefineConfig}from"@armit/config-loader";export const defineConfig=i=>myDefineConfig(i);
@@ -1 +1 @@
1
- import{mergeOptions,logger,searchConfig}from"@flatjs/common";import{configFileName,moduleName}from"../constants.js";import{defaultEvolveOptions}from"../default-options.js";import{refreshEvolveMockOptions}from"../helpers/refresh-evolve-mock-options.js";export const loadEvolveConfig=async(o,e,n={},t={configFile:configFileName,esmLoaderOptions:{externals:["@flatjs/evolve","@flatjs/mock"]}})=>{const{configFile:i,esmLoaderOptions:s}=t,r=await searchConfig(i,e,{esm:{...s,projectCwd:e}});let l={};l="function"==typeof r?.config?r?.config(o):r?.config||{};const f=mergeOptions(defaultEvolveOptions,l),m=mergeOptions(f,n),a=mergeOptions(m,{projectCwd:e}),c="build"===o.command?a:await refreshEvolveMockOptions(e,a,t);return logger.debug(`Load evolve config:\n${JSON.stringify(c,null,2)}`,moduleName),c};
1
+ import{searchConfig}from"@armit/config-loader";import{mergeOptions,logger}from"@flatjs/common";import{configFileName,moduleName}from"../constants.js";import{defaultEvolveOptions}from"../default-options.js";import{refreshEvolveMockOptions}from"../helpers/refresh-evolve-mock-options.js";export const loadEvolveConfig=async(o,e,i={},t={configFile:configFileName,esmLoaderOptions:{externals:["@flatjs/evolve","@flatjs/mock"]}})=>{const{configFile:n,esmLoaderOptions:r}=t,s=await searchConfig(n,e,{esm:{...r,projectCwd:e}});let l={};l="function"==typeof s?.config?s?.config(o):s?.config||{};const m=mergeOptions(defaultEvolveOptions,l),f=mergeOptions(m,i),a=mergeOptions(f,{projectCwd:e}),c="build"===o.command?a:await refreshEvolveMockOptions(e,a,t);return logger.debug(`Load evolve config:\n${JSON.stringify(c,null,2)}`,moduleName),c};
@@ -0,0 +1 @@
1
+ export declare const getWorkerPath: () => string;
@@ -0,0 +1 @@
1
+ import{pathToFileURL}from"node:url";import{getDirname}from"@armit/file-utility";export const getWorkerPath=()=>pathToFileURL(getDirname(import.meta.url,"./start-build-worker.js")).toString();
@@ -1 +1 @@
1
- import{isAbsolute,join}from"node:path";import{pathToFileURL}from"node:url";import{getDirname}from"@armit/file-utility";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";export async function getBuildEntryFiles(e,t,r){const i=[],o=[];for(const e of r)t.includes(e)?i.push(e):o.push(e);if(o.length){const r=await traverseGraph({input:o,projectCwd:e,treeNodeFilter:()=>!0});if(!r)return i;logger.debug(`DependencyGraph:\n${JSON.stringify(r,null,2)}`);for(const e of o){const o=r[e]||[];arraysIntersect(o,t)&&i.push(e)}}return i}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);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=pathToFileURL(getDirname(import.meta.url,"./start-build-worker.js")).toString(),f=await createThreadPool(c,{size:l}),d=new Listr([],{concurrent:l,exitOnError:!0}),u=[];for(const[t]of Object.entries(n))d.add({title:`Build module ${chalk(["magenta"])(t)} ...`,task:async()=>{const r=await f.startBuildWorker(e,t,jsonSerializer.stringify(i),o);u.push(r)}});return d.tasks.length&&await d.run(),f.pool.terminate(),u};
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){const i=[],o=[];for(const e of r)t.includes(e)?i.push(e):o.push(e);if(o.length){const r=await traverseGraph({input:o,projectCwd:e,treeNodeFilter:()=>!0});if(!r)return i;logger.debug(`DependencyGraph:\n${JSON.stringify(r,null,2)}`);for(const e of o){const o=r[e]||[];arraysIntersect(o,t)&&i.push(e)}}return i}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);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(),f=await createThreadPool(c,{size:l}),d=new Listr([],{concurrent:l,exitOnError:!0}),g=[];for(const[t]of Object.entries(n))d.add({title:`Build module ${chalk(["magenta"])(t)} ...`,task:async()=>{const r=await f.startBuildWorker(e,t,jsonSerializer.stringify(i),o);g.push(r)}});return d.tasks.length&&await d.run(),f.pool.terminate(),g};
@@ -1 +1 @@
1
- import{pathToFileURL}from"node:url";import{getDirname}from"@armit/file-utility";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";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=pathToFileURL(getDirname(import.meta.url,"./start-build-worker.js")).toString(),m=await createThreadPool(l,{size:n}),c=new Listr([],{concurrent:n,exitOnError:!0}),d=[];for(const[e]of Object.entries(s))c.add({title:`Build module ${chalk(["magenta"])(e)} ...`,task:async()=>{const i=await m.startBuildWorker(r,e,jsonSerializer.stringify(t),o);d.push(i)}});return c.tasks.length&&await c.run(),m.pool.terminate(),d};
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,6 +1,5 @@
1
1
  import { type TransformOptions } from '@babel/core';
2
2
  import { type PostcssPluginPixelOptions } from '@flatjs/forge-postcss-plugin-pixel';
3
- import { type Options } from 'cssnano';
4
3
  import { type AcceptedPlugin } from 'postcss';
5
4
  import { type ModularImportOption } from './types-modular-import.js';
6
5
  export type BabelInputOptions = Pick<TransformOptions, 'presets' | 'plugins'>;
@@ -51,13 +50,14 @@ export interface RuleSetLoaderOptions {
51
50
  /**
52
51
  * The overrided configurations of `cssnano-preset-default`
53
52
  * sometimes we need to disabled some rules for `default cssnano preset`
53
+ * @link https://www.npmjs.com/package/cssnano-preset-default
54
54
  * @example
55
- * disable `postcss-minify-font-values` rule to avoid transitions from `font-weight:bold` to `font-weight:700`
55
+ * Disable `postcss-minify-font-values` rule to avoid transitions from `font-weight:bold` to `font-weight:700`
56
56
  * ```json
57
57
  * cssnanoOptions: { minifyFontValues: false }
58
58
  * ```
59
59
  */
60
- cssnanoOptions?: Options;
60
+ cssnanoOptions?: Record<string, unknown>;
61
61
  /**
62
62
  * Allow to extends extra plugins of `postcss-loader`
63
63
  * @example `['tailwindcss', {}]`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatjs/evolve",
3
- "version": "1.8.1-next.81",
3
+ "version": "1.8.1-next.82",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -37,16 +37,17 @@
37
37
  "typecheck": "tsc --project ./tsconfig.json --noEmit"
38
38
  },
39
39
  "dependencies": {
40
+ "@armit/config-loader": "^0.0.47",
40
41
  "@armit/file-utility": "^0.0.26",
41
42
  "@armit/git": "^0.0.31",
42
43
  "@armit/package": "^0.0.41",
43
44
  "@armit/worker-threads": "^0.0.3",
44
45
  "@babel/core": "7.22.5",
45
- "@flatjs/common": "1.8.1-next.30",
46
+ "@flatjs/common": "1.8.1-next.31",
46
47
  "@flatjs/evolve-preset-babel": "1.8.1-next.15",
47
- "@flatjs/forge-postcss-plugin-pixel": "1.8.1-next.30",
48
- "@flatjs/graph": "1.8.1-next.40",
49
- "@flatjs/mock": "1.8.1-next.65",
48
+ "@flatjs/forge-postcss-plugin-pixel": "1.8.1-next.31",
49
+ "@flatjs/graph": "1.8.1-next.41",
50
+ "@flatjs/mock": "1.8.1-next.66",
50
51
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
51
52
  "@types/babel__core": "7.20.1",
52
53
  "babel-loader": "9.1.2",
@@ -80,7 +81,7 @@
80
81
  },
81
82
  "devDependencies": {
82
83
  "@armit/eslint-config-bases": "^0.0.21",
83
- "@flatjs/testing": "1.8.1-next.31",
84
+ "@flatjs/testing": "1.8.1-next.32",
84
85
  "@swc/core": "1.3.67",
85
86
  "@types/express": "4.17.17",
86
87
  "@types/listr": "0.14.4",