@flatjs/evolve 1.8.1-next.57 → 1.8.1-next.58
Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md
CHANGED
@@ -1,2 +1,8 @@
|
|
1
1
|
export declare const printInfo: (message: string, silent?: boolean) => void;
|
2
2
|
export declare const printError: (message: string | Error) => void;
|
3
|
+
/**
|
4
|
+
* Do not use `logger` to print webpack compiler error, cause of it may have it's message formatting.
|
5
|
+
* @param errors
|
6
|
+
* @returns
|
7
|
+
*/
|
8
|
+
export declare const printCompilerError: (errors: any) => void;
|
@@ -1 +1 @@
|
|
1
|
-
import{logger}from"@flatjs/common";import{moduleName}from"../constants.js";export const printInfo=(o,r=!1)=>{r||logger.info(o,moduleName)};export const printError=o=>{logger.error(o,moduleName)};
|
1
|
+
import{logger}from"@flatjs/common";import{moduleName}from"../constants.js";export const printInfo=(o,r=!1)=>{r||logger.info(o,moduleName)};export const printError=o=>{logger.error(o,moduleName)};export const printCompilerError=o=>{if(o)if("string"==typeof o)console.log(o);else if(Array.isArray(o))for(const r of o)printCompilerError(r);else if("object"==typeof o){const r=o.stack||o.message;delete o.stack,delete o.message;const e={...o,_newMsg:r};for(const[,o]of Object.entries(e))printCompilerError(o)}};
|
@@ -1 +1 @@
|
|
1
|
-
import{cpus}from"node:os";import{ensureSlash,logger,mergeOptions}from"@flatjs/common";import ora from"ora";import webpack from"webpack";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=(r,t)=>Math.max(1,"string"==typeof t&&t.endsWith("%")?Math.round(cpus().length*Number(t.slice(0,-1))/100):Number(t)||r),startSingleEntryBuild=async(r,t)=>{const o=await loadWebpackConfig("production",r,t),e=splitToMultiCompilerConfigs(r,o,t);if(e.length>1)throw new Error("startSingleEntryBuild() only support `compiler` at a time");const n=e[0];return new Promise(((r,o)=>{webpack(n,((e,s)=>{if(e)return o(e);const i=s?.toJson();return i?.errors?.length?o(i.errors):t.rejectWarnings&&i?.warnings?.length?o(i.warnings):void r({name:n.name,warningStats:i?.warnings})}))}))};export const prepareBuild=async(r,t,o)=>{await envVerify(r,o);const e=o.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),s=[],i=chunkEntryMap(t,getMaxProcessTasks(Object.keys(t).length,o.maxProcesses)),a=i.length;logger.info(`Preparing to run total ${a} tasks...`);for(let r=0;r<a;r++){const t=
|
1
|
+
import{cpus}from"node:os";import{ensureSlash,logger,mergeOptions}from"@flatjs/common";import ora from"ora";import webpack from"webpack";import{loadWebpackConfig}from"../create-webpack/load-webpack-config.js";import{chunkEntryMap}from"../helpers/chunk-entry-map.js";import{printCompilerError}from"../helpers/print-log.js";import{splitToMultiCompilerConfigs}from"../helpers/split-to-multi-compiler.js";import{envVerify}from"./env-verify.js";const getMaxProcessTasks=(r,t)=>Math.max(1,"string"==typeof t&&t.endsWith("%")?Math.round(cpus().length*Number(t.slice(0,-1))/100):Number(t)||r),startSingleEntryBuild=async(r,t)=>{const o=await loadWebpackConfig("production",r,t),e=splitToMultiCompilerConfigs(r,o,t);if(e.length>1)throw new Error("startSingleEntryBuild() only support `compiler` at a time");const n=e[0];return new Promise(((r,o)=>{webpack(n,((e,s)=>{if(e)return o(e);const i=s?.toJson();return i?.errors?.length?o(i.errors):t.rejectWarnings&&i?.warnings?.length?o(i.warnings):void r({name:n.name,warningStats:i?.warnings})}))}))};export const prepareBuild=async(r,t,o)=>{await envVerify(r,o);const e=o.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),s=[],i=chunkEntryMap(t,getMaxProcessTasks(Object.keys(t).length,o.maxProcesses)),a=i.length;logger.info(`Preparing to run total ${a} tasks...`);for(let r=0;r<a;r++){const t=ora(`Run building task id:${r+1} ...`).start();try{const e=i[r],a=[];for(const[r,t]of Object.entries(e)){const e={[r]:t},s=t.options?.useRelativeAssetPath;a.push(startSingleEntryBuild(e,mergeOptions(o,{webpack:{publicPath:s?"auto":n}})))}const p=await Promise.all(a);s.push(...p),t.succeed()}catch(r){printCompilerError(r),t.fail()}}return s};
|