@flatjs/evolve 1.8.1-next.31 → 1.8.1-next.33

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @flatjs/evolve
2
2
 
3
+ ## 1.8.1-next.33
4
+
5
+ ### Patch Changes
6
+
7
+ - 56bddb7: imporved print logging for build entries
8
+ - @flatjs/mock@1.8.1-next.30
9
+
10
+ ## 1.8.1-next.32
11
+
12
+ ### Patch Changes
13
+
14
+ - 69b3166: Add `maxProcesses` for production build
15
+ - 68642bf: update minify.ts to minify.mjs
16
+ - Updated dependencies [68642bf]
17
+ - @flatjs/forge-postcss-plugin-pixel@1.8.1-next.17
18
+ - @flatjs/evolve-preset-babel@1.8.1-next.7
19
+ - @flatjs/common@1.8.1-next.17
20
+ - @flatjs/mock@1.8.1-next.29
21
+
3
22
  ## 1.8.1-next.31
4
23
 
5
24
  ### Patch Changes
@@ -1 +1 @@
1
- export const defaultEvolveOptions={projectCwd:process.cwd(),projectVirtualPath:"flatjs/evolve",rejectWarnings:!1,devServer:{autoOpen:!0,mockOptions:{mockBaseDir:"mocks"},middlewares:[],watchOptions:{poll:1e3,ignored:/node_modules/,aggregateTimeout:500},defaultServeGlobalData:()=>Promise.resolve({})},webpack:{target:["web","es5"],plugins:[],ruleSets:[],publicPath:"auto",externals:{vue:"Vue",react:"React","react-dom":"ReactDOM"},enableBundleHashName:!0},loaderOptions:{assetDataUrlMaxSize:4096,babelOptions:{usePreset:"react",plugins:[],presets:[]},runTsChecker:!0,lessOptions:{},cssnanoOptions:{},pixelOptions:{rootValue:{px:100,rpx:1},outputUnit:"rem"},modularImports:[]},entryMap:{},multiHtmlCdn:{},multiHtmlCdnEnvResolver:function cdnResolver(){},needVerifyPackages:{},packageInstallChecker:{enabled:!1,detectModules:["@dimjs/*"],throwError:!1,showAllInstalledGraph:!0}};
1
+ export const defaultEvolveOptions={projectCwd:process.cwd(),projectVirtualPath:"flatjs/evolve",rejectWarnings:!1,devServer:{autoOpen:!0,mockOptions:{mockBaseDir:"mocks"},middlewares:[],watchOptions:{poll:1e3,ignored:/node_modules/,aggregateTimeout:500},defaultServeGlobalData:()=>Promise.resolve({})},webpack:{target:["web","es5"],plugins:[],ruleSets:[],publicPath:"auto",externals:{vue:"Vue",react:"React","react-dom":"ReactDOM"},enableBundleHashName:!0},loaderOptions:{assetDataUrlMaxSize:4096,babelOptions:{usePreset:"react",plugins:[],presets:[]},runTsChecker:!0,lessOptions:{},cssnanoOptions:{},pixelOptions:{rootValue:{px:100,rpx:1},outputUnit:"rem"},modularImports:[]},entryMap:{},multiHtmlCdn:{},multiHtmlCdnEnvResolver:function cdnResolver(){},needVerifyPackages:{},packageInstallChecker:{enabled:!1,detectModules:["@dimjs/*"],throwError:!1,showAllInstalledGraph:!0},maxProcesses:"50%"};
@@ -2,7 +2,7 @@ import { type EvolveEntryMap } from '../types/types-entry-map.js';
2
2
  import { type FlatEvolveOptions } from '../types/types-options.js';
3
3
  export type EvolveBuildResult = {
4
4
  name?: string;
5
- warningStats?: any;
5
+ warningStats?: unknown;
6
6
  };
7
7
  /**
8
8
  * The main entry to start an evolve `build`
@@ -1 +1 @@
1
- import{ensureSlash,logger,mergeOptions}from"@flatjs/common";import webpack from"webpack";import{moduleName}from"../constants.js";import{loadWebpackConfig}from"../create-webpack/load-webpack-config.js";import{chunkEntryMap}from"../helpers/chunk-entry-map.js";import{splitToMultiCompilerConfigs}from"../helpers/split-to-multi-compiler.js";import{envVerify}from"./env-verify.js";const startSingleEntryBuild=(r,o)=>{const t=loadWebpackConfig("production",r,o),e=splitToMultiCompilerConfigs(r,t,o);if(e.length>1)throw new Error("startSingleEntryBuild() only support `compiler` at a time");const n=e[0];return new Promise(((r,t)=>{webpack(n,((e,i)=>{if(e)return t(e);const s=i?.toJson();return s?.errors?.length?t(s.errors):o.rejectWarnings&&s?.warnings?.length?t(s.warnings):void r({name:n.name,warningStats:s?.warnings})}))}))};export const prepareBuild=async(r,o,t)=>{await envVerify(r,t);const e=t.multiHtmlCdn?.prod||[];if(!e.length)throw new Error('No CDN configuration for env: "prod"');const n=ensureSlash(e[Math.floor(Math.random()*e.length)],!0),i=[],s=chunkEntryMap(o);for(const r of s){logger.info(`build task: ${JSON.stringify(Object.keys(r))}`,moduleName);const o=[];for(const[e,i]of Object.entries(r)){const r={[e]:i},s=i.options?.useRelativeAssetPath;o.push(startSingleEntryBuild(r,mergeOptions(t,{webpack:{publicPath:s?"auto":n}})))}const e=await Promise.all(o);i.push(...e)}return i};
1
+ import{cpus}from"node:os";import{ensureSlash,logger,mergeOptions}from"@flatjs/common";import webpack from"webpack";import{moduleName}from"../constants.js";import{loadWebpackConfig}from"../create-webpack/load-webpack-config.js";import{chunkEntryMap}from"../helpers/chunk-entry-map.js";import{splitToMultiCompilerConfigs}from"../helpers/split-to-multi-compiler.js";import{envVerify}from"./env-verify.js";const getMaxProcessTasks=(e,r)=>Math.max(1,"string"==typeof r&&r.endsWith("%")?Math.round(cpus().length*Number(r.slice(0,-1))/100):Number(r)||e),startSingleEntryBuild=(e,r)=>{const t=loadWebpackConfig("production",e,r),o=splitToMultiCompilerConfigs(e,t,r);if(o.length>1)throw new Error("startSingleEntryBuild() only support `compiler` at a time");const n=o[0];return new Promise(((e,t)=>{webpack(n,((o,s)=>{if(o)return t(o);const i=s?.toJson();return i?.errors?.length?t(i.errors):r.rejectWarnings&&i?.warnings?.length?t(i.warnings):void e({name:n.name,warningStats:i?.warnings})}))}))};export const prepareBuild=async(e,r,t)=>{await envVerify(e,t);const o=t.multiHtmlCdn?.prod||[];if(!o.length)throw new Error('No CDN configuration for env: "prod"');const n=ensureSlash(o[Math.floor(Math.random()*o.length)],!0),s=[],i=chunkEntryMap(r,(a=Object.keys(r).length,l=t.maxProcesses,Math.max(1,"string"==typeof l&&l.endsWith("%")?Math.round(cpus().length*Number(l.slice(0,-1))/100):Number(l)||a)));var a,l;for(const e of i){logger.info({buildEntries:Object.keys(e)},moduleName);const r=[];for(const[o,s]of Object.entries(e)){const e={[o]:s},i=s.options?.useRelativeAssetPath;r.push(startSingleEntryBuild(e,mergeOptions(t,{webpack:{publicPath:i?"auto":n}})))}const o=await Promise.all(r);s.push(...o)}return s};
@@ -1 +1 @@
1
- import{rmSync}from"node:fs";import{relative}from"node:path";import{fileWalkSync}from"@armit/file-utility";import{logger}from"@flatjs/common";import{moduleName}from"../../constants.js";export class CleanWebpackPlugin{constructor(e={}){this.verbose=!0===e.verbose||!1,this.projectCwd=e.projectCwd||process.cwd(),this.cleanStaleWebpackAssets=!0!==e.cleanStaleWebpackAssets&&!1!==e.cleanStaleWebpackAssets||e.cleanStaleWebpackAssets,this.protectWebpackAssets=!0!==e.protectWebpackAssets&&!1!==e.protectWebpackAssets||e.protectWebpackAssets,this.cleanAfterEveryBuildPatterns=Array.isArray(e.cleanAfterEveryBuildPatterns)?e.cleanAfterEveryBuildPatterns:[],this.cleanOnceBeforeBuildPatterns=Array.isArray(e.cleanOnceBeforeBuildPatterns)?e.cleanOnceBeforeBuildPatterns:["**/*"],this.currentAssets=[],this.initialClean=!1,this.outputPath="",this.apply=this.apply.bind(this),this.handleInitial=this.handleInitial.bind(this),this.handleDone=this.handleDone.bind(this),this.removeFiles=this.removeFiles.bind(this)}apply(e){if(!e.options.output||!e.options.output.path)return void logger.warn("clean-webpack-plugin: options.output.path not defined. Plugin disabled...",moduleName);this.outputPath=e.options.output.path;const t=e.hooks;0!==this.cleanOnceBeforeBuildPatterns.length&&t.emit.tap("clean-webpack-plugin",(e=>{this.handleInitial(e)})),t.done.tap("clean-webpack-plugin",(e=>{this.handleDone(e)}))}handleInitial(e){if(this.initialClean)return;e.getStats().hasErrors()||(this.initialClean=!0,this.removeFiles(this.cleanOnceBeforeBuildPatterns))}handleDone(e){if(e.hasErrors())return void(this.verbose&&logger.warn("clean-webpack-plugin: pausing due to webpack errors",moduleName));const t=(e.toJson({assets:!0}).assets||[]).map((e=>e.name)),s=this.currentAssets.filter((e=>!1===t.includes(e)));this.currentAssets=t.sort();const i=[];!0===this.cleanStaleWebpackAssets&&0!==s.length&&i.push(...s),0!==this.cleanAfterEveryBuildPatterns.length&&i.push(...this.cleanAfterEveryBuildPatterns),0!==i.length&&this.removeFiles(i)}removeFiles(e){try{const t=fileWalkSync(e,{absolute:!0,unique:!0,cwd:this.outputPath,dot:!0,ignore:this.protectWebpackAssets?this.currentAssets:[]});for(const e of t)rmSync(e,{force:!0,recursive:!0});this.verbose&&t.forEach((e=>{const t=relative(this.projectCwd,e);logger.info(`clean-webpack-plugin: removed ${t}`,moduleName)}))}catch(e){if(/Cannot delete files\/folders outside the current working directory\./.test(e.message)){throw new Error("clean-webpack-plugin: Cannot delete files/folders outside the current working directory. Can be overridden with the `dangerouslyAllowCleanPatternsOutsideProject` option.")}throw e}}}
1
+ import{rmSync}from"node:fs";import{relative}from"node:path";import{fileWalkSync}from"@armit/file-utility";import{logger}from"@flatjs/common";import{moduleName}from"../../constants.js";export class CleanWebpackPlugin{constructor(e={}){this.verbose=!0===e.verbose||!1,this.projectCwd=e.projectCwd||process.cwd(),this.cleanStaleWebpackAssets=!0!==e.cleanStaleWebpackAssets&&!1!==e.cleanStaleWebpackAssets||e.cleanStaleWebpackAssets,this.protectWebpackAssets=!0!==e.protectWebpackAssets&&!1!==e.protectWebpackAssets||e.protectWebpackAssets,this.cleanAfterEveryBuildPatterns=Array.isArray(e.cleanAfterEveryBuildPatterns)?e.cleanAfterEveryBuildPatterns:[],this.cleanOnceBeforeBuildPatterns=Array.isArray(e.cleanOnceBeforeBuildPatterns)?e.cleanOnceBeforeBuildPatterns:["**/*"],this.currentAssets=[],this.initialClean=!1,this.outputPath="",this.apply=this.apply.bind(this),this.handleInitial=this.handleInitial.bind(this),this.handleDone=this.handleDone.bind(this),this.removeFiles=this.removeFiles.bind(this)}apply(e){if(!e.options.output||!e.options.output.path)return void logger.warn("clean-webpack-plugin: options.output.path not defined. Plugin disabled...",moduleName);this.outputPath=e.options.output.path;const t=e.hooks;0!==this.cleanOnceBeforeBuildPatterns.length&&t.emit.tap("clean-webpack-plugin",(e=>{this.handleInitial(e)})),t.done.tap("clean-webpack-plugin",(e=>{this.handleDone(e)}))}handleInitial(e){if(this.initialClean)return;e.getStats().hasErrors()||(this.initialClean=!0,this.removeFiles(this.cleanOnceBeforeBuildPatterns))}handleDone(e){if(e.hasErrors())return void(this.verbose&&logger.warn("clean-webpack-plugin: pausing due to webpack errors",moduleName));const t=(e.toJson({assets:!0}).assets||[]).map((e=>e.name)),s=this.currentAssets.filter((e=>!1===t.includes(e)));this.currentAssets=t.sort();const i=[];!0===this.cleanStaleWebpackAssets&&0!==s.length&&i.push(...s),0!==this.cleanAfterEveryBuildPatterns.length&&i.push(...this.cleanAfterEveryBuildPatterns),0!==i.length&&this.removeFiles(i)}removeFiles(e){try{const t=fileWalkSync(e,{absolute:!0,unique:!0,cwd:this.outputPath,dot:!0,ignore:this.protectWebpackAssets?this.currentAssets:[]});for(const e of t)rmSync(e,{force:!0,recursive:!0});this.verbose&&t.forEach((e=>{const t=relative(this.projectCwd,e);logger.debug(`clean-webpack-plugin: removed ${t}`,moduleName)}))}catch(e){if(/Cannot delete files\/folders outside the current working directory\./.test(e.message)){throw new Error("clean-webpack-plugin: Cannot delete files/folders outside the current working directory. Can be overridden with the `dangerouslyAllowCleanPatternsOutsideProject` option.")}throw e}}}
@@ -90,6 +90,15 @@ export interface FlatEvolveOptions {
90
90
  * Visualize size of webpack output files with an interactive zoomable treemap.
91
91
  */
92
92
  analyzer?: Record<string, unknown>;
93
+ /**
94
+ * Maximum number of process to run at once for production build
95
+ * Exact number or a percent of CPUs available (for example "50%").
96
+ *
97
+ * If undefined, then all build processes will start in parallel.
98
+ * Setting this value to 1 will achieve sequential running.
99
+ * @default `50%`
100
+ */
101
+ maxProcesses?: number | string;
93
102
  /**
94
103
  * For `production` mode, the value indicates if we interrupt compilation process while received "warnings" while evolve `build`
95
104
  * @default false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatjs/evolve",
3
- "version": "1.8.1-next.31",
3
+ "version": "1.8.1-next.33",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -40,10 +40,10 @@
40
40
  "@armit/file-utility": "^0.0.19",
41
41
  "@armit/package": "^0.0.29",
42
42
  "@babel/core": "7.21.8",
43
- "@flatjs/common": "1.8.1-next.16",
44
- "@flatjs/evolve-preset-babel": "1.8.1-next.6",
45
- "@flatjs/forge-postcss-plugin-pixel": "1.8.1-next.16",
46
- "@flatjs/mock": "1.8.1-next.28",
43
+ "@flatjs/common": "1.8.1-next.17",
44
+ "@flatjs/evolve-preset-babel": "1.8.1-next.7",
45
+ "@flatjs/forge-postcss-plugin-pixel": "1.8.1-next.17",
46
+ "@flatjs/mock": "1.8.1-next.30",
47
47
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
48
48
  "@types/babel__core": "7.20.0",
49
49
  "babel-loader": "9.1.2",
@@ -75,7 +75,7 @@
75
75
  },
76
76
  "devDependencies": {
77
77
  "@armit/eslint-config-bases": "^0.0.16",
78
- "@flatjs/testing": "1.8.1-next.13",
78
+ "@flatjs/testing": "1.8.1-next.14",
79
79
  "@swc/core": "1.3.59",
80
80
  "@types/express": "4.17.17",
81
81
  "@types/node": "20.2.3",