@flatjs/evolve 2.1.0-next.28 → 2.1.0-next.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/constants.d.ts +0 -9
- 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 +1 -2
- 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-webpack-config.d.ts +1 -2
- 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 +0 -2
- 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-tasks.d.ts +3 -0
- package/dist/dev-server/create-dev-server-compiler-tasks.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-only-single-entry-item.d.ts +7 -0
- package/dist/helpers/assert-only-single-entry-item.js +1 -0
- package/dist/helpers/get-bundle-file-name.d.ts +1 -1
- package/dist/helpers/index.d.ts +4 -18
- package/dist/helpers/index.js +1 -1
- package/dist/helpers/json-serializer.js +1 -1
- package/dist/helpers/normalize-entry-map.d.ts +0 -1
- package/dist/helpers/normalize-entry-map.js +1 -1
- 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/should-enable-react-fast-refresh.js +1 -1
- package/dist/helpers/split-to-multi-compiler.d.ts +8 -0
- package/dist/helpers/split-to-multi-compiler.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 +1 -2
- package/dist/main/create-thread-worker.d.ts +14 -29
- 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-build.d.ts +3 -4
- 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-build-dynamic.d.ts +2 -2
- package/dist/main/start-build-dynamic.js +1 -1
- package/dist/main/start-build-worker.d.ts +6 -17
- package/dist/main/start-build-worker.js +1 -1
- package/dist/main/start-build.d.ts +2 -3
- package/dist/main/start-build.js +1 -1
- package/dist/main/start-one-entry-build.d.ts +13 -0
- package/dist/main/start-one-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/types/index.d.ts +1 -3
- package/dist/types/index.js +1 -1
- package/dist/types/types-dev-server.d.ts +6 -17
- package/dist/types/types-entry-map.d.ts +3 -21
- package/dist/types/types-loader-options.d.ts +9 -31
- package/dist/types/types-options.d.ts +15 -30
- package/dist/types/types-webpack.d.ts +2 -5
- package/package.json +61 -69
- package/templates/html-plugin/index-dev.html +2 -2
- package/templates/html-plugin/index-inte.html +2 -2
- package/templates/html-plugin/index-inte2.html +2 -2
- package/templates/html-plugin/index-inte3.html +2 -2
- package/templates/html-plugin/index-inte4.html +2 -2
- package/templates/html-plugin/index-me.html +2 -2
- package/templates/html-plugin/index-prod.html +2 -2
- package/templates/html-plugin/index-rc.html +2 -2
- package/templates/html-plugin/index-uat.html +2 -2
- package/templates/module.html +2 -2
- package/dist/compiler/create-global-compiler.d.ts +0 -2
- package/dist/compiler/create-global-compiler.js +0 -1
- package/dist/create-webpack/load-watch-options.d.ts +0 -12
- package/dist/create-webpack/load-watch-options.js +0 -1
- package/dist/dev-server/create-dev-server-compiler-task.d.ts +0 -3
- package/dist/dev-server/create-dev-server-compiler-task.js +0 -1
- package/dist/helpers/assert-group-entry-item.d.ts +0 -7
- package/dist/helpers/assert-group-entry-item.js +0 -1
- package/dist/helpers/assert-single-compiler.d.ts +0 -15
- package/dist/helpers/assert-single-compiler.js +0 -1
- package/dist/helpers/check-runtime-env.d.ts +0 -4
- package/dist/helpers/check-runtime-env.js +0 -1
- package/dist/helpers/custom-listr-renderer.d.ts +0 -41
- package/dist/helpers/custom-listr-renderer.js +0 -1
- package/dist/helpers/custom-message-channel.d.ts +0 -17
- package/dist/helpers/custom-message-channel.js +0 -1
- package/dist/helpers/delete-object-keys.d.ts +0 -11
- package/dist/helpers/delete-object-keys.js +0 -1
- package/dist/helpers/flat-entry-map.d.ts +0 -8
- package/dist/helpers/flat-entry-map.js +0 -1
- package/dist/helpers/format-spinner-text.d.ts +0 -8
- package/dist/helpers/format-spinner-text.js +0 -1
- package/dist/helpers/get-runtime-cdn-base.d.ts +0 -2
- package/dist/helpers/get-runtime-cdn-base.js +0 -1
- package/dist/helpers/get-stats-file-name.d.ts +0 -2
- package/dist/helpers/get-stats-file-name.js +0 -1
- package/dist/helpers/is-deep-equal.d.ts +0 -9
- package/dist/helpers/is-deep-equal.js +0 -1
- package/dist/helpers/normalize-check-entry-options.d.ts +0 -10
- package/dist/helpers/normalize-check-entry-options.js +0 -1
- package/dist/helpers/normalize-entry-module-absolute-path.d.ts +0 -10
- package/dist/helpers/normalize-entry-module-absolute-path.js +0 -1
- package/dist/helpers/normalize-group-name.d.ts +0 -8
- package/dist/helpers/normalize-group-name.js +0 -1
- package/dist/helpers/normalize-template-inject-tokens.d.ts +0 -16
- package/dist/helpers/normalize-template-inject-tokens.js +0 -1
- package/dist/helpers/split-to-entry-group.d.ts +0 -52
- package/dist/helpers/split-to-entry-group.js +0 -1
- package/dist/helpers/verify-group-entry-options.d.ts +0 -9
- package/dist/helpers/verify-group-entry-options.js +0 -1
- package/dist/main/prepare-analyzer.d.ts +0 -9
- package/dist/main/prepare-analyzer.js +0 -1
- package/dist/main/start-analyzer.d.ts +0 -10
- package/dist/main/start-analyzer.js +0 -1
- package/dist/main/start-group-entry-build.d.ts +0 -15
- package/dist/main/start-group-entry-build.js +0 -1
- package/dist/plugins/stats-webpack/helper-write-stats.d.ts +0 -28
- package/dist/plugins/stats-webpack/helper-write-stats.js +0 -1
- package/dist/plugins/stats-webpack/index.d.ts +0 -12
- package/dist/plugins/stats-webpack/index.js +0 -1
- package/dist/plugins/stats-webpack/stats-webpack-plugin.d.ts +0 -25
- package/dist/plugins/stats-webpack/stats-webpack-plugin.js +0 -1
- package/dist/plugins/ts-checker/ts-checker-guard-plugin.d.ts +0 -13
- package/dist/plugins/ts-checker/ts-checker-guard-plugin.js +0 -1
- package/dist/plugins/ts-checker/ts-checker-plugin.d.ts +0 -3
- package/dist/plugins/ts-checker/ts-checker-plugin.js +0 -1
- package/dist/types/types-analyzer.d.ts +0 -70
- package/dist/types/types-analyzer.js +0 -1
- package/dist/types/types-cli-options.d.ts +0 -12
- package/dist/types/types-cli-options.js +0 -1
- package/dist/types/types-global-compiler-options.d.ts +0 -7
- package/dist/types/types-global-compiler-options.js +0 -1
- package/dist/types/types-threads-options.d.ts +0 -18
- package/dist/types/types-threads-options.js +0 -1
- package/templates/html-plugin/index-ntv.html +0 -61
package/dist/constants.d.ts
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import { type EvolveEntryItemOption } from './types/types-entry-map.js';
|
2
1
|
export declare const moduleName = "@flatjs/evolve";
|
3
2
|
/**
|
4
3
|
* the configuration file of `flat-evolve`
|
@@ -23,11 +22,3 @@ export declare const devReactFastRefresh: {
|
|
23
22
|
runtime: string;
|
24
23
|
reactRefreshSetup: string;
|
25
24
|
};
|
26
|
-
/**
|
27
|
-
* Array of keys to ignore in the verifyGroupEntryOptions step
|
28
|
-
*/
|
29
|
-
export declare const ignoreEntryOptionKeys: Array<keyof EvolveEntryItemOption>;
|
30
|
-
/**
|
31
|
-
* The directory where the webpack stats files are stored. relative to projectCwd
|
32
|
-
*/
|
33
|
-
export declare const webpackStatsDir = ".cache/stats";
|
package/dist/constants.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const moduleName="@flatjs/evolve";export const configFileName="flatjs-evolve";export const viewportScripts='(function(d){var j;var b=1;var i=1;var h=750;var c=100;function e(s,o){var q=d.document;var l=q.documentElement;var k=navigator.userAgent;var m=k.toLowerCase().indexOf("android")>-1;i=d.devicePixelRatio||1;if(i>3){i=3}if(m){i=1}console.log("current devicePixelRatio:",i);l.setAttribute("data-dpr",i.toString());var p=q.querySelector(\'meta[name="viewport"]\');if(!p){b=1/i;p=q.createElement("meta");p.setAttribute("name","viewport");q.head.appendChild(p);p.setAttribute(["content","width=device-width,user-scalable=no,initial-scale=",b,",maximum-scale=",b,",minimum-scale=",b].join(""))}function n(){var t=document.documentElement.clientWidth;j=t/o*(s/i)*i;q.documentElement.style.fontSize=String(j)+"px"}var r;d.addEventListener("resize",function(){clearTimeout(r);r=setTimeout(n,300)},false);d.addEventListener("onload",n,false);n()}e(c,h);window.fabricViewport={currRem:j,currDpr:i,currScale:b,dpiPX2px:function f(k){return parseFloat(k.toString())/j*100+"px"},px2DPIpx:function a(k){return parseFloat(k.toString())/100*j+"px"},px2rem:function g(k){return parseFloat(k.toString())/100+"rem"}}})(window);';export const polyfill=["https://polyfill.io/v3/polyfill.min.js?features=Array.from%2CArray.isArray%2CArray.of%2CArray.prototype.entries%2CArray.prototype.every%2CArray.prototype.fill%2CArray.prototype.filter%2CArray.prototype.find%2CArray.prototype.findIndex%2CArray.prototype.flat%2CArray.prototype.forEach%2CArray.prototype.flatMap%2CArray.prototype.keys%2CArray.prototype.indexOf%2CArray.prototype.includes%2CArray.prototype.lastIndexOf%2CArray.prototype.map%2CArray.prototype.reduce%2CArray.prototype.reduceRight%2CArray.prototype.some%2CArray.prototype.sort%2CArray.prototype.values%2CArrayBuffer%2CBlob%2CDataView%2CDate.now%2CObject.assign%2CObject.create%2CObject.defineProperties%2CObject.defineProperty%2CObject.entries%2CObject.freeze%2CObject.fromEntries%2CObject.getOwnPropertySymbols%2CObject.getOwnPropertyNames%2CObject.getOwnPropertyDescriptors%2CObject.getOwnPropertyDescriptor%2CObject.getPrototypeOf%2CObject.is%2CObject.isExtensible%2CObject.isFrozen%2CObject.isSealed%2CObject.keys%2CObject.values%2CObject.setPrototypeOf%2CPromise%2CPromise.prototype.finally%2CReflect%2CReflect.apply%2CReflect.construct%2CReflect.defineProperty%2CReflect.deleteProperty%2CReflect.getPrototypeOf%2CReflect.getOwnPropertyDescriptor%2CReflect.get%2CReflect.ownKeys%2CReflect.isExtensible%2CReflect.has%2CReflect.preventExtensions%2CReflect.set%2CReflect.setPrototypeOf%2CSet%2CString.prototype.trimStart%2CString.prototype.trimEnd%2CString.prototype.trim%2CString.prototype.startsWith%2CString.prototype.repeat%2CString.prototype.replaceAll%2CString.prototype.padStart%2CString.prototype.padEnd%2CMap%2CObject.seal%2Cconsole.groupEnd%2Cconsole.group"];export const devReactFastRefresh={runtime:"reactRefreshRuntime",reactRefreshSetup:"reactRefreshSetup"};
|
1
|
+
export const moduleName="@flatjs/evolve";export const configFileName="flatjs-evolve";export const viewportScripts='(function(d){var j;var b=1;var i=1;var h=750;var c=100;function e(s,o){var q=d.document;var l=q.documentElement;var k=navigator.userAgent;var m=k.toLowerCase().indexOf("android")>-1;i=d.devicePixelRatio||1;if(i>3){i=3}if(m){i=1}console.log("current devicePixelRatio:",i);l.setAttribute("data-dpr",i.toString());var p=q.querySelector(\'meta[name="viewport"]\');if(!p){b=1/i;p=q.createElement("meta");p.setAttribute("name","viewport");q.head.appendChild(p);p.setAttribute(["content","width=device-width,user-scalable=no,initial-scale=",b,",maximum-scale=",b,",minimum-scale=",b].join(""))}function n(){var t=document.documentElement.clientWidth;j=t/o*(s/i)*i;q.documentElement.style.fontSize=String(j)+"px"}var r;d.addEventListener("resize",function(){clearTimeout(r);r=setTimeout(n,300)},false);d.addEventListener("onload",n,false);n()}e(c,h);window.fabricViewport={currRem:j,currDpr:i,currScale:b,dpiPX2px:function f(k){return parseFloat(k.toString())/j*100+"px"},px2DPIpx:function a(k){return parseFloat(k.toString())/100*j+"px"},px2rem:function g(k){return parseFloat(k.toString())/100+"rem"}}})(window);';export const polyfill=["https://polyfill.io/v3/polyfill.min.js?features=Array.from%2CArray.isArray%2CArray.of%2CArray.prototype.entries%2CArray.prototype.every%2CArray.prototype.fill%2CArray.prototype.filter%2CArray.prototype.find%2CArray.prototype.findIndex%2CArray.prototype.flat%2CArray.prototype.forEach%2CArray.prototype.flatMap%2CArray.prototype.keys%2CArray.prototype.indexOf%2CArray.prototype.includes%2CArray.prototype.lastIndexOf%2CArray.prototype.map%2CArray.prototype.reduce%2CArray.prototype.reduceRight%2CArray.prototype.some%2CArray.prototype.sort%2CArray.prototype.values%2CArrayBuffer%2CBlob%2CDataView%2CDate.now%2CObject.assign%2CObject.create%2CObject.defineProperties%2CObject.defineProperty%2CObject.entries%2CObject.freeze%2CObject.fromEntries%2CObject.getOwnPropertySymbols%2CObject.getOwnPropertyNames%2CObject.getOwnPropertyDescriptors%2CObject.getOwnPropertyDescriptor%2CObject.getPrototypeOf%2CObject.is%2CObject.isExtensible%2CObject.isFrozen%2CObject.isSealed%2CObject.keys%2CObject.values%2CObject.setPrototypeOf%2CPromise%2CPromise.prototype.finally%2CReflect%2CReflect.apply%2CReflect.construct%2CReflect.defineProperty%2CReflect.deleteProperty%2CReflect.getPrototypeOf%2CReflect.getOwnPropertyDescriptor%2CReflect.get%2CReflect.ownKeys%2CReflect.isExtensible%2CReflect.has%2CReflect.preventExtensions%2CReflect.set%2CReflect.setPrototypeOf%2CSet%2CString.prototype.trimStart%2CString.prototype.trimEnd%2CString.prototype.trim%2CString.prototype.startsWith%2CString.prototype.repeat%2CString.prototype.replaceAll%2CString.prototype.padStart%2CString.prototype.padEnd%2CMap%2CObject.seal%2Cconsole.groupEnd%2Cconsole.group"];export const devReactFastRefresh={runtime:"reactRefreshRuntime",reactRefreshSetup:"reactRefreshSetup"};
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import { type Configuration } from 'webpack';
|
2
2
|
import { type EntryMapItem } from '../types/types-entry-map.js';
|
3
3
|
import { type FlatEvolveWebpackOptions } from '../types/types-webpack.js';
|
4
|
-
export declare const createExternals: (externals
|
4
|
+
export declare const createExternals: (externals: FlatEvolveWebpackOptions['externals'], entryItem: EntryMapItem) => Configuration['externals'];
|
@@ -1 +1 @@
|
|
1
|
-
import{mergeOptions}from"@flatjs/common";export const createExternals=(t={},e)=>{const o=e
|
1
|
+
import{mergeOptions}from"@flatjs/common";export const createExternals=(t={},e)=>{const o=e[1],r=o.options?.externals||{};return mergeOptions(t,r)};
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import { type Configuration } from 'webpack';
|
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 createOptimization: (serveMode: boolean, evolveOptions: FlatEvolveOptions,
|
4
|
+
export declare const createOptimization: (serveMode: boolean, evolveOptions: FlatEvolveOptions, entryItem: EntryMapItem) => Configuration['optimization'];
|
@@ -1 +1 @@
|
|
1
|
-
import{join}from"node:path";import{devReactFastRefresh}from"../constants.js";import{shouldEnableReactFastRefresh}from"../helpers/should-enable-react-fast-refresh.js";import{createMinimizers}from"../minimizer/index.js";export const createOptimization=(e,i,n)=>({nodeEnv:e?"development":"production",chunkIds:"named",moduleIds:"named",runtimeChunk:!!shouldEnableReactFastRefresh(e,n,i)&&{name:
|
1
|
+
import{join}from"node:path";import{devReactFastRefresh}from"../constants.js";import{shouldEnableReactFastRefresh}from"../helpers/should-enable-react-fast-refresh.js";import{createMinimizers}from"../minimizer/index.js";export const createOptimization=(e,i,n)=>({nodeEnv:e?"development":"production",chunkIds:"named",moduleIds:"named",runtimeChunk:!!shouldEnableReactFastRefresh(e,n,i)&&{name:()=>join(n[0],devReactFastRefresh.runtime)},minimize:!1!==i.webpack?.minimizer&&!e,minimizer:createMinimizers(e,i.webpack),splitChunks:{name:!1,chunks:"all",minSize:25e5,cacheGroups:{default:!1,defaultVendors:!1}}});
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import { type Configuration } from 'webpack';
|
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 createOutput: (serveMode: boolean, evolveOptions: FlatEvolveOptions, entryItem: EntryMapItem) => Promise<Configuration[
|
4
|
+
export declare const createOutput: (serveMode: boolean, evolveOptions: FlatEvolveOptions, entryItem: EntryMapItem) => Promise<Configuration['output']>;
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import { type FlatEvolveWebpackOptions } from '../types/types-webpack.js';
|
2
|
-
export declare const createPerformance: (serveMode: boolean, performanceOptions?: FlatEvolveWebpackOptions[
|
2
|
+
export declare const createPerformance: (serveMode: boolean, performanceOptions?: FlatEvolveWebpackOptions['performance']) => FlatEvolveWebpackOptions['performance'];
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import { FlatCliOptions } from '../types/types-cli-options.js';
|
2
1
|
import { type EntryMapItem } from '../types/types-entry-map.js';
|
3
2
|
import { type FlatEvolveOptions } from '../types/types-options.js';
|
4
3
|
import { type FlatEvolveWebpackOptions } from '../types/types-webpack.js';
|
5
|
-
export declare const createPlugins: (serveMode: boolean,
|
4
|
+
export declare const createPlugins: (serveMode: boolean, entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => Promise<FlatEvolveWebpackOptions['plugins']>;
|
@@ -1 +1 @@
|
|
1
|
-
import CaseSensitivePathsPlugin from"case-sensitive-paths-webpack-plugin";import MiniCssExtractPlugin from"mini-css-extract-plugin";import webpack from"webpack";import{
|
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{createCircularDependencyPlugin}from"../plugins/circular-dependency/index.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,l=enableBundleHashNameForModule(a,i?.options),t=[new webpack.WatchIgnorePlugin({paths:[/\.d\.[cm]ts$/]}),new CaseSensitivePathsPlugin,...createCircularDependencyPlugin(e,a),new MiniCssExtractPlugin({filename:`[name]/${getBundleFileName("css",e,l)}`,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&&t.push(new ForkTsCheckerWebpackPlugin({async:e,typescript:{context:a.projectCwd,memoryLimit:8192}})),s&&t.push(new BundleAnalyzerPlugin({analyzerPort:"auto",analyzerMode:"server",...s}));const u=shouldEnableReactFastRefresh(e,n,a);u&&t.push(new ReactRefreshWebpackPlugin({overlay:!1})),!u&&e&&(a.devServer?.liveReload?logger.warn('The HMR disabled cause of "liveReload" specificed'):logger.warn(`The HMR disabled cause of \`"moduleFederation":"${r}"\``));const p=a.webpack?.plugins||[];return t.concat(p)};
|
@@ -1 +1 @@
|
|
1
|
-
import{join}from"node:path";import{TsconfigPathsPlugin}from"tsconfig-paths-webpack-plugin";
|
1
|
+
import{join}from"node:path";import{mergeOptions}from"@flatjs/common";import{TsconfigPathsPlugin}from"tsconfig-paths-webpack-plugin";export const createResolve=(s,o)=>{const n={mainFields:["browser","module","main"],extensions:[".ts",".tsx",".js",".json"],extensionAlias:{".js":[".js",".ts"],".cjs":[".cjs",".cts"],".mjs":[".mjs",".mts"],".jsx":[".jsx",".tsx"]},plugins:[new TsconfigPathsPlugin({configFile:join(s,"tsconfig.json"),extensions:[".ts",".tsx",".js",".jsx"]})]};return mergeOptions(n,o?.resolve||{})};
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import { type RuleSetRule } from 'webpack';
|
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 createRuleSets: (serveMode: boolean,
|
4
|
+
export declare const createRuleSets: (serveMode: boolean, entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => RuleSetRule[];
|
@@ -1 +1 @@
|
|
1
|
-
import{ruleAssets}from"./rule-sets/rule-assets.js";import{ruleCss}from"./rule-sets/rule-css.js";import{ruleLess}from"./rule-sets/rule-less.js";import{ruleScripts}from"./rule-sets/rule-scripts.js";import{ruleSvgIcon}from"./rule-sets/rule-svg-icon.js";export const createRuleSets=(s,e,r)=>{const l=
|
1
|
+
import{ruleAssets}from"./rule-sets/rule-assets.js";import{ruleCss}from"./rule-sets/rule-css.js";import{ruleLess}from"./rule-sets/rule-less.js";import{ruleScripts}from"./rule-sets/rule-scripts.js";import{ruleSvgIcon}from"./rule-sets/rule-svg-icon.js";export const createRuleSets=(s,e,r)=>{const l=[ruleSvgIcon(),ruleAssets(e,r),ruleCss(s,e,r,!1),ruleCss(s,e,r,!0),ruleLess(s,e,r),ruleScripts(s,e,r)],t=r.webpack?.ruleSets||[];return l.concat(t)};
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { type Configuration } from 'webpack';
|
2
|
-
import { FlatCliOptions } from '../types/types-cli-options.js';
|
3
2
|
import { type EvolveEntryMap } from '../types/types-entry-map.js';
|
4
3
|
import { type FlatEvolveOptions } from '../types/types-options.js';
|
5
4
|
/**
|
@@ -8,4 +7,4 @@ import { type FlatEvolveOptions } from '../types/types-options.js';
|
|
8
7
|
* @param entryMap The only single one `servedEntry` or `toBuildEntry`
|
9
8
|
* @param overrideOptions The manually override configuration options for flatjsEvolve
|
10
9
|
*/
|
11
|
-
export declare const loadWebpackConfig: (mode:
|
10
|
+
export declare const loadWebpackConfig: (mode: 'production' | 'development', entryMap: EvolveEntryMap, evolveOptions: FlatEvolveOptions) => Promise<Omit<Configuration, 'entry'>>;
|
@@ -1 +1 @@
|
|
1
|
-
import{
|
1
|
+
import{assertOnlySingleEntryItem}from"../helpers/assert-only-single-entry-item.js";import{createExternals}from"./create-externals.js";import{createOptimization}from"./create-optimization.js";import{createOutput}from"./create-output.js";import{createPerformance}from"./create-performance.js";import{createPlugins}from"./create-plugins.js";import{createResolve}from"./create-resolve.js";import{createRuleSets}from"./create-rule-sets.js";export const loadWebpackConfig=async(e,t,r)=>{const a="development"===e,{projectCwd:o,webpack:s,devServer:n}=r,c=n?.watchOptions,i=assertOnlySingleEntryItem(t,r),m=createRuleSets(a,i,r);return{mode:e,plugins:await createPlugins(a,i,r),watchOptions:c,output:await createOutput(a,r,i),context:o,target:s?.target??["web","es5"],resolve:createResolve(o,s),module:{rules:m},devtool:a?"eval-source-map":s?.sourceMap||!1,externalsType:s?.externalsType,externals:createExternals(s?.externals,i),performance:createPerformance(a,s?.performance),optimization:createOptimization(a,r,i),infrastructureLogging:s?.infrastructureLogging??{level:"warn"},stats:s?.stats??{preset:"minimal"},cache:{type:"memory"}}};
|
@@ -5,6 +5,6 @@ import { type FlatEvolveOptions } from '../../types/types-options.js';
|
|
5
5
|
* Preparing image loader for normal pictures except stored in folder `icons`
|
6
6
|
* Webpack@5 don't need `file-loader`, `raw-loader`, `url-loader` provider us `asset-modules`
|
7
7
|
* https://webpack.js.org/guides/asset-modules/
|
8
|
-
* @param
|
8
|
+
* @param entryItem The available entries, `development` it contains multiple enties, `production` only one entry in once build.
|
9
9
|
*/
|
10
|
-
export declare const ruleAssets: (
|
10
|
+
export declare const ruleAssets: (entryItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => RuleSetRule;
|
@@ -1 +1 @@
|
|
1
|
-
import{dirname,join,relative,resolve}from"node:path";import{
|
1
|
+
import{dirname,join,relative,resolve}from"node:path";import{resolvePublicPath}from"../resolve-public-path.js";import{FONT_PATH_REGEX,IMAGE_PATH_REGEX}from"./constants.js";import{isIconSvg}from"./rule-utils.js";const getEntryAssetFileName=(e,t,r)=>{const[s,o]=t,{projectCwd:a,projectVirtualPath:i}=r;let n=dirname(join(i,e.replace(/^src/,"")));const l=o.entry.map((e=>dirname(join(a,e)))),m=resolve(a,e),c=l.find((e=>m.startsWith(e)));return c&&(n=dirname(join(s,relative(c,m)))),`${n}/[name]-[contenthash:8][ext]`};export const ruleAssets=(e,t)=>{const r=resolvePublicPath(t);return{type:"asset",test:e=>FONT_PATH_REGEX.test(e)||IMAGE_PATH_REGEX.test(e)&&!isIconSvg(e),generator:{filename:({filename:r})=>getEntryAssetFileName(r,e,t),publicPath:"auto"===r?void 0:r},parser:{dataUrlCondition:{maxSize:t.loaderOptions.assetDataUrlMaxSize}}}};
|
@@ -1 +1 @@
|
|
1
|
-
import
|
1
|
+
import{requireResolve}from"@flatjs/common";import{forgePostcssPluginPixel}from"@flatjs/forge-postcss-plugin-pixel";import cssnano from"cssnano";import MiniCssExtractPlugin from"mini-css-extract-plugin";import{allowPx2remForModule}from"../../helpers/allow-px2rem-for-module.js";const getPostcssOptions=(s,o={},e={})=>{const r=[...e.plugins||[],cssnano({preset:["default",{discardComments:{removeAll:!s},reduceInitial:!1,normalizeWhitespace:!s,...e.cssnanoOptions}]})];return!1!==o&&r.push(forgePostcssPluginPixel(o)),{plugins:r}};export const ruleCss=(s,o,e,r=!1)=>{const{pixelOptions:t,cssLoaderOptions:i={},postcssOptions:l}=e.loaderOptions,n=r?{}:{modules:!1},p={test:/\.css$/i,use:[{loader:MiniCssExtractPlugin.loader,options:{esModule:!0}},{loader:requireResolve(import.meta.url,"css-loader"),options:{sourceMap:s,...i,...n}}]};r?p.include=/\.module\.css$/i:p.exclude=/\.module\.css$/i;const c=allowPx2remForModule(o,e);if(Array.isArray(p.use)){const o=getPostcssOptions(s,!!c&&t,l);p.use.push({loader:requireResolve(import.meta.url,"postcss-loader"),options:{postcssOptions:{...o,config:!1},sourceMap:s}})}return p};
|
@@ -1,5 +1,3 @@
|
|
1
1
|
import { type RuleSetRule } from 'webpack';
|
2
|
-
import { type TransformOptions } from '@babel/core';
|
3
2
|
import { type EntryMapItem, type FlatEvolveOptions } from '../../types/index.js';
|
4
|
-
export declare const ruleBabel: (options: TransformOptions) => RuleSetRule;
|
5
3
|
export declare const ruleScripts: (serveMode: boolean, entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => RuleSetRule;
|
@@ -1 +1 @@
|
|
1
|
-
import{requireResolve}from"@flatjs/common";import{mergeBabelOption}from"../../helpers/merge-babel-options.js";import{shouldEnableReactFastRefresh}from"../../helpers/should-enable-react-fast-refresh.js";export const
|
1
|
+
import{requireResolve}from"@flatjs/common";import{mergeBabelOption}from"../../helpers/merge-babel-options.js";import{shouldEnableReactFastRefresh}from"../../helpers/should-enable-react-fast-refresh.js";export const ruleScripts=(e,r,s)=>{const{babelOptions:o={},modularImports:t=[]}=s.loaderOptions,l=mergeBabelOption(t,o);shouldEnableReactFastRefresh(e,r,s)&&(l.plugins?l.plugins.push(requireResolve(import.meta.url,"react-refresh/babel")):l.plugins=[requireResolve(import.meta.url,"react-refresh/babel")]);return{test:/\.(tsx|ts|js|jsx)$/,use:[{loader:requireResolve(import.meta.url,"babel-loader"),options:l}]}};
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import { type
|
1
|
+
import { type WebpackPluginInstance, type Compiler } from 'webpack';
|
2
2
|
export type WebpackPlugin = ((this: Compiler, compiler: Compiler) => void) | WebpackPluginInstance;
|
package/dist/default-options.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const defaultEvolveOptions={projectCwd:process.cwd(),projectVirtualPath:"flatjs/evolve",rejectWarnings:!1,devServer:{autoOpen:!0,pageProxy:"/pages",mockOptions:{mockBaseDir:"mocks"},clientOverlay:{errors:!0,warnings:!1},webSocketURL:"localIp",middlewares:[],watchOptions:{poll:1e3,ignored:["**/node_modules","**/mocks"],aggregateTimeout:500},defaultServeGlobalData:()=>Promise.resolve({}),bundleDirResolver:e=>e},webpack:{target:["web","es5"],plugins:[],ruleSets:[],publicPath:"auto",resolve:{},externals:{vue:"Vue",react:"React","react-dom":"ReactDOM"},outputDir:"public",enableBundleHashName:!0},pluginOptions:{},loaderOptions:{assetDataUrlMaxSize:4096,babelOptions:{usePreset:"react",plugins:[],presets:[]},lessOptions:{},postcssOptions:{cssnanoOptions:{}},pixelOptions:{rootValue:{px:100,rpx:1},outputUnit:"rem"},modularImports:[]},
|
1
|
+
export const defaultEvolveOptions={projectCwd:process.cwd(),projectVirtualPath:"flatjs/evolve",rejectWarnings:!1,devServer:{autoOpen:!0,pageProxy:"/pages",mockOptions:{mockBaseDir:"mocks"},clientOverlay:{errors:!0,warnings:!1},webSocketURL:"localIp",middlewares:[],watchOptions:{poll:1e3,ignored:["**/node_modules","**/mocks"],aggregateTimeout:500},defaultServeGlobalData:()=>Promise.resolve({}),bundleDirResolver:e=>e},webpack:{target:["web","es5"],plugins:[],ruleSets:[],publicPath:"auto",resolve:{},externals:{vue:"Vue",react:"React","react-dom":"ReactDOM"},outputDir:"public",enableBundleHashName:!0},pluginOptions:{},loaderOptions:{assetDataUrlMaxSize:4096,babelOptions:{usePreset:"react",plugins:[],presets:[]},runTsChecker:!0,lessOptions:{},postcssOptions:{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:5,ci:{basedBranch:"origin/master"}};
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { type
|
2
|
-
import { type ConfigEnvBase, type UserConfigExport } from '@armit/config-loader';
|
1
|
+
import { type UserConfigExport, type ConfigEnvBase } from '@armit/config-loader';
|
3
2
|
import { type requireResolve } from '@flatjs/common';
|
3
|
+
import { type PartialDeep } from 'type-fest';
|
4
4
|
import { type FlatEvolveOptions } from '../types/types-options.js';
|
5
5
|
export interface EvolveConfigBase extends ConfigEnvBase {
|
6
6
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
import{join}from"node:path";import WebpackDevServer from"webpack-dev-server";export const addCompilerToDevServer=(e,r,t,
|
1
|
+
import{join}from"node:path";import WebpackDevServer from"webpack-dev-server";export const addCompilerToDevServer=(e,o,r,t,s)=>{const{projectCwd:p,devServer:c}=s,l=new WebpackDevServer({server:{type:c?.https?"https":"http",options:{...c?.https}},open:!1,compress:!0,port:r,hot:o,liveReload:!o,allowedHosts:"all",static:{directory:`${join(p,"/public")}`},headers:{"Access-Control-Allow-Origin":"*"},client:{progress:!0,overlay:c?.clientOverlay,webSocketURL:"localIp"===c?.webSocketURL?{hostname:t||void 0}:{hostname:"0.0.0.0",...c?.webSocketURL}}},e);return new Promise(((e,o)=>{l.startCallback((r=>{if(r)return o(r);e(!0)}))}))};
|
@@ -0,0 +1,3 @@
|
|
1
|
+
import { type FlatEvolveOptions } from '../types/types-options.js';
|
2
|
+
import { type EvolveDevServerEntryMap } from './middlewares/types.js';
|
3
|
+
export declare const createDevServerCompilerTasks: (projectCwd: string, mainPage: string, publicIp: string, servedDevServerEntries: EvolveDevServerEntryMap, evolveOptions: FlatEvolveOptions) => Promise<Promise<boolean>[]>;
|
@@ -0,0 +1 @@
|
|
1
|
+
import{relative}from"node:path";import{chalk,logger,mergeOptions,urlJoin}from"@flatjs/common";import webpack from"webpack";import{loadWebpackConfig}from"../create-webpack/load-webpack-config.js";import{shouldEnableReactFastRefresh}from"../helpers/should-enable-react-fast-refresh.js";import{splitToMultiCompilerConfigs}from"../helpers/split-to-multi-compiler.js";import{addCompilerToDevServer}from"./add-compiler-to-dev-server.js";export const createDevServerCompilerTasks=async(e,o,r,t,i)=>{const a=[];for(const[n,l]of Object.entries(t)){const s=l.entryConfig,p=s.options?.moduleFederation;(p?.remotes||[]).forEach((e=>{e.endpoint=e=>{const o=t[e];if(!o)throw new Error(`No servedDevServerEntry found via "${e}"`);return urlJoin(o?.devServerHostUri,["/public"])}}));const{devServerPort:c,devServerHostUri:m}=t[n],f={[n]:s},d=urlJoin(m,["public"]),v=await loadWebpackConfig("development",f,mergeOptions(i,{webpack:{publicPath:d}})),h=shouldEnableReactFastRefresh(!0,[n,s],i),g=webpack(splitToMultiCompilerConfigs(f,v,i,h)[0]);a.push(addCompilerToDevServer(g,h,c,r,i));const u=g.name||"";g.hooks.invalid.tap("fileChange",(o=>{const r=relative(e,o||"");logger.info(`file change ➩ ${chalk(["cyan"])(r)}`,u)})),g.hooks.done.tap("compileDone",(()=>{logger.info(`debug page ➩ ${chalk(["cyan"])(o)}`,u)}))}return a};
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import { type EvolveEntryMap } from '../types/types-entry-map.js';
|
2
2
|
import { type FlatEvolveOptions } from '../types/types-options.js';
|
3
3
|
import { type EvolveDevServerEntryMap } from './middlewares/types.js';
|
4
|
-
export declare const createDevServerEntries: (
|
4
|
+
export declare const createDevServerEntries: (startPort: number, servedEntries: EvolveEntryMap, evolveOptions: FlatEvolveOptions) => Promise<EvolveDevServerEntryMap>;
|
@@ -1 +1 @@
|
|
1
|
-
import{mergeOptions}from"@flatjs/common";import{prepareMockDomain}from"@flatjs/mock";import{normalizeEvolveEntryName}from"../helpers/normalize-entry-map.js";export const createDevServerEntries=async(r,e,o)=>{const{devServer:t,projectVirtualPath:n}=o,m={},{mockPort:
|
1
|
+
import{mergeOptions}from"@flatjs/common";import{prepareMockDomain}from"@flatjs/mock";import{normalizeEvolveEntryName}from"../helpers/normalize-entry-map.js";export const createDevServerEntries=async(r,e,o)=>{const{devServer:t,projectVirtualPath:n}=o,m={};let a=r;for(const[r,o]of Object.entries(e)){a+=1;const{mockPort:e,hostUri:i}=await prepareMockDomain(mergeOptions(t?.mockOptions||{},{port:a})),s=normalizeEvolveEntryName(r,n);m[r]={entryConfig:o,devServerPort:e,devServerHostUri:i,normalizedEntryName:s}}return m};
|
@@ -1 +1 @@
|
|
1
|
-
import
|
1
|
+
import https from"node:https";import{prepareMockDomain}from"@flatjs/mock";import express from"express";export const createDevServer=async e=>{const r=express(),t=e.devServer?.mockOptions,{mockPort:o,hostUri:p,publicIp:s}=await prepareMockDomain(t||{});return new Promise((t=>{const i=e.devServer?.https?https.createServer(e.devServer?.https,r):r;r.set("hostUri",p),i.listen(o,(()=>{t({app:r,publicIp:s,devHostUri:p,devPort:o})}))}))};
|
@@ -1,6 +1,6 @@
|
|
1
|
+
export * from './middlewares/index.js';
|
1
2
|
export * from './add-compiler-to-dev-server.js';
|
2
|
-
export * from './create-app-page-route.js';
|
3
3
|
export * from './create-dev-server.js';
|
4
|
-
export * from './create-
|
4
|
+
export * from './create-app-page-route.js';
|
5
5
|
export * from './create-dev-server-entries.js';
|
6
|
-
export * from './
|
6
|
+
export * from './create-dev-server-compiler-tasks.js';
|
package/dist/dev-server/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export*from"./
|
1
|
+
export*from"./middlewares/index.js";export*from"./add-compiler-to-dev-server.js";export*from"./create-dev-server.js";export*from"./create-app-page-route.js";export*from"./create-dev-server-entries.js";export*from"./create-dev-server-compiler-tasks.js";
|
@@ -1 +1 @@
|
|
1
|
-
export declare const getBundleAsset: (devServerHostUri: string, normalizedCurrEntry: string, extension:
|
1
|
+
export declare const getBundleAsset: (devServerHostUri: string, normalizedCurrEntry: string, extension: '.css' | '.js') => string;
|
@@ -1 +1 @@
|
|
1
|
-
import
|
1
|
+
import{readFileSync}from"node:fs";import{join}from"node:path";import{urlJoin}from"@flatjs/common";import _ from"lodash";import{getPackageDir}from"../../helpers/get-pacakge-dir.js";import{normalizePageProxy}from"../../helpers/normalize-page-proxy.js";import{getSortedModules}from"./get-all-sorted-modules.js";export const getPageMainHtml=async(e,r,t)=>{const o=getPackageDir(),a=readFileSync(join(o,"./templates/main.html"),"utf-8"),i=getSortedModules(t,e,r),n=normalizePageProxy(t.devServer?.pageProxy||"/pages"),m={title:"@flatjs/evolve",modules:i.map((e=>{const{entryName:t,entryContent:o,isServedEntry:a,projectVirtualPath:i,normalizedEntryName:m}=e,l=urlJoin(r,[n,m],{env:"me"}),s=o.options?.servePageMainLinkFn||(e=>e);return{link:s(l,{hostUri:r,entryName:t,virtualPath:i}),name:t.replace(i,"").replace(/^\//,""),flagText:a?"serve":"static",isServed:a?1:0}})).sort(((e,r)=>r.isServed-e.isServed))};return _.template(a)(m)};
|
@@ -1 +1 @@
|
|
1
|
-
import
|
1
|
+
import{existsSync,readFileSync}from"node:fs";import{isAbsolute,join}from"node:path";import{ensureSlash,urlJoin}from"@flatjs/common";import _ from"lodash";import{allowPx2remForModule}from"../../helpers/allow-px2rem-for-module.js";import{getHtmlPluginConfig}from"../../helpers/get-html-plugin-config.js";import{getPackageDir}from"../../helpers/get-pacakge-dir.js";import{normalizeEvolveEntryName}from"../../helpers/normalize-entry-map.js";import{normalizePageProxy}from"../../helpers/normalize-page-proxy.js";import{injectFederationScripts}from"../../helpers/script-injects.js";import{getBundleAsset}from"./get-bundle-asset.js";import{getDevServerHostUri}from"./get-dev-server-host-uri.js";import{getHmrRuntimeChunks}from"./get-hmr-runtime-chunks.js";import{getNormalizedEntryName}from"./get-normalized-entry-name.js";export const getPageModuleHtml=async(e,t,r,o,l)=>{const{entryMap:i,projectVirtualPath:a}=l,s=Object.keys(i).sort(((e,t)=>t.length-e.length)),n=getPackageDir(),m=s.find((e=>{const r=normalizeEvolveEntryName(e,a);return ensureSlash(t.path.replace(/^\//,""),!0).startsWith(ensureSlash(r,!0))}));if(!m){const e=readFileSync(join(n,"./templates/module-404.html"),"utf-8");return _.template(e)({title:"404 Not Found",errorMeta:[{name:"@flatjs/evolve workspace",value:n},{name:"served entry names",value:JSON.stringify(s)},{name:"module path",value:`${t.path}`}]})}const p=i[m],g=p.options,u=getDevServerHostUri(e,m,r),d=g?.serveModuleTemplate||"./templates/module.html",f=join(l.projectCwd,"./templates/module.html"),c=readFileSync(isAbsolute(d)?d:existsSync(f)?f:join(n,"./templates/module.html"),"utf-8"),h=l.devServer,v=h?.defaultServeGlobalData?await h.defaultServeGlobalData(p,r):{},S={mode:"development",envCdn:urlJoin(r,["public"])},y=getNormalizedEntryName(m,a,e,h),j=normalizePageProxy(h?.pageProxy||"/pages"),H={title:getHtmlPluginConfig("title",S,g?.title),favicon:getHtmlPluginConfig("favicon",S,g?.favicon),viewport:allowPx2remForModule([m,p],l)?getHtmlPluginConfig("viewport",S,g?.viewport):"",headBeforeHtmlTags:getHtmlPluginConfig("headBeforeHtmlTags",S,g?.headBeforeHtmlTags),inlineScripts:getHtmlPluginConfig("inlineScripts",S,g?.inlineScripts),headBeforeStyles:getHtmlPluginConfig("headBeforeStyles",S,g?.headBeforeStyles),headBeforeScripts:getHtmlPluginConfig("headBeforeScripts",S,g?.headBeforeScripts),bodyAfterScripts:getHtmlPluginConfig("bodyAfterScripts",S,g?.bodyAfterScripts),moduleFederationScripts:injectFederationScripts({me:[urlJoin(r,["public"])]},l.multiHtmlCdnEnvResolver),global:{hostUrl:r,apiBase:urlJoin(r,[o]),virtualPath:join(j,a),moduleName:m.replace(a,"").replace(/^\//,""),...v,...g?.serveGlobalData||{}},styles:[getBundleAsset(u,y,".css")],scripts:[getBundleAsset(u,y,".js")]};H.headBeforeHtmlTags?H.headBeforeHtmlTags=H.headBeforeHtmlTags.slice(0):H.headBeforeHtmlTags=[];return getHmrRuntimeChunks(e,m,y,p,l,u).forEach((e=>{H.headBeforeHtmlTags?.push(`<script src="${e}"><\/script>`)})),_.template(c)(H)};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { type EntryMapItem, type EvolveEntryMap } from '../types/types-entry-map.js';
|
2
|
+
import { type FlatEvolveOptions } from '../types/types-options.js';
|
3
|
+
/**
|
4
|
+
* Only fetch single one entry map once `serve`,`build` recycle.
|
5
|
+
* @returns
|
6
|
+
*/
|
7
|
+
export declare const assertOnlySingleEntryItem: (entryMap: EvolveEntryMap, evolveOptions: FlatEvolveOptions) => EntryMapItem;
|
@@ -0,0 +1 @@
|
|
1
|
+
import{normalizeEvolveEntryName}from"./normalize-entry-map.js";export const assertOnlySingleEntryItem=(e,r)=>{if(Object.keys(e).length>1)throw new Error("Only single one entry map support right now for `serve`, `build`!");let t;for(const[r,o]of Object.entries(e)){t=[r,o];break}if(!t)throw new Error('No entry map found while "serve", "build" process!');const[o,n]=t;return[normalizeEvolveEntryName(o,r.projectVirtualPath),n]};
|
@@ -11,4 +11,4 @@ export declare const currNow: () => string;
|
|
11
11
|
* @param serveMode If we are run `serve` mode
|
12
12
|
* @param enableBundleHashName If we need to generate bundle file name with `[contenthash]`
|
13
13
|
*/
|
14
|
-
export declare const getBundleFileName: (type:
|
14
|
+
export declare const getBundleFileName: (type: 'css' | 'js', serveMode: boolean, enableBundleHashName?: boolean) => string;
|
package/dist/helpers/index.d.ts
CHANGED
@@ -1,31 +1,17 @@
|
|
1
1
|
export * from './allow-px2rem-for-module.js';
|
2
|
-
export * from './assert-
|
3
|
-
export * from './assert-single-compiler.js';
|
4
|
-
export * from './check-runtime-env.js';
|
2
|
+
export * from './assert-only-single-entry-item.js';
|
5
3
|
export * from './chunk-entry-map.js';
|
6
|
-
export * from './custom-listr-renderer.js';
|
7
|
-
export * from './delete-object-keys.js';
|
8
4
|
export * from './enable-bundle-hashname-for-module.js';
|
9
|
-
export * from './flat-entry-map.js';
|
10
|
-
export * from './format-spinner-text.js';
|
11
5
|
export * from './get-bundle-file-name.js';
|
12
6
|
export * from './get-html-plugin-config.js';
|
13
7
|
export * from './get-pacakge-dir.js';
|
14
|
-
export * from './get-runtime-cdn-base.js';
|
15
|
-
export * from './get-stats-file-name.js';
|
16
|
-
export * from './is-deep-equal.js';
|
17
|
-
export * from './json-serializer.js';
|
18
8
|
export * from './merge-babel-options.js';
|
19
|
-
export * from './normalize-check-entry-options.js';
|
20
9
|
export * from './normalize-entry-map.js';
|
21
|
-
export * from './normalize-group-name.js';
|
22
|
-
export * from './normalize-page-proxy.js';
|
23
|
-
export * from './normalize-resolve-alias.js';
|
24
|
-
export * from './normalize-template-inject-tokens.js';
|
25
10
|
export * from './open-page.js';
|
26
11
|
export * from './print-log.js';
|
27
12
|
export * from './refresh-evolve-mock-options.js';
|
28
13
|
export * from './script-injects.js';
|
29
14
|
export * from './should-enable-react-fast-refresh.js';
|
30
|
-
export * from './split-to-
|
31
|
-
export * from './
|
15
|
+
export * from './split-to-multi-compiler.js';
|
16
|
+
export * from './json-serializer.js';
|
17
|
+
export * from './normalize-resolve-alias.js';
|
package/dist/helpers/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export*from"./allow-px2rem-for-module.js";export*from"./assert-
|
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";export*from"./json-serializer.js";export*from"./normalize-resolve-alias.js";
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
function stringifyWithFns(n){return JSON.stringify(n,(function(n,t){if("function"==typeof t)try{return makeFunctionFromString(t),t.toString()}catch(n){return`function ${t.toString()}`}return t}))}function looksLikeAFunctionString(n){return!![/^function[^(]*\(([^()]*)\)\s*\{[\s\S]*\}$/m,/^(\s*async\s*)?(\w*\s*)\(([^)]*)\)\s*=>\s*(.*)$/m,/^\s*\w+\s*=>/m].find((t=>t.test(n)))}function makeFunctionFromString(funcString){return eval("("+funcString+")")}function parseWithFns(n){try{return JSON.parse(n,(function(n,t){return looksLikeAFunctionString(t)?makeFunctionFromString(t):t}))}catch(n){return{}}}export const jsonSerializer={stringify:stringifyWithFns,parse:parseWithFns};
|
@@ -11,6 +11,5 @@ export declare const normalizeEvolveEntryName: (entryName: string, projectVirtua
|
|
11
11
|
* Merge default entry item configuration values.
|
12
12
|
* @param activedEntryMap actived entries
|
13
13
|
* @param definedEntryMap defined entries in flatjs.evolve.js
|
14
|
-
* @param projectVirtualPath virtual path for current `project`
|
15
14
|
*/
|
16
15
|
export declare const normalizeEvolveEntryMap: (activedEntryMap?: EvolveEntryMap, definedEntryMap?: EvolveEntryMap) => EvolveEntryMap;
|
@@ -1 +1 @@
|
|
1
|
-
import
|
1
|
+
import{join}from"node:path";import _ from"lodash";export const normalizeEvolveEntryName=(o,e)=>{const r=o.replace(/^\//,""),t=e.replace(/^\//,"");return(r.startsWith(t)?r:join(t,r)).replace(/\/$/,"")};export const normalizeEvolveEntryMap=(o={},e={})=>{const r={};for(const[t,n]of Object.entries(e)){const e={options:{}};o[t]&&(r[t]=_.merge({},e,n,o[t])),_.merge(n,e)}return r};
|
@@ -1 +1 @@
|
|
1
|
-
import opn from"better-opn";export const openPage=n=>{try{opn(n)}catch{console.warn("Unable to open browser. If you are running in a headless environment\n")}};
|
1
|
+
import opn from"better-opn";export const openPage=n=>{try{opn(n)}catch(n){console.warn("Unable to open browser. If you are running in a headless environment\n")}};
|
@@ -1 +1 @@
|
|
1
|
-
import
|
1
|
+
import{requireResolve}from"@flatjs/common";import{loadMockConfig,getMockCwd}from"@flatjs/mock";import _ from"lodash";export const refreshEvolveMockOptions=async(o,t,e)=>{const s=t.devServer,r=e?.esmLoaderOptions,i=r?.externals||[],n={projectCwd:o,resolve:requireResolve},c=await loadMockConfig(n,o,s?.mockOptions||{},_.merge({},e,{configFile:"flatjs-mock",esmLoaderOptions:{externals:[...i,"@flatjs/mock"]}}));if(s){s.mockOptions=c||{},s.mockOptions&&!s.mockOptions.https&&(s.mockOptions.https=s?.https);const o=getMockCwd(c);Array.isArray(s?.watchOptions?.ignored)&&s?.watchOptions?.ignored.push(o)}return t};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { type
|
1
|
+
import { type EvolveMultiCdnEnvType, type EvolveMultiCDNConfig, type EvolveMultiCDNEnvResolver } from '../types/types-multi-html.js';
|
2
2
|
export declare function httpUrlJoin(first?: string, second?: string): string;
|
3
3
|
/**
|
4
4
|
* To extract the best matched CDN configuration url address, either use URL `query.env` or customize the `envRresolver`
|
@@ -1 +1 @@
|
|
1
|
-
export const shouldEnableReactFastRefresh=(e,o,t)=>{const r=o[1],s=!!r.options?.moduleFederation
|
1
|
+
export const shouldEnableReactFastRefresh=(e,o,t)=>{const r=o[1],s=!!r.options?.moduleFederation;return e&&"react"===t.loaderOptions.babelOptions?.usePreset&&!s&&!0!==t.devServer?.liveReload};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { type Configuration } from 'webpack';
|
2
|
+
import { type EvolveEntryMap } from '../types/types-entry-map.js';
|
3
|
+
import { type FlatEvolveOptions } from '../types/types-options.js';
|
4
|
+
/**
|
5
|
+
* Split the `webpack` to make sure that we have separated compiler process for each module
|
6
|
+
* @param webpackConfig `Omit<Configuration, 'entry'>` webpack final configuration
|
7
|
+
*/
|
8
|
+
export declare function splitToMultiCompilerConfigs(servedEntries: EvolveEntryMap, webpackConfig: Omit<Configuration, 'entry'>, evolveOptions: FlatEvolveOptions, enabledHmr?: boolean): Configuration[];
|
@@ -0,0 +1 @@
|
|
1
|
+
import{join}from"path";import{mergeOptions}from"@flatjs/common";import{devReactFastRefresh}from"../constants.js";import{normalizeEvolveEntryName}from"./normalize-entry-map.js";export function splitToMultiCompilerConfigs(e,t,r,o=!1){const n=[];for(const[t,o]of Object.entries(e)){const e=normalizeEvolveEntryName(t,r.projectVirtualPath);n.push({[e]:o.entry})}return n.map((e=>{const r=Object.keys(e)[0];if(o){e[join(r,devReactFastRefresh.reactRefreshSetup)]=["@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js"]}return mergeOptions(t,{name:r,entry:e})}))}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export*from"./define-config/index.js";export*from"./load-config/index.js";export*from"./main/index.js";export*from"./types/types-
|
1
|
+
export*from"./define-config/index.js";export*from"./load-config/index.js";export*from"./main/index.js";export*from"./types/types-options.js";export*from"./types/types-entry-map.js";
|
@@ -1 +1 @@
|
|
1
|
-
import{searchConfig}from"@armit/config-loader";import{logger
|
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{normalizeResolveAlias}from"../helpers/normalize-resolve-alias.js";import{refreshEvolveMockOptions}from"../helpers/refresh-evolve-mock-options.js";export const loadEvolveConfig=async(o,e,i={},s={configFile:configFileName,esmLoaderOptions:{externals:[/^@flatjs\/.*/]}})=>{const{configFile:r,esmLoaderOptions:l}=s,a=await searchConfig(r,e,{esm:{...l,projectCwd:e}});let n={};n="function"==typeof a?.config?await(a?.config(o)):a?.config||{};const t=mergeOptions(defaultEvolveOptions,n),m=mergeOptions(t,i),f=mergeOptions(m,{projectCwd:e}),c="build"===o.command?f:await refreshEvolveMockOptions(e,f,s);return logger.debug(`Load evolve config:\n${JSON.stringify(c,null,2)}`,moduleName),c.webpack?.resolve?.alias&&(c.webpack.resolve.alias=normalizeResolveAlias(e,c.webpack?.resolve?.alias)),c};
|
@@ -9,8 +9,7 @@ const svgOptimize = (buffer, svgoOption) => {
|
|
9
9
|
return data;
|
10
10
|
};
|
11
11
|
const iconLoader = function iconLoader(source) {
|
12
|
-
|
13
|
-
this.cacheable(true);
|
12
|
+
this.cacheable && this.cacheable(true);
|
14
13
|
const options = this.getOptions();
|
15
14
|
const callback = this.async();
|
16
15
|
try {
|
@@ -1,31 +1,16 @@
|
|
1
|
-
import
|
2
|
-
import {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
import { type PoolInterface, type BaseWorker } from '@armit/worker-threads';
|
2
|
+
import { startBuildWorker } from './start-build-worker.js';
|
3
|
+
declare class ThreadPoolForUnittest implements BaseWorker {
|
4
|
+
private workerSize;
|
5
|
+
constructor(workerSize: number);
|
6
|
+
startBuildWorker(...args: Parameters<typeof startBuildWorker>): Promise<import("src/main/start-one-entry-build.js").EvolveBuildResult>;
|
7
|
+
get pool(): PoolInterface;
|
7
8
|
}
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
}
|
15
|
-
/**
|
16
|
-
* Represents a thread pool for executing tasks using the TinyPool library.
|
17
|
-
*/
|
18
|
-
declare class ThreadPoolForTinyPool implements BaseThreadPool {
|
19
|
-
pool: Tinypool;
|
20
|
-
/**
|
21
|
-
* Creates a new instance of the `ThreadPoolForTinyPool` class.
|
22
|
-
* @param workerPath The path to the worker file.
|
23
|
-
* @param workerSize The number of worker threads to create.
|
24
|
-
* @param options Optional configuration options for the worker pool.
|
25
|
-
*/
|
26
|
-
constructor(workerPath: string, options?: ThreadsOptions);
|
27
|
-
startBuildWorker(options: Parameters<typeof startBuildWorker>[0]): ReturnType<typeof startBuildWorker>;
|
28
|
-
terminate(): void;
|
29
|
-
}
|
30
|
-
export declare const createThreadWorker: (options?: ThreadsOptions) => ThreadPoolForUnittest | ThreadPoolForTinyPool;
|
9
|
+
export declare const createThreadWorker: (workerSize: number) => Promise<ThreadPoolForUnittest | (BaseWorker & {
|
10
|
+
all: {
|
11
|
+
readonly startBuildWorker: (projectCwd: string, entryKey: string, serializedEvolveOptions: string, configLoaderOptions?: import("src/load-config/types.js").ConfigLoaderOptions | undefined) => Promise<import("src/main/start-one-entry-build.js").EvolveBuildResult>;
|
12
|
+
};
|
13
|
+
} & {
|
14
|
+
readonly startBuildWorker: (projectCwd: string, entryKey: string, serializedEvolveOptions: string, configLoaderOptions?: import("src/load-config/types.js").ConfigLoaderOptions | undefined) => Promise<import("src/main/start-one-entry-build.js").EvolveBuildResult>;
|
15
|
+
})>;
|
31
16
|
export {};
|
@@ -1 +1 @@
|
|
1
|
-
import
|
1
|
+
import EventEmitter from"events";import{createThreadPool}from"@armit/worker-threads";import{getWorkerPath}from"./get-worker-path.js";import{startBuildWorker}from"./start-build-worker.js";class ThreadPoolForUnittest{constructor(r){this.workerSize=r}startBuildWorker(...r){return startBuildWorker(...r)}get pool(){const r=new EventEmitter,e={terminate(){console.warn('[WARNING] Using fake "terminate" for unittest!')},refill(){console.warn('[WARNING] Using fake "refill" for unittest!')},async drain(){console.warn('[WARNING] Using fake "drain" for unittest!')},size:this.workerSize,isTerminated:!1,threads:new Map};return Object.assign(r,e)}}export const createThreadWorker=async r=>{const e=getWorkerPath();return"test"===process.env.NODE_ENV?(console.warn("[WARNING] Using fake thread pool worker for unittest!"),new ThreadPoolForUnittest(r)):await createThreadPool(e,{size:r})};
|
package/dist/main/index.d.ts
CHANGED
package/dist/main/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export*from"./start-build.js";export*from"./start-
|
1
|
+
export*from"./start-build.js";export*from"./start-serve.js";export*from"./start-static.js";export*from"./start-build-dynamic.js";
|
@@ -1,10 +1,9 @@
|
|
1
|
-
import {
|
2
|
-
import { type EvolveEntryMap } from '../types/types-entry-map.js';
|
1
|
+
import { type EntryMapItem } from '../types/types-entry-map.js';
|
3
2
|
import { type FlatEvolveOptions } from '../types/types-options.js';
|
4
|
-
import { type EvolveBuildResult } from './start-
|
3
|
+
import { type EvolveBuildResult } from './start-one-entry-build.js';
|
5
4
|
/**
|
6
5
|
* The main entry to start an evolve `build`
|
7
6
|
* @param entryMapItem The `entryMapItem` for one entry build task
|
8
7
|
* @param evolveOptions FlatEvolveOptions
|
9
8
|
*/
|
10
|
-
export declare const prepareBuild: (
|
9
|
+
export declare const prepareBuild: (entryMapItem: EntryMapItem, evolveOptions: FlatEvolveOptions) => Promise<EvolveBuildResult>;
|
@@ -1 +1 @@
|
|
1
|
-
import{ensureSlash,mergeOptions}from"@flatjs/common";import{
|
1
|
+
import{ensureSlash,mergeOptions}from"@flatjs/common";import{EvolveBuildError}from"../errors/evolve-build-error.js";import{printCompilerError}from"../helpers/print-log.js";import{startOneEntryBuild}from"./start-one-entry-build.js";export const prepareBuild=async(r,o)=>{const[t,e]=r,n=o.multiHtmlCdn?.prod||[];if(!n.length)throw new Error(`No CDN config for env:"prod", moduleName: ${t}`);const i=ensureSlash(n[Math.floor(Math.random()*n.length)],!0),l={[t]:e};try{const r=e.options?.useRelativeAssetPath,t=mergeOptions(o,{webpack:{publicPath:r?"auto":i}});return await startOneEntryBuild(l,t)}catch(r){const o=printCompilerError(r);throw new EvolveBuildError("BUILD_ERROR",o)}};
|
@@ -6,4 +6,4 @@ import { type FlatEvolveOptions } from '../types/types-options.js';
|
|
6
6
|
* @param servedEntries All normalized webpack entries we have served.
|
7
7
|
* @param evolveOptions FlatEvolveOptions
|
8
8
|
*/
|
9
|
-
export declare const prepareServe: (projectCwd: string, servedEntries: EvolveEntryMap, evolveOptions: FlatEvolveOptions) => Promise<import("express-serve-static-core").Express
|
9
|
+
export declare const prepareServe: (projectCwd: string, servedEntries: EvolveEntryMap, evolveOptions: FlatEvolveOptions) => Promise<import("express-serve-static-core").Express>;
|