@flatjs/evolve 2.1.0-next.9 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/compiler/create-global-compiler.d.ts +2 -0
- package/dist/compiler/create-global-compiler.js +1 -0
- package/dist/constants.d.ts +9 -0
- package/dist/constants.js +1 -1
- package/dist/create-webpack/create-externals.d.ts +1 -1
- package/dist/create-webpack/create-externals.js +1 -1
- package/dist/create-webpack/create-optimization.d.ts +1 -1
- package/dist/create-webpack/create-optimization.js +1 -1
- package/dist/create-webpack/create-output.d.ts +1 -1
- package/dist/create-webpack/create-performance.d.ts +1 -1
- package/dist/create-webpack/create-plugins.d.ts +2 -1
- package/dist/create-webpack/create-plugins.js +1 -1
- package/dist/create-webpack/create-resolve.js +1 -1
- package/dist/create-webpack/create-rule-sets.d.ts +1 -1
- package/dist/create-webpack/create-rule-sets.js +1 -1
- package/dist/create-webpack/load-watch-options.d.ts +12 -0
- package/dist/create-webpack/load-watch-options.js +1 -0
- package/dist/create-webpack/load-webpack-config.d.ts +2 -1
- package/dist/create-webpack/load-webpack-config.js +1 -1
- package/dist/create-webpack/rule-sets/rule-assets.d.ts +2 -2
- package/dist/create-webpack/rule-sets/rule-assets.js +1 -1
- package/dist/create-webpack/rule-sets/rule-css.js +1 -1
- package/dist/create-webpack/rule-sets/rule-scripts.d.ts +2 -0
- package/dist/create-webpack/rule-sets/rule-scripts.js +1 -1
- package/dist/create-webpack/types.d.ts +1 -1
- package/dist/default-options.js +1 -1
- package/dist/define-config/define-config.d.ts +2 -2
- package/dist/dev-server/add-compiler-to-dev-server.js +1 -1
- package/dist/dev-server/create-dev-server-compiler-task.d.ts +3 -0
- package/dist/dev-server/create-dev-server-compiler-task.js +1 -0
- package/dist/dev-server/create-dev-server-entries.d.ts +1 -1
- package/dist/dev-server/create-dev-server-entries.js +1 -1
- package/dist/dev-server/create-dev-server.js +1 -1
- package/dist/dev-server/index.d.ts +3 -3
- package/dist/dev-server/index.js +1 -1
- package/dist/dev-server/middlewares/get-bundle-asset.d.ts +1 -1
- package/dist/dev-server/middlewares/get-page-main-html.js +1 -1
- package/dist/dev-server/middlewares/get-page-module-html.js +1 -1
- package/dist/helpers/assert-group-entry-item.d.ts +7 -0
- package/dist/helpers/assert-group-entry-item.js +1 -0
- package/dist/helpers/assert-single-compiler.d.ts +15 -0
- package/dist/helpers/assert-single-compiler.js +1 -0
- package/dist/helpers/check-runtime-env.d.ts +4 -0
- package/dist/helpers/check-runtime-env.js +1 -0
- package/dist/helpers/custom-listr-renderer.d.ts +41 -0
- package/dist/helpers/custom-listr-renderer.js +1 -0
- package/dist/helpers/custom-message-channel.d.ts +17 -0
- package/dist/helpers/custom-message-channel.js +1 -0
- package/dist/helpers/delete-object-keys.d.ts +11 -0
- package/dist/helpers/delete-object-keys.js +1 -0
- package/dist/helpers/flat-entry-map.d.ts +8 -0
- package/dist/helpers/flat-entry-map.js +1 -0
- package/dist/helpers/format-spinner-text.d.ts +8 -0
- package/dist/helpers/format-spinner-text.js +1 -0
- package/dist/helpers/get-bundle-file-name.d.ts +1 -1
- package/dist/helpers/get-runtime-cdn-base.d.ts +2 -0
- package/dist/helpers/get-runtime-cdn-base.js +1 -0
- package/dist/helpers/get-stats-file-name.d.ts +2 -0
- package/dist/helpers/get-stats-file-name.js +1 -0
- package/dist/helpers/index.d.ts +18 -4
- package/dist/helpers/index.js +1 -1
- package/dist/helpers/is-deep-equal.d.ts +9 -0
- package/dist/helpers/is-deep-equal.js +1 -0
- package/dist/helpers/json-serializer.js +1 -1
- package/dist/helpers/merge-babel-options.d.ts +1 -1
- package/dist/helpers/merge-babel-options.js +1 -1
- package/dist/helpers/normalize-check-entry-options.d.ts +10 -0
- package/dist/helpers/normalize-check-entry-options.js +1 -0
- package/dist/helpers/normalize-entry-map.d.ts +1 -0
- package/dist/helpers/normalize-entry-map.js +1 -1
- package/dist/helpers/normalize-entry-module-absolute-path.d.ts +10 -0
- package/dist/helpers/normalize-entry-module-absolute-path.js +1 -0
- package/dist/helpers/normalize-group-name.d.ts +8 -0
- package/dist/helpers/normalize-group-name.js +1 -0
- package/dist/helpers/normalize-template-inject-tokens.d.ts +16 -0
- package/dist/helpers/normalize-template-inject-tokens.js +1 -0
- package/dist/helpers/open-page.js +1 -1
- package/dist/helpers/refresh-evolve-mock-options.js +1 -1
- package/dist/helpers/script-injects.d.ts +1 -1
- package/dist/helpers/split-to-entry-group.d.ts +52 -0
- package/dist/helpers/split-to-entry-group.js +1 -0
- package/dist/helpers/verify-group-entry-options.d.ts +9 -0
- package/dist/helpers/verify-group-entry-options.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/load-config/load-evolve-config.js +1 -1
- package/dist/loaders/loader-icon.cjs +2 -1
- package/dist/main/create-thread-worker.d.ts +29 -14
- package/dist/main/create-thread-worker.js +1 -1
- package/dist/main/index.d.ts +1 -1
- package/dist/main/index.js +1 -1
- package/dist/main/prepare-analyzer.d.ts +9 -0
- package/dist/main/prepare-analyzer.js +1 -0
- package/dist/main/prepare-build.d.ts +4 -3
- package/dist/main/prepare-build.js +1 -1
- package/dist/main/prepare-serve.d.ts +1 -1
- package/dist/main/prepare-serve.js +1 -1
- package/dist/main/start-analyzer.d.ts +10 -0
- package/dist/main/start-analyzer.js +1 -0
- package/dist/main/start-build-dynamic.d.ts +2 -2
- package/dist/main/start-build-dynamic.js +1 -1
- package/dist/main/start-build-worker.d.ts +17 -6
- package/dist/main/start-build-worker.js +1 -1
- package/dist/main/start-build.d.ts +3 -2
- package/dist/main/start-build.js +1 -1
- package/dist/main/start-group-entry-build.d.ts +15 -0
- package/dist/main/start-group-entry-build.js +1 -0
- package/dist/main/start-serve.d.ts +1 -1
- package/dist/main/start-serve.js +1 -1
- package/dist/minimizer/create-minimizers.js +1 -1
- package/dist/minimizer/image-minimizer.js +1 -1
- package/dist/minimizer/terser-minimizer.js +1 -1
- package/dist/plugins/circular-dependency/circular-dependency-plugin.js +1 -1
- package/dist/plugins/clean-webpack/index.d.ts +1 -1
- package/dist/plugins/clean-webpack/index.js +1 -1
- package/dist/plugins/define-variable/define-variable-plugin.js +1 -1
- package/dist/plugins/module-federation/module-federation.d.ts +1 -1
- package/dist/plugins/module-federation/module-federation.js +1 -1
- package/dist/plugins/multi-html/index.d.ts +1 -1
- package/dist/plugins/multi-html/index.js +1 -1
- package/dist/plugins/multi-html/multi-html-cdn-plugin.js +1 -1
- package/dist/plugins/multi-html/multi-html-plugin.d.ts +1 -1
- package/dist/plugins/multi-html/multi-html-plugin.js +1 -1
- package/dist/plugins/stats-webpack/helper-write-stats.d.ts +28 -0
- package/dist/plugins/stats-webpack/helper-write-stats.js +1 -0
- package/dist/plugins/stats-webpack/index.d.ts +12 -0
- package/dist/plugins/stats-webpack/index.js +1 -0
- package/dist/plugins/stats-webpack/stats-webpack-plugin.d.ts +25 -0
- package/dist/plugins/stats-webpack/stats-webpack-plugin.js +1 -0
- package/dist/plugins/ts-checker/ts-checker-guard-plugin.d.ts +13 -0
- package/dist/plugins/ts-checker/ts-checker-guard-plugin.js +1 -0
- package/dist/plugins/ts-checker/ts-checker-plugin.d.ts +1 -2
- package/dist/plugins/ts-checker/ts-checker-plugin.js +1 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.js +1 -1
- package/dist/types/types-analyzer.d.ts +70 -0
- package/dist/types/types-analyzer.js +1 -0
- package/dist/types/types-cli-options.d.ts +12 -0
- package/dist/types/types-cli-options.js +1 -0
- package/dist/types/types-dev-server.d.ts +17 -6
- package/dist/types/types-entry-map.d.ts +19 -1
- package/dist/types/types-global-compiler-options.d.ts +7 -0
- package/dist/types/types-global-compiler-options.js +1 -0
- package/dist/types/types-loader-options.d.ts +31 -9
- package/dist/types/types-options.d.ts +30 -15
- package/dist/types/types-threads-options.d.ts +18 -0
- package/dist/types/types-threads-options.js +1 -0
- package/dist/types/types-webpack.d.ts +5 -2
- package/package.json +66 -64
- package/templates/html-plugin/index-ntv.html +61 -0
- package/dist/dev-server/create-dev-server-compiler-tasks.d.ts +0 -3
- package/dist/dev-server/create-dev-server-compiler-tasks.js +0 -1
- package/dist/helpers/assert-only-single-entry-item.d.ts +0 -7
- package/dist/helpers/assert-only-single-entry-item.js +0 -1
- package/dist/helpers/split-to-multi-compiler.d.ts +0 -8
- package/dist/helpers/split-to-multi-compiler.js +0 -1
- package/dist/main/start-one-entry-build.d.ts +0 -13
- package/dist/main/start-one-entry-build.js +0 -1
- package/dist/plugins/ts-checker/index.d.ts +0 -1
- package/dist/plugins/ts-checker/index.js +0 -1
@@ -1 +1 @@
|
|
1
|
-
import{join}from"node:path";import{ensureSlash}from"@flatjs/common";import
|
1
|
+
import{join}from"node:path";import webpack from"webpack";import{ensureSlash}from"@flatjs/common";import{normalizeEvolveEntryName}from"../../helpers/normalize-entry-map.js";import{injectFederationScripts}from"../../helpers/script-injects.js";import{HtmlInjectScriptPlugin}from"../html-inject-scripts/plugin-html-inject-script.js";import{ExternalTemplateRemotesPlugin}from"./external-template-remotes.js";const normalizeWidgetName=(e="")=>e.replace(/[/-]/g,"_").toLowerCase(),remoteFileName=e=>join(e,"micro-remote-module.js");export const createModuleFederationPlugin=(e,t,o)=>{const r=o.projectVirtualPath,n=o.multiHtmlCdn,i=o.multiHtmlCdnEnvResolver,m=[];for(const o of t){const[t,a]=o,l=a.options?.moduleFederation;if(l){const{remotes:o,exposes:a,...s}=l,c=remoteFileName(t),p=normalizeWidgetName(t),u=(a?Array.isArray(a)?a:[a]:[]).map((e=>{const o={};for(const[r,n]of Object.entries(e))o[r]={...n,name:join(t,n.name.replace(/^\//,""))};return o})),d=(o||[]).map((({name:e,endpoint:t})=>{const o=normalizeEvolveEntryName(e,r),n=normalizeWidgetName(o),i=remoteFileName(o),m=t?ensureSlash(t(e,o),!1):"[window.evolveFetchMicroWidgets()]";return{[n]:`${n}@${m}/${i}`}}));m.push(new webpack.container.ModuleFederationPlugin({...s,name:p,filename:c,remotes:d,exposes:u}),new ExternalTemplateRemotesPlugin),e||m.unshift(new HtmlInjectScriptPlugin([injectFederationScripts(n,i)]))}}return m};
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import { type WebpackPlugin } from '../../create-webpack/types.js';
|
2
2
|
import { type EntryMapItem } from '../../types/types-entry-map.js';
|
3
3
|
import { type FlatEvolveOptions } from '../../types/types-options.js';
|
4
|
-
export declare const createHtmlPlugins: (serveMode: boolean,
|
4
|
+
export declare const createHtmlPlugins: (serveMode: boolean, entryMapItemList: EntryMapItem[], evolveOptions: FlatEvolveOptions) => WebpackPlugin[];
|
@@ -1 +1 @@
|
|
1
|
-
import{FlatEvolveMultiCdnPlugin}from"./multi-html-cdn-plugin.js";import{createMultiHtmlWebpackPlugin}from"./multi-html-plugin.js";export const createHtmlPlugins=(t,l,u)=>{const i=[];if(t||
|
1
|
+
import{FlatEvolveMultiCdnPlugin}from"./multi-html-cdn-plugin.js";import{createMultiHtmlWebpackPlugin}from"./multi-html-plugin.js";export const createHtmlPlugins=(t,l,u)=>{const i=[],n=l[0];if(t||n[1]?.options?.output?.library)return i;const e=Object.keys(u.multiHtmlCdn);return i.push(...createMultiHtmlWebpackPlugin(t,u,l,e)),i.push(new FlatEvolveMultiCdnPlugin(u)),i};
|
@@ -1 +1 @@
|
|
1
|
-
import{basename}from"node:path";import
|
1
|
+
import HtmlWebpackPlugin from"html-webpack-plugin";import{basename}from"node:path";import webpack from"webpack";import{getRuntimeCDNBase}from"../../helpers/get-runtime-cdn-base.js";import{findEnvCdn,httpUrlJoin}from"../../helpers/script-injects.js";export class FlatEvolveMultiCdnPlugin{constructor(e){if(this.pluginName="FlatEvolveMultiCdnPlugin",this.requireFn=webpack.RuntimeGlobals.publicPath,this.config=e.multiHtmlCdn,this.cdnResolver=e.multiHtmlCdnEnvResolver||function cdnResolver(){},!this.config?.prod)throw new Error("We must setup `prod` for each CDN config node!")}apply(e){e.hooks.thisCompilation.tap(this.pluginName,(e=>{e.mainTemplate.hooks.requireExtensions.tap(this.pluginName,((t,n)=>{const i=[];i.push("// Dynamic assets path override(`@flatjs/evolve`) plugin-multi-html-cdn`)");const s=e.chunkGraph?.getTreeRuntimeRequirements(n);return s&&s.has(webpack.RuntimeGlobals.requireScope)&&i.push(webpack.Template.indent(getRuntimeCDNBase(this.config,this.cdnResolver,this.requireFn))),webpack.Template.asString(i)}))})),e.hooks.compilation.tap(this.pluginName,(e=>{HtmlWebpackPlugin.getHooks(e).beforeAssetTagGeneration.tap(this.pluginName,(e=>{const{assets:t,plugin:n,outputName:i}=e,s=n?.options?.chunks||[],r=Array.isArray(s)?s.find((e=>i.includes(e))):s,{userOptions:o}=e.plugin;if(!r)throw new Error("We must have current chunk!");const a=t.js.filter((e=>e.includes(r))),l=t.css.filter((e=>e.includes(r))),p=o.multiCdn,u=t.publicPath,c=a.map((e=>{if(p.disabled)return basename(e);const t=findEnvCdn(this.config,p.env);return httpUrlJoin(t,e.replace(u,""))})),m=l.map((e=>{if(p.disabled)return basename(e);const t=findEnvCdn(this.config,p.env);return httpUrlJoin(t,e.replace(u,""))}));return e.assets.js=c,e.assets.css=m,e}))}))}}
|
@@ -8,4 +8,4 @@ import { type FlatEvolveOptions } from '../../types/types-options.js';
|
|
8
8
|
* @param buildEntryItem the entries for this `build`
|
9
9
|
* @param allEnv
|
10
10
|
*/
|
11
|
-
export declare const createMultiHtmlWebpackPlugin: (serveMode: boolean, evolveOptions: FlatEvolveOptions,
|
11
|
+
export declare const createMultiHtmlWebpackPlugin: (serveMode: boolean, evolveOptions: FlatEvolveOptions, entryMapItemList: EntryMapItem[], allEnv: Array<EvolveMultiCdnEnvType>) => WebpackPlugin[];
|
@@ -1 +1 @@
|
|
1
|
-
import HtmlWebpackPlugin from"html-webpack-plugin";import{allowPx2remForModule}from"../../helpers/allow-px2rem-for-module.js";import{getHtmlPluginConfig}from"../../helpers/get-html-plugin-config.js";import{findEnvCdn}from"../../helpers/script-injects.js";const minifyOpts={minifyJS:!0,removeComments:!0,collapseWhitespace:!0,collapseBooleanAttributes:!1};export const createMultiHtmlWebpackPlugin=(e,t,i
|
1
|
+
import HtmlWebpackPlugin from"html-webpack-plugin";import{existsSync}from"node:fs";import{logger}from"@flatjs/common";import{allowPx2remForModule}from"../../helpers/allow-px2rem-for-module.js";import{getHtmlPluginConfig}from"../../helpers/get-html-plugin-config.js";import{normalizeTemplateInjectTokens}from"../../helpers/normalize-template-inject-tokens.js";import{findEnvCdn}from"../../helpers/script-injects.js";const minifyOpts={minifyJS:!0,removeComments:!0,collapseWhitespace:!0,collapseBooleanAttributes:!1};export const createMultiHtmlWebpackPlugin=(e,t,l,i)=>{const n=l[0],[,o]=n,m=[],{options:r}=o,p=e?"development":"production",s=l.map((e=>e[0]));for(const e of i){const l={mode:p,envCdn:findEnvCdn(t.multiHtmlCdn,e)},i=normalizeTemplateInjectTokens(l,r);let o=getHtmlPluginConfig("templatePath",l,r?.templatePath).replace("{0}",e.trim());existsSync(o)||(logger.warn(`The template file ${o} is not exists, use \`prod\` instead!`),o=getHtmlPluginConfig("templatePath",l,r?.templatePath).replace("{0}","prod")),m.push(new HtmlWebpackPlugin({inject:"body",title:getHtmlPluginConfig("title",l,r?.title),chunks:s,minify:!1!==r?.htmlMinify&&!["me","dev"].includes(e)&&minifyOpts,filename:t=>`${t}/index${"prod"===e?"":`-${e}`}.html`,template:o,templateParameters:{title:getHtmlPluginConfig("title",l,r?.title),favicon:getHtmlPluginConfig("favicon",l,r?.favicon),viewport:allowPx2remForModule(n,t)?getHtmlPluginConfig("viewport",l,r?.viewport):"",...i},multiCdn:{env:e,disabled:(r?.excludeCdnEnvs||["me","dev","ntv"]).includes(e)}}))}return m};
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { Readable } from 'node:stream';
|
2
|
+
import { StatsCompilation } from 'webpack';
|
3
|
+
/**
|
4
|
+
* A readable stream that serializes a StatsCompilation object into a string representation.
|
5
|
+
*/
|
6
|
+
export declare class StatsSerializeStream extends Readable {
|
7
|
+
private indentLevel;
|
8
|
+
private stringifier;
|
9
|
+
/**
|
10
|
+
* Creates an instance of StatsSerializeStream.
|
11
|
+
* @param stats - The StatsCompilation object to be serialized.
|
12
|
+
*/
|
13
|
+
constructor(stats: StatsCompilation);
|
14
|
+
/**
|
15
|
+
* Gets the indentation string based on the current indent level.
|
16
|
+
*/
|
17
|
+
get indent(): string;
|
18
|
+
/**
|
19
|
+
* Implements the _read method required by the Readable stream.
|
20
|
+
*/
|
21
|
+
_read(): void;
|
22
|
+
/**
|
23
|
+
* Generator function that recursively converts an object into a string representation.
|
24
|
+
* @param obj - The object to be serialized.
|
25
|
+
*/
|
26
|
+
_stringify(obj: StatsCompilation): any;
|
27
|
+
}
|
28
|
+
export declare const writeStats: (stats: StatsCompilation, filepath: string) => Promise<unknown>;
|
@@ -0,0 +1 @@
|
|
1
|
+
import{createWriteStream}from"node:fs";import{Readable}from"node:stream";export class StatsSerializeStream extends Readable{constructor(e){super(),this.indentLevel=0,this.stringifier=this._stringify(e)}get indent(){return" ".repeat(this.indentLevel)}_read(){let e=!0;for(;e;){const{value:t,done:i}=this.stringifier.next();i?(this.push(null),e=!1):e=this.push(t)}}*_stringify(e){if("string"==typeof e||"number"==typeof e||"boolean"==typeof e||null===e)yield JSON.stringify(e);else if(Array.isArray(e)){yield"[",this.indentLevel++;let t=!0;for(let i of e)void 0===i&&(i=null),yield`${t?"":","}\n${this.indent}`,yield*this._stringify(i),t=!1;this.indentLevel--,yield e.length?`\n${this.indent}]`:"]"}else{yield"{",this.indentLevel++;let t=!0;const i=Object.entries(e);for(const[e,n]of i)void 0!==n&&(yield`${t?"":","}\n${this.indent}${JSON.stringify(e)}: `,yield*this._stringify(n),t=!1);this.indentLevel--,yield i.length?`\n${this.indent}}`:"}"}}}export const writeStats=(e,t)=>new Promise(((i,n)=>{new StatsSerializeStream(e).on("end",i).on("error",n).pipe(createWriteStream(t))}));
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { type WebpackPlugin } from '../../create-webpack/types.js';
|
2
|
+
import { FlatCliOptions } from '../../types/types-cli-options.js';
|
3
|
+
import { type FlatEvolveOptions } from '../../types/types-options.js';
|
4
|
+
/**
|
5
|
+
* Creates an array of Webpack plugins for generating stats files.
|
6
|
+
*
|
7
|
+
* @param serveMode - A boolean indicating whether the application is running in serve mode.
|
8
|
+
* @param evolveOptions - The options for the evolve package.
|
9
|
+
* @param cliOptions - The options passed through the command-line interface.
|
10
|
+
* @returns An array of Webpack plugins.
|
11
|
+
*/
|
12
|
+
export declare const createStatsWebpackPlugin: (serveMode: boolean, evolveOptions: FlatEvolveOptions, cliOptions?: FlatCliOptions) => WebpackPlugin[];
|
@@ -0,0 +1 @@
|
|
1
|
+
import{StatsWebpackPlugin}from"./stats-webpack-plugin.js";export const createStatsWebpackPlugin=(t,e,a={})=>{const{analyzer:r=!1}=a;return t||!r?[]:[new StatsWebpackPlugin({verbose:!0,projectCwd:e.projectCwd})]};
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { Compiler, Stats, StatsCompilation } from 'webpack';
|
2
|
+
export interface Options {
|
3
|
+
/**
|
4
|
+
* The project root.
|
5
|
+
*/
|
6
|
+
projectCwd?: string;
|
7
|
+
/**
|
8
|
+
* Write Logs to Console
|
9
|
+
* (Always enabled when dry is true)
|
10
|
+
*
|
11
|
+
* default: false
|
12
|
+
*/
|
13
|
+
verbose?: boolean;
|
14
|
+
}
|
15
|
+
export declare class StatsWebpackPlugin {
|
16
|
+
private readonly verbose;
|
17
|
+
private outputPath;
|
18
|
+
private projectCwd;
|
19
|
+
private statsFilename;
|
20
|
+
constructor(options?: Options);
|
21
|
+
apply(compiler: Compiler): void;
|
22
|
+
handleBeforeClean(): void;
|
23
|
+
handleDone(stats: Stats, callback: (error?: Error) => void): Promise<void>;
|
24
|
+
generateStatsFile(stats: StatsCompilation): Promise<void>;
|
25
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
import{rmSync}from"node:fs";import{mkdir}from"node:fs/promises";import{dirname,join,resolve}from"node:path";import{logger}from"@flatjs/common";import{webpackStatsDir}from"../../constants.js";import{getStatsFileName}from"../../helpers/get-stats-file-name.js";import{writeStats}from"./helper-write-stats.js";export class StatsWebpackPlugin{constructor(t={}){this.verbose=!0===t.verbose||!1,this.projectCwd=t.projectCwd||process.cwd(),this.outputPath=join(this.projectCwd,webpackStatsDir)}apply(t){this.handleBeforeClean();t.hooks.done.tapAsync("stats-webpack-plugin",((t,e)=>{this.statsFilename=getStatsFileName(t),this.handleDone(t,e)}))}handleBeforeClean(){rmSync(this.outputPath,{force:!0,recursive:!0})}async handleDone(t,e){try{await this.generateStatsFile(t.toJson()),e()}catch(t){e(t)}}async generateStatsFile(t){const e=resolve(this.outputPath,this.statsFilename);await mkdir(dirname(e),{recursive:!0});try{await writeStats(t,e),this.verbose&&logger.debug(`stats-webpack-plugin: saved stats file to ${e}`)}catch(t){this.verbose&&logger.error(`stats-webpack-plugin: error saving stats file to ${e}: ${t}`)}}}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { type Compiler } from 'webpack';
|
2
|
+
export interface TsCheckerGuardPluginOption {
|
3
|
+
/**
|
4
|
+
* Whether to exit the process when issues is not empty
|
5
|
+
* @default false
|
6
|
+
*/
|
7
|
+
autoExit?: boolean;
|
8
|
+
}
|
9
|
+
export declare class TsCheckerGuardPlugin {
|
10
|
+
private options;
|
11
|
+
constructor(option?: TsCheckerGuardPluginOption);
|
12
|
+
apply(compiler: Compiler): void;
|
13
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
import ForkTsCheckerWebpackPlugin from"fork-ts-checker-webpack-plugin";import{mergeOptions}from"@flatjs/common";export class TsCheckerGuardPlugin{constructor(r={}){this.options=mergeOptions({autoExit:!1},r)}apply(r){ForkTsCheckerWebpackPlugin.getCompilerHooks(r).issues.tap("issues",(r=>{const{autoExit:e}=this.options,o=r.filter((r=>"error"===r.severity));if(e&&o?.length>0)throw new Error(`TS_CHECKER_ERROR: \n ${JSON.stringify(o,null,2)}`);return r}))}}
|
@@ -1,4 +1,3 @@
|
|
1
1
|
import { type WebpackPlugin } from '../../create-webpack/types.js';
|
2
|
-
import { type EntryMapItem } from '../../types/types-entry-map.js';
|
3
2
|
import { type FlatEvolveOptions } from '../../types/types-options.js';
|
4
|
-
export declare const createTsCheckerPlugins: (serveMode: boolean,
|
3
|
+
export declare const createTsCheckerPlugins: (serveMode: boolean, evolveOptions: FlatEvolveOptions) => WebpackPlugin[];
|
@@ -1 +1 @@
|
|
1
|
-
import ForkTsCheckerWebpackPlugin from"fork-ts-checker-webpack-plugin";export const createTsCheckerPlugins=(e,r
|
1
|
+
import ForkTsCheckerWebpackPlugin from"fork-ts-checker-webpack-plugin";import{TsCheckerGuardPlugin}from"./ts-checker-guard-plugin.js";export const createTsCheckerPlugins=(e,r)=>{const{entryMap:t,globalCompilerOptions:c}=r,s=[];let n=!1;for(const[,e]of Object.entries(t)){if((e.entry||[]).find((e=>/.vue$/.test(e)))){n=!0;break}}if(c?.runTsChecker&&!n){const t=new ForkTsCheckerWebpackPlugin({async:e,devServer:!1,issue:{},typescript:{context:r.projectCwd,memoryLimit:8192}});s.push(t),s.push(new TsCheckerGuardPlugin({autoExit:!e}))}return s};
|
package/dist/types/index.d.ts
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
export * from './types-analyzer.js';
|
1
2
|
export * from './types-dev-server.js';
|
2
3
|
export * from './types-entry-map.js';
|
3
4
|
export * from './types-federation.js';
|
5
|
+
export * from './types-global-compiler-options.js';
|
6
|
+
export * from './types-loader-options.js';
|
4
7
|
export * from './types-modular-import.js';
|
5
8
|
export * from './types-multi-html.js';
|
6
9
|
export * from './types-options.js';
|
7
|
-
export * from './types-loader-options.js';
|
8
10
|
export * from './types-webpack.js';
|
package/dist/types/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export*from"./types-dev-server.js";export*from"./types-entry-map.js";export*from"./types-federation.js";export*from"./types-
|
1
|
+
export*from"./types-analyzer.js";export*from"./types-dev-server.js";export*from"./types-entry-map.js";export*from"./types-federation.js";export*from"./types-global-compiler-options.js";export*from"./types-loader-options.js";export*from"./types-modular-import.js";export*from"./types-multi-html.js";export*from"./types-options.js";export*from"./types-webpack.js";
|
@@ -0,0 +1,70 @@
|
|
1
|
+
import { type StatsCompilation } from 'webpack';
|
2
|
+
type ExcludeAssetsPatternFn = (assetName: string) => boolean;
|
3
|
+
type ExcludeAssetsPattern = string | RegExp | ExcludeAssetsPatternFn;
|
4
|
+
interface AddressInfo {
|
5
|
+
address: string;
|
6
|
+
family: string;
|
7
|
+
port: number;
|
8
|
+
}
|
9
|
+
/**
|
10
|
+
* Options for serving and analyzing a project.
|
11
|
+
*/
|
12
|
+
export type AnalyzeServeOptions = {
|
13
|
+
/**
|
14
|
+
* The port number to listen on.
|
15
|
+
* @default 0 (auto-assign a port)
|
16
|
+
*/
|
17
|
+
port?: number;
|
18
|
+
/**
|
19
|
+
* The host address to bind to.
|
20
|
+
* @default '127.0.0.1'
|
21
|
+
*/
|
22
|
+
host?: string;
|
23
|
+
/**
|
24
|
+
* Whether to automatically open the browser.
|
25
|
+
* @default true
|
26
|
+
*/
|
27
|
+
openBrowser?: boolean;
|
28
|
+
/**
|
29
|
+
* The directory where the bundled files are located.
|
30
|
+
*/
|
31
|
+
bundleDir?: string;
|
32
|
+
/**
|
33
|
+
* Module sizes to show in the report by default.
|
34
|
+
* Should be one of "parsed", "stat", or "gzip".
|
35
|
+
* @default 'parsed'
|
36
|
+
*/
|
37
|
+
defaultSizes?: 'parsed' | 'stat' | 'gzip' | undefined;
|
38
|
+
/**
|
39
|
+
* Patterns that will be used to match against asset names to exclude them from the report.
|
40
|
+
* If the pattern is a string, it will be converted to a regular expression via `new RegExp(str)`.
|
41
|
+
* If the pattern is a function, it should have the following signature: `(assetName: string) => boolean`
|
42
|
+
* and should return true to exclude the matching asset.
|
43
|
+
* If multiple patterns are provided, an asset should match at least one of them to be excluded.
|
44
|
+
* @default null
|
45
|
+
*/
|
46
|
+
excludeAssets?: null | ExcludeAssetsPattern | ExcludeAssetsPattern[] | undefined;
|
47
|
+
/**
|
48
|
+
* Content of the HTML title element; or a function of the form `() => string` that provides the content.
|
49
|
+
* @default A function that returns the pretty printed current date and time.
|
50
|
+
*/
|
51
|
+
reportTitle?: string | (() => string) | undefined;
|
52
|
+
/**
|
53
|
+
* The URL printed to the console with server mode.
|
54
|
+
* @default 'http://${listenHost}:${boundAddress.port}'
|
55
|
+
*/
|
56
|
+
analyzerUrl?: (options: {
|
57
|
+
listenPort: string;
|
58
|
+
listenHost: string;
|
59
|
+
boundAddress: AddressInfo;
|
60
|
+
}) => string;
|
61
|
+
};
|
62
|
+
export type BundleStatsMapping = {
|
63
|
+
[statsFilename: string]: StatsCompilation;
|
64
|
+
};
|
65
|
+
export type PromptsOptionValue = {
|
66
|
+
value: string;
|
67
|
+
label: string;
|
68
|
+
hint?: string;
|
69
|
+
};
|
70
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export{};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
export interface FlatCliOptions {
|
2
|
+
/**
|
3
|
+
* Visualize size of webpack output files with an interactive zoomable treemap.
|
4
|
+
*
|
5
|
+
* With build mode `production` only
|
6
|
+
*
|
7
|
+
* This Configuration take effect only during the build phase
|
8
|
+
*
|
9
|
+
* @default false
|
10
|
+
*/
|
11
|
+
analyzer?: boolean;
|
12
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export{};
|
@@ -1,7 +1,6 @@
|
|
1
|
-
import { type SecureContextHttps, type FlatMockOptions } from '@flatjs/mock';
|
2
1
|
import { type RequestHandler } from 'express';
|
3
|
-
import { type
|
4
|
-
import { type
|
2
|
+
import { type ClientConfiguration, Middleware, type WebSocketURL } from 'webpack-dev-server';
|
3
|
+
import { type FlatMockOptions, type SecureContextHttps } from '@flatjs/mock';
|
5
4
|
import { type EvolveEntryMapContent } from './types-entry-map.js';
|
6
5
|
export interface WebpackWatchOptions {
|
7
6
|
/**
|
@@ -13,9 +12,9 @@ export interface WebpackWatchOptions {
|
|
13
12
|
*/
|
14
13
|
followSymlinks?: boolean;
|
15
14
|
/**
|
16
|
-
* Ignore some files from watching
|
15
|
+
* Ignore some files from watching
|
17
16
|
*/
|
18
|
-
ignored?: string
|
17
|
+
ignored?: string[];
|
19
18
|
/**
|
20
19
|
* Enable polling mode for watching.
|
21
20
|
*/
|
@@ -36,7 +35,19 @@ export type FlatEvolveDevServerOptions = {
|
|
36
35
|
* In webpack-dev-server watch mode is enabled by default.
|
37
36
|
* This configuration will be merged into `webpack-dev-server`
|
38
37
|
*/
|
39
|
-
watchOptions?:
|
38
|
+
watchOptions?: WebpackWatchOptions;
|
39
|
+
/**
|
40
|
+
* Provides the ability to execute a custom function and apply custom middleware(s).
|
41
|
+
* https://webpack.js.org/configuration/dev-server/#devserversetupmiddlewares
|
42
|
+
* @default []
|
43
|
+
*/
|
44
|
+
devBeforeMiddlewares?: Middleware[];
|
45
|
+
/**
|
46
|
+
* Provides the ability to execute a custom function and apply custom middleware(s).
|
47
|
+
* https://webpack.js.org/configuration/dev-server/#devserversetupmiddlewares
|
48
|
+
* @default []
|
49
|
+
*/
|
50
|
+
devAfterMiddlewares?: Middleware[];
|
40
51
|
/**
|
41
52
|
* Allow us costomized global serve data injected into `window.GLOBAL = {...globalData}`
|
42
53
|
*/
|
@@ -78,11 +78,29 @@ export interface EvolveEntryItemOption extends MultiHtmlCDNEntryItem {
|
|
78
78
|
* ```
|
79
79
|
* @default undefined
|
80
80
|
*/
|
81
|
-
output?: Configuration['output']
|
81
|
+
output?: Omit<Required<Configuration>['output'], 'chunkFilename' | 'cssChunkFilename'>;
|
82
82
|
}
|
83
83
|
export type EvolveEntryMapContent = {
|
84
84
|
entry: [string, ...string[]];
|
85
85
|
options?: EvolveEntryItemOption;
|
86
|
+
/**
|
87
|
+
* An alias used when grouping builds
|
88
|
+
*/
|
89
|
+
groupName?: string;
|
90
|
+
/**
|
91
|
+
* The basis of the grouping, this configuration takes effect when re-entering a group
|
92
|
+
*
|
93
|
+
* If groupingSource is `manual`, The grouping depends on the manually set groupName
|
94
|
+
*
|
95
|
+
* If groupingSource is `auto`, Grouping depends on whether the entry options are the same
|
96
|
+
*
|
97
|
+
* @default 'auto'
|
98
|
+
*/
|
99
|
+
groupingSource?: 'auto' | 'manual';
|
100
|
+
/**
|
101
|
+
* The base path of the entry module
|
102
|
+
*/
|
103
|
+
entryModuleBase?: string[];
|
86
104
|
};
|
87
105
|
export interface EvolveEntryMap {
|
88
106
|
/**
|
@@ -0,0 +1 @@
|
|
1
|
+
export{};
|
@@ -1,6 +1,7 @@
|
|
1
|
+
import { type AcceptedPlugin } from 'postcss';
|
2
|
+
import { type LoaderContext } from 'webpack';
|
1
3
|
import { type TransformOptions } from '@babel/core';
|
2
4
|
import { type PostcssPluginPixelOptions } from '@flatjs/forge-postcss-plugin-pixel';
|
3
|
-
import { type AcceptedPlugin } from 'postcss';
|
4
5
|
import { type ModularImportOption } from './types-modular-import.js';
|
5
6
|
export type BabelInputOptions = Pick<TransformOptions, 'presets' | 'plugins'>;
|
6
7
|
/**
|
@@ -14,6 +15,34 @@ export type BuiltinBabelOptions = BabelInputOptions & {
|
|
14
15
|
*/
|
15
16
|
usePreset?: 'react' | 'vue';
|
16
17
|
};
|
18
|
+
/**
|
19
|
+
* The configurations for `css-loader` modules
|
20
|
+
* https://github.com/webpack-contrib/css-loader/blob/master/README.md#modules
|
21
|
+
*/
|
22
|
+
export type CssLoaderModules = boolean | 'local' | 'global' | 'pure' | 'icss' | Partial<{
|
23
|
+
auto: boolean | RegExp | ((resourcePath: string) => boolean);
|
24
|
+
mode: 'local' | 'global' | 'pure' | 'icss' | ((resourcePath: any) => 'local' | 'global' | 'pure' | 'icss');
|
25
|
+
localIdentName: string;
|
26
|
+
localIdentContext: string;
|
27
|
+
localIdentHashSalt: string;
|
28
|
+
localIdentHashFunction: string;
|
29
|
+
localIdentHashDigest: string;
|
30
|
+
localIdentRegExp: string | RegExp;
|
31
|
+
getLocalIdent: (context: LoaderContext<any>, localIdentName: string, localName: string) => string;
|
32
|
+
namedExport: boolean;
|
33
|
+
exportGlobals: boolean;
|
34
|
+
exportLocalsConvention: 'as-is' | 'camel-case' | 'camel-case-only' | 'dashes' | 'dashes-only' | ((name: string) => string);
|
35
|
+
exportOnlyLocals: boolean;
|
36
|
+
getJSON: ({ resourcePath, imports, exports, replacements, }: {
|
37
|
+
resourcePath: string;
|
38
|
+
imports: object[];
|
39
|
+
exports: object[];
|
40
|
+
replacements: object[];
|
41
|
+
}) => Promise<void> | void;
|
42
|
+
}>;
|
43
|
+
export type CssLoaderOptions = {
|
44
|
+
modules?: CssLoaderModules;
|
45
|
+
} & Record<string, unknown>;
|
17
46
|
/**
|
18
47
|
* The configurations for `builtin` rule set options
|
19
48
|
*/
|
@@ -28,9 +57,7 @@ export interface RuleSetLoaderOptions {
|
|
28
57
|
* The configurations of `css-loader`
|
29
58
|
* https://github.com/webpack-contrib/css-loader/blob/master/README.md#modules
|
30
59
|
*/
|
31
|
-
cssLoaderOptions?:
|
32
|
-
modules?: Record<string, unknown>;
|
33
|
-
} & Record<string, unknown>;
|
60
|
+
cssLoaderOptions?: CssLoaderOptions;
|
34
61
|
/**
|
35
62
|
* The config for `Less`
|
36
63
|
*/
|
@@ -40,11 +67,6 @@ export interface RuleSetLoaderOptions {
|
|
40
67
|
* @default []
|
41
68
|
*/
|
42
69
|
modularImports?: ModularImportOption[];
|
43
|
-
/**
|
44
|
-
* The value indicates whether runs typescript type checker and linter on separate process.
|
45
|
-
* @default true
|
46
|
-
*/
|
47
|
-
runTsChecker?: boolean;
|
48
70
|
/**
|
49
71
|
* The configration options of `postcss-loader`
|
50
72
|
*/
|
@@ -2,9 +2,11 @@ import { type VerifyPackagePattern } from '@armit/package';
|
|
2
2
|
import { type FlatEvolveCI } from './types-ci.js';
|
3
3
|
import { type FlatEvolveDevServerOptions } from './types-dev-server.js';
|
4
4
|
import { type EvolveEntryMap } from './types-entry-map.js';
|
5
|
+
import { type GlobalCompilerOptions } from './types-global-compiler-options.js';
|
5
6
|
import { type RuleSetLoaderOptions } from './types-loader-options.js';
|
6
|
-
import { type
|
7
|
+
import { type EvolveMultiCDNConfig, type EvolveMultiCDNEnvResolver } from './types-multi-html.js';
|
7
8
|
import { type EvolvePluginOptions } from './types-plugin-options.js';
|
9
|
+
import { type ThreadsOptions } from './types-threads-options.js';
|
8
10
|
import { type FlatEvolveWebpackOptions } from './types-webpack.js';
|
9
11
|
/**
|
10
12
|
* Detect locally installed dependencies that have correctly installed from `package.json` declared version `dependencies`
|
@@ -44,6 +46,10 @@ export interface FlatEvolveOptions {
|
|
44
46
|
* The configurations of `webpack`
|
45
47
|
*/
|
46
48
|
webpack?: FlatEvolveWebpackOptions;
|
49
|
+
/**
|
50
|
+
* The config options of global webpack compiler.
|
51
|
+
*/
|
52
|
+
globalCompilerOptions?: GlobalCompilerOptions;
|
47
53
|
/**
|
48
54
|
* The config options of all rule set loaders.
|
49
55
|
*/
|
@@ -96,20 +102,9 @@ export interface FlatEvolveOptions {
|
|
96
102
|
/**
|
97
103
|
* All webpack entries configuration
|
98
104
|
*/
|
99
|
-
entryMap:
|
100
|
-
|
101
|
-
|
102
|
-
*/
|
103
|
-
analyzer?: Record<string, unknown>;
|
104
|
-
/**
|
105
|
-
* Maximum number of process to run at once for production build
|
106
|
-
* Exact number or a percent of CPUs available (for example "50%").
|
107
|
-
*
|
108
|
-
* If undefined, then all build processes will start in parallel.
|
109
|
-
* Setting this value to 1 will achieve sequential running.
|
110
|
-
* @default 5
|
111
|
-
*/
|
112
|
-
maxProcesses?: number | string;
|
105
|
+
entryMap: {
|
106
|
+
[K in keyof EvolveEntryMap]: Omit<EvolveEntryMap[K], 'groupingSource'>;
|
107
|
+
};
|
113
108
|
/**
|
114
109
|
* For `production` mode, the value indicates if we interrupt compilation process while received "warnings" while evolve `build`
|
115
110
|
* @default false
|
@@ -119,4 +114,24 @@ export interface FlatEvolveOptions {
|
|
119
114
|
* The faster builds, simplified ci pipeline configurations
|
120
115
|
*/
|
121
116
|
ci?: FlatEvolveCI;
|
117
|
+
/**
|
118
|
+
* The configurations of `threads`
|
119
|
+
*/
|
120
|
+
threads?: ThreadsOptions;
|
121
|
+
/**
|
122
|
+
* Control whether each entry is built independently.
|
123
|
+
*
|
124
|
+
* If `true`, each entry will be built independently.
|
125
|
+
*
|
126
|
+
* If `false`, each entries are grouped according to certain rules
|
127
|
+
*
|
128
|
+
* @default false
|
129
|
+
*/
|
130
|
+
isolation?: boolean;
|
131
|
+
/**
|
132
|
+
* The maximum size of an entry group.
|
133
|
+
*
|
134
|
+
* @default 10
|
135
|
+
*/
|
136
|
+
maxEntryGroupSize?: number;
|
122
137
|
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
export interface ThreadsOptions {
|
2
|
+
/**
|
3
|
+
* Minimum number of process to run at once for production build
|
4
|
+
*
|
5
|
+
* @default 1
|
6
|
+
*/
|
7
|
+
minThreads?: number;
|
8
|
+
/**
|
9
|
+
* Maximum number of process to run at once for production build
|
10
|
+
*/
|
11
|
+
maxThreads?: number;
|
12
|
+
/**
|
13
|
+
* Default timeout to wait for close when Thread shuts down, in milliseconds
|
14
|
+
*
|
15
|
+
* @default 60000
|
16
|
+
*/
|
17
|
+
idleTimeout?: number;
|
18
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export{};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { type
|
1
|
+
import { type Configuration, type RuleSetRule } from 'webpack';
|
2
2
|
import { type WebpackPlugin } from '../create-webpack/types.js';
|
3
3
|
import { type TerserMinimizerOptions } from '../minimizer/types.js';
|
4
4
|
/**
|
@@ -62,7 +62,10 @@ export interface FlatEvolveWebpackOptions extends Pick<Configuration, 'performan
|
|
62
62
|
* @default `terser` minimizer has been enabled fro `production`
|
63
63
|
*/
|
64
64
|
minimizer?: false | {
|
65
|
-
|
65
|
+
/**
|
66
|
+
* Allow to disable terser minimizer. or customized terser options.
|
67
|
+
*/
|
68
|
+
terserOptions?: false | TerserMinimizerOptions;
|
66
69
|
/**
|
67
70
|
* @default false
|
68
71
|
*/
|