@flatjs/evolve 1.8.1-next.30 → 1.8.1-next.32

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @flatjs/evolve
2
2
 
3
+ ## 1.8.1-next.32
4
+
5
+ ### Patch Changes
6
+
7
+ - 69b3166: Add `maxProcesses` for production build
8
+ - 68642bf: update minify.ts to minify.mjs
9
+ - Updated dependencies [68642bf]
10
+ - @flatjs/forge-postcss-plugin-pixel@1.8.1-next.17
11
+ - @flatjs/evolve-preset-babel@1.8.1-next.7
12
+ - @flatjs/common@1.8.1-next.17
13
+ - @flatjs/mock@1.8.1-next.29
14
+
15
+ ## 1.8.1-next.31
16
+
17
+ ### Patch Changes
18
+
19
+ - b318549: Add array chunks & evolve split entryMap into multi chunks
20
+ - Updated dependencies [b318549]
21
+ - @flatjs/common@1.8.1-next.16
22
+ - @flatjs/forge-postcss-plugin-pixel@1.8.1-next.16
23
+ - @flatjs/mock@1.8.1-next.28
24
+ - @flatjs/evolve-preset-babel@1.8.1-next.6
25
+
3
26
  ## 1.8.1-next.30
4
27
 
5
28
  ### 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%"};
@@ -0,0 +1,7 @@
1
+ import { type EvolveEntryMap } from '../types/types-entry-map.js';
2
+ /**
3
+ * Split entryMap into multi entryMap with a `size`
4
+ * @param entryMap
5
+ * @param size
6
+ */
7
+ export declare const chunkEntryMap: (entryMap: EvolveEntryMap, size?: number) => EvolveEntryMap[];
@@ -0,0 +1 @@
1
+ import{arrayChunk}from"@flatjs/common";export const chunkEntryMap=(r,o=2)=>{const n=Object.keys(r),t=arrayChunk(n,o),c=[];for(const o of t){const n=o.reduce(((o,n)=>({...o,[n]:r[n]})),{});c.push(n)}return c};
@@ -1,5 +1,6 @@
1
1
  export * from './allow-px2rem-for-module.js';
2
2
  export * from './assert-only-single-entry-item.js';
3
+ export * from './chunk-entry-map.js';
3
4
  export * from './enable-bundle-hashname-for-module.js';
4
5
  export * from './get-bundle-file-name.js';
5
6
  export * from './get-html-plugin-config.js';
@@ -1 +1 @@
1
- export*from"./allow-px2rem-for-module.js";export*from"./assert-only-single-entry-item.js";export*from"./enable-bundle-hashname-for-module.js";export*from"./get-bundle-file-name.js";export*from"./get-html-plugin-config.js";export*from"./get-pacakge-dir.js";export*from"./merge-babel-options.js";export*from"./normalize-entry-map.js";export*from"./open-page.js";export*from"./print-log.js";export*from"./refresh-evolve-mock-options.js";export*from"./script-injects.js";export*from"./should-enable-react-fast-refresh.js";export*from"./split-to-multi-compiler.js";
1
+ export*from"./allow-px2rem-for-module.js";export*from"./assert-only-single-entry-item.js";export*from"./chunk-entry-map.js";export*from"./enable-bundle-hashname-for-module.js";export*from"./get-bundle-file-name.js";export*from"./get-html-plugin-config.js";export*from"./get-pacakge-dir.js";export*from"./merge-babel-options.js";export*from"./normalize-entry-map.js";export*from"./open-page.js";export*from"./print-log.js";export*from"./refresh-evolve-mock-options.js";export*from"./script-injects.js";export*from"./should-enable-react-fast-refresh.js";export*from"./split-to-multi-compiler.js";
@@ -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,mergeOptions}from"@flatjs/common";import webpack from"webpack";import{loadWebpackConfig}from"../create-webpack/load-webpack-config.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=[],i=ensureSlash(e[Math.floor(Math.random()*e.length)],!0);for(const[r,e]of Object.entries(o)){const o={[r]:e},s=e.options?.useRelativeAssetPath;n.push(startSingleEntryBuild(o,mergeOptions(t,{webpack:{publicPath:s?"auto":i}})))}return Promise.all(n)};
1
+ import{cpus}from"node:os";import{ensureSlash,logger,mergeOptions,chalk}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=(t,e)=>Math.max(1,"string"==typeof e&&e.endsWith("%")?Math.round(cpus().length*Number(e.slice(0,-1))/100):Number(e)||t),startSingleEntryBuild=(t,e)=>{const r=loadWebpackConfig("production",t,e),o=splitToMultiCompilerConfigs(t,r,e);if(o.length>1)throw new Error("startSingleEntryBuild() only support `compiler` at a time");const n=o[0];return new Promise(((t,r)=>{webpack(n,((o,s)=>{if(o)return r(o);const i=s?.toJson();return i?.errors?.length?r(i.errors):e.rejectWarnings&&i?.warnings?.length?r(i.warnings):void t({name:n.name,warningStats:i?.warnings})}))}))};export const prepareBuild=async(t,e,r)=>{await envVerify(t,r);const o=r.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(e,(a=Object.keys(e).length,l=r.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 t of i){logger.info(`Build task: ${chalk(["magenta"])(JSON.stringify(Object.keys(t)))}`,moduleName);const e=[];for(const[o,s]of Object.entries(t)){const t={[o]:s},i=s.options?.useRelativeAssetPath;e.push(startSingleEntryBuild(t,mergeOptions(r,{webpack:{publicPath:i?"auto":n}})))}const o=await Promise.all(e);s.push(...o)}return s};
@@ -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.30",
3
+ "version": "1.8.1-next.32",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -25,7 +25,7 @@
25
25
  "build": "rimraf dist && tsc -p ./tsconfig.build.json && npm run minify",
26
26
  "?build-release": "When https://github.com/atlassian/changesets/issues/432 has a solution we can remove this trick",
27
27
  "build-release": "yarn build && rimraf ./_release && yarn pack && mkdir ./_release && tar zxvf ./package.tgz --directory ./_release && rm ./package.tgz",
28
- "minify": "ts-node ../../scripts/minify.ts --dest=dist",
28
+ "minify": "node ../../scripts/minify.mjs --dest=dist",
29
29
  "codegen": "graphql-codegen --config ./codegen.cjs",
30
30
  "clean": "rimraf --no-glob ./dist ./coverage ./__data__ ./config/__data__ ./_release ./tsconfig.tsbuildinfo",
31
31
  "lint": "eslint . --ext .ts,.mts,.tsx,.js,.jsx,.cjs,.mjs --cache --cache-location ../../.cache/eslint/evolve.eslintcache",
@@ -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.15",
44
- "@flatjs/evolve-preset-babel": "1.8.1-next.6",
45
- "@flatjs/forge-postcss-plugin-pixel": "1.8.1-next.15",
46
- "@flatjs/mock": "1.8.1-next.27",
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.29",
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.12",
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",