@flatjs/evolve 3.0.1 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +1 -1
- package/dist/core/rspack/create-plugins.js +1 -1
- package/dist/core/rspack/create-rspack-output.js +1 -1
- package/dist/core/rspack/load-rspack-config.js +1 -1
- package/dist/core/webpack/create-output.js +1 -1
- package/dist/core/webpack/create-plugins.js +1 -1
- package/dist/core/webpack/load-webpack-config.js +1 -1
- package/dist/dev-server/middlewares/get-page-module-html.js +1 -1
- package/dist/helpers/assert-chunk-filename.d.ts +12 -0
- package/dist/helpers/assert-chunk-filename.js +1 -0
- package/dist/helpers/check-html-template-options.d.ts +5 -0
- package/dist/helpers/check-html-template-options.js +1 -0
- package/dist/helpers/get-html-max-order.d.ts +16 -0
- package/dist/helpers/get-html-max-order.js +1 -0
- package/dist/helpers/merge-inspector-evolve-config.js +1 -1
- package/dist/plugins/rspack/multi-html/index.js +1 -1
- package/dist/plugins/rspack/multi-html/multi-html-rspack-plugin.js +1 -1
- package/dist/plugins/webpack/code-checker/code-checker-error.d.ts +3 -0
- package/dist/plugins/webpack/code-checker/code-checker-error.js +1 -0
- package/dist/plugins/webpack/code-checker/code-checker-webpack-plugin.d.ts +21 -0
- package/dist/plugins/webpack/code-checker/code-checker-webpack-plugin.js +1 -0
- package/dist/plugins/webpack/code-checker/index.d.ts +17 -0
- package/dist/plugins/webpack/code-checker/index.js +1 -0
- package/dist/plugins/webpack/multi-html/index.js +1 -1
- package/dist/plugins/webpack/multi-html/multi-html-webpack-plugins.js +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -1
- package/dist/types/types-ci.d.ts +1 -1
- package/dist/types/types-code-checker-options.d.ts +41 -0
- package/dist/types/types-code-checker-options.js +1 -0
- package/dist/types/types-options.d.ts +8 -0
- package/dist/types/types-webpack.d.ts +15 -0
- package/package.json +7 -7
package/dist/constants.d.ts
CHANGED
@@ -39,3 +39,7 @@ export declare const webpackStatsDir = ".cache/stats";
|
|
39
39
|
* Unix: Braille patterns for smoother animation
|
40
40
|
*/
|
41
41
|
export declare const buildProgressSpinnerFrames: string[];
|
42
|
+
/**
|
43
|
+
* The default domain regex for code checker
|
44
|
+
*/
|
45
|
+
export declare const defaultExtractionRule: string[];
|
package/dist/constants.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import process from"node:process";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=[{id:"polyfill.io/v3/polyfill.min.js",src:"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",position:"end",order
|
1
|
+
import process from"node:process";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=[{id:"polyfill.io/v3/polyfill.min.js",src:"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",position:"end",order:-1}];export const devReactFastRefresh={runtime:"reactRefreshRuntime",reactRefreshSetup:"reactRefreshSetup"};export const ignoreEntryOptionKeys=["title"];export const webpackStatsDir=".cache/stats";export const buildProgressSpinnerFrames="win32"===process.platform?["-","\\","|","/"]:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];export const defaultExtractionRule=["(?:https?:)?\\/\\/(?:[\\w-]+@)?(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,}(?::\\d+)?","(?:https?:)?\\/\\/\\d{1,3}(?:\\.\\d{1,3}){3}(?::\\d+)?"];
|
@@ -1 +1 @@
|
|
1
|
-
import CaseSensitivePathsPlugin from"case-sensitive-paths-webpack-plugin";import{logger}from"@flatjs/common";import{RsdoctorRspackPlugin}from"@rsdoctor/rspack-plugin";import rspack
|
1
|
+
import CaseSensitivePathsPlugin from"case-sensitive-paths-webpack-plugin";import{logger}from"@flatjs/common";import{RsdoctorRspackPlugin}from"@rsdoctor/rspack-plugin";import rspack from"@rspack/core";import ReactRefreshPlugin from"@rspack/plugin-react-refresh";import{assertChunkFilename}from"../../helpers/assert-chunk-filename.js";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{createBuiltinDefineVariablesRspackPlugins}from"../../plugins/rspack/define-variable/index.js";import{createModuleFederationRspackPlugins}from"../../plugins/rspack/module-federation/index.js";import{createHtmlRspackPlugins}from"../../plugins/rspack/multi-html/index.js";import{createProgressRspackPlugins}from"../../plugins/rspack/progress-plugin/index.js";import{createCircularDependencyWebpackPlugins}from"../../plugins/webpack/circular-dependency/index.js";import{createCleanWebpackPlugins}from"../../plugins/webpack/clean-webpack/index.js";import{createCodeCheckerWebpackPlugins}from"../../plugins/webpack/code-checker/index.js";import{createStatsWebpackPlugins}from"../../plugins/webpack/stats-webpack/index.js";export const createRspackPlugins=async(e,s,a,r)=>{const n=s[0],[i,l]=n,c=enableBundleHashNameForModule(a,l?.options),o=[...createProgressRspackPlugins(e,s),new rspack.IgnorePlugin({resourceRegExp:/\.d\.[cm]ts$/}),new CaseSensitivePathsPlugin,...createCircularDependencyWebpackPlugins(e,a),new rspack.CssExtractRspackPlugin({filename:`[name]/${getBundleFileName("css",e,c)}`,chunkFilename:assertChunkFilename(a,n,"css")}),...await createBuiltinDefineVariablesRspackPlugins(e,a),...createCleanWebpackPlugins(e,s,a),...createModuleFederationRspackPlugins(e,s,a),...createHtmlRspackPlugins(e,s,a),...createStatsWebpackPlugins(e,a,r),...createCodeCheckerWebpackPlugins(e,a)],t=shouldEnableReactFastRefresh(e,n,a);t&&o.push(new ReactRefreshPlugin({overlay:!1,exclude:[/node_modules/]})),!t&&e&&(a.devServer?.liveReload?logger.warn('The HMR disabled cause of "liveReload" specificed'):logger.warn(`The HMR disabled cause of \`"moduleFederation":"${i}"\``)),a.openRsdoctor&&o.push(new RsdoctorRspackPlugin);const p=a.webpack?.plugins||[];return o.concat(p)};
|
@@ -1 +1 @@
|
|
1
|
-
import{join}from"node:path";import{enableBundleHashNameForModule}from"../../helpers/enable-bundle-hashname-for-module.js";import{getBundleFileName}from"../../helpers/get-bundle-file-name.js";import{resolvePublicPath}from"../../helpers/resolve-public-path.js";export const createRspackOutput=async(e,o,t)=>{const{projectCwd:a,webpack:n}=o,l=t[1],
|
1
|
+
import{join}from"node:path";import{assertChunkFilename}from"../../helpers/assert-chunk-filename.js";import{enableBundleHashNameForModule}from"../../helpers/enable-bundle-hashname-for-module.js";import{getBundleFileName}from"../../helpers/get-bundle-file-name.js";import{resolvePublicPath}from"../../helpers/resolve-public-path.js";export const createRspackOutput=async(e,o,t)=>{const{projectCwd:a,webpack:n}=o,l=t[1],r=enableBundleHashNameForModule(o,l?.options),u=resolvePublicPath(o),i="function"==typeof n?.outputDir?await n.outputDir():n?.outputDir||"public";return{devtoolModuleFilenameTemplate:({namespace:e,resourcePath:o})=>`webpack:///${join(e,o)}`,environment:{},pathinfo:!1,path:join(a,i),publicPath:u,filename:`[name]/${getBundleFileName("js",e,r)}`,chunkFilename:assertChunkFilename(o,t),...l.options?.output}};
|
@@ -1 +1 @@
|
|
1
|
-
import{assertGroupEntryItem}from"../../helpers/assert-group-entry-item.js";import{createExternals}from"./create-externals.js";import{createOptimization}from"./create-optimization.js";import{createPerformance}from"./create-performance.js";import{createRspackPlugins}from"./create-plugins.js";import{createRspackResolve}from"./create-resolve.js";import{createRspackOutput}from"./create-rspack-output.js";import{createRspackRuleSets}from"./create-rspack-rule-sets.js";import{loadRspackWatchOptions}from"./load-rspack-watch-options.js";export const loadRspackConfig=async(e,t,r,a)=>{const s="development"===e,{projectCwd:o,webpack:c,devServer:p}=r,n=loadRspackWatchOptions(t,r,p?.watchOptions),i=assertGroupEntryItem(t,r),m=createRspackRuleSets(s,i,r),l=await createRspackPlugins(s,i,r,a),u=i[0];return{mode:e,plugins:l,watchOptions:n,output:await createRspackOutput(s,r,u),context:o,target:c?.target??["web","es5"],resolve:createRspackResolve(o,c),module:{rules:m},devtool:s?"
|
1
|
+
import{assertGroupEntryItem}from"../../helpers/assert-group-entry-item.js";import{createExternals}from"./create-externals.js";import{createOptimization}from"./create-optimization.js";import{createPerformance}from"./create-performance.js";import{createRspackPlugins}from"./create-plugins.js";import{createRspackResolve}from"./create-resolve.js";import{createRspackOutput}from"./create-rspack-output.js";import{createRspackRuleSets}from"./create-rspack-rule-sets.js";import{loadRspackWatchOptions}from"./load-rspack-watch-options.js";export const loadRspackConfig=async(e,t,r,a)=>{const s="development"===e,{projectCwd:o,webpack:c,devServer:p}=r,n=loadRspackWatchOptions(t,r,p?.watchOptions),i=assertGroupEntryItem(t,r),m=createRspackRuleSets(s,i,r),l=await createRspackPlugins(s,i,r,a),u=i[0];return{mode:e,plugins:l,watchOptions:n,output:await createRspackOutput(s,r,u),context:o,target:c?.target??["web","es5"],resolve:createRspackResolve(o,c),module:{rules:m,...c?.rspackExtraModuleOptions||{}},devtool:s?"source-map":c?.sourceMap||!1,externalsType:c?.externalsType,externals:createExternals(c?.externals,u),performance:createPerformance(s,c?.performance),optimization:createOptimization(s,r,u),infrastructureLogging:c?.infrastructureLogging??{level:"warn"},stats:c?.stats??{preset:"errors-warnings"},cache:!0}};
|
@@ -1 +1 @@
|
|
1
|
-
import{join}from"node:path";import{enableBundleHashNameForModule}from"../../helpers/enable-bundle-hashname-for-module.js";import{getBundleFileName}from"../../helpers/get-bundle-file-name.js";import{resolvePublicPath}from"../../helpers/resolve-public-path.js";export const createOutput=async(e,o,t)=>{const{projectCwd:
|
1
|
+
import{join}from"node:path";import{assertChunkFilename}from"../../helpers/assert-chunk-filename.js";import{enableBundleHashNameForModule}from"../../helpers/enable-bundle-hashname-for-module.js";import{getBundleFileName}from"../../helpers/get-bundle-file-name.js";import{resolvePublicPath}from"../../helpers/resolve-public-path.js";export const createOutput=async(e,o,t)=>{const{projectCwd:a,webpack:n}=o,l=t[1],r=enableBundleHashNameForModule(o,l?.options),u=resolvePublicPath(o),i="function"==typeof n?.outputDir?await n.outputDir():n?.outputDir||"public";return{devtoolModuleFilenameTemplate:({namespace:e,resourcePath:o})=>`webpack:///${join(e,o)}`,environment:{},pathinfo:!1,path:join(a,i),publicPath:u,filename:`[name]/${getBundleFileName("js",e,r)}`,chunkFilename:assertChunkFilename(o,t),...l.options?.output}};
|
@@ -1 +1 @@
|
|
1
|
-
import CaseSensitivePathsPlugin from"case-sensitive-paths-webpack-plugin";import MiniCssExtractPlugin from"mini-css-extract-plugin";import webpack from"webpack";import{logger}from"@flatjs/common";import ReactRefreshWebpackPlugin from"@pmmmwh/react-refresh-webpack-plugin";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{createCircularDependencyWebpackPlugins}from"../../plugins/webpack/circular-dependency/index.js";import{createCleanWebpackPlugins}from"../../plugins/webpack/clean-webpack/index.js";import{createBuiltinDefineVariablesWebpackPlugins}from"../../plugins/webpack/define-variable/index.js";import{createModuleFederationWebpackPlugins}from"../../plugins/webpack/module-federation/index.js";import{createHtmlWebpackPlugins}from"../../plugins/webpack/multi-html/index.js";import{createStatsWebpackPlugins}from"../../plugins/webpack/stats-webpack/index.js";export const createPlugins=async(e,a,i
|
1
|
+
import CaseSensitivePathsPlugin from"case-sensitive-paths-webpack-plugin";import MiniCssExtractPlugin from"mini-css-extract-plugin";import webpack from"webpack";import{logger}from"@flatjs/common";import ReactRefreshWebpackPlugin from"@pmmmwh/react-refresh-webpack-plugin";import{assertChunkFilename}from"../../helpers/assert-chunk-filename.js";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{createCircularDependencyWebpackPlugins}from"../../plugins/webpack/circular-dependency/index.js";import{createCleanWebpackPlugins}from"../../plugins/webpack/clean-webpack/index.js";import{createCodeCheckerWebpackPlugins}from"../../plugins/webpack/code-checker/index.js";import{createBuiltinDefineVariablesWebpackPlugins}from"../../plugins/webpack/define-variable/index.js";import{createModuleFederationWebpackPlugins}from"../../plugins/webpack/module-federation/index.js";import{createHtmlWebpackPlugins}from"../../plugins/webpack/multi-html/index.js";import{createStatsWebpackPlugins}from"../../plugins/webpack/stats-webpack/index.js";export const createPlugins=async(e,a,n,i)=>{const s=a[0],[r,l]=s,c=enableBundleHashNameForModule(n,l?.options),t=[new webpack.WatchIgnorePlugin({paths:[/\.d\.[cm]ts$/]}),new CaseSensitivePathsPlugin,...createCircularDependencyWebpackPlugins(e,n),new MiniCssExtractPlugin({filename:`[name]/${getBundleFileName("css",e,c)}`,chunkFilename:assertChunkFilename(n,s,"css")}),...await createBuiltinDefineVariablesWebpackPlugins(e,n),...createCleanWebpackPlugins(e,a,n),...createModuleFederationWebpackPlugins(e,a,n),...createHtmlWebpackPlugins(e,a,n),...createStatsWebpackPlugins(e,n,i),...createCodeCheckerWebpackPlugins(e,n)],p=shouldEnableReactFastRefresh(e,s,n);p&&t.push(new ReactRefreshWebpackPlugin({overlay:!1})),!p&&e&&(n.devServer?.liveReload?logger.warn('The HMR disabled cause of "liveReload" specificed'):logger.warn(`The HMR disabled cause of \`"moduleFederation":"${r}"\``));const o=n.webpack?.plugins||[];return t.concat(o)};
|
@@ -1 +1 @@
|
|
1
|
-
import{assertGroupEntryItem}from"../../helpers/assert-group-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";import{loadWatchOptions}from"./load-watch-options.js";export const loadWebpackConfig=async(e,t,r,a)=>{const o="development"===e,{projectCwd:s,webpack:c,devServer:n}=r,p=loadWatchOptions(t,r,n?.watchOptions),i=assertGroupEntryItem(t,r),m=createRuleSets(o,i,r),l=await createPlugins(o,i,r,a),u=i[0];return{mode:e,plugins:l,watchOptions:p,output:await createOutput(o,r,u),context:s,target:c?.target??["web","es5"],resolve:createResolve(s,c),module:{rules:m},devtool:o?"
|
1
|
+
import{assertGroupEntryItem}from"../../helpers/assert-group-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";import{loadWatchOptions}from"./load-watch-options.js";export const loadWebpackConfig=async(e,t,r,a)=>{const o="development"===e,{projectCwd:s,webpack:c,devServer:n}=r,p=loadWatchOptions(t,r,n?.watchOptions),i=assertGroupEntryItem(t,r),m=createRuleSets(o,i,r),l=await createPlugins(o,i,r,a),u=i[0];return{mode:e,plugins:l,watchOptions:p,output:await createOutput(o,r,u),context:s,target:c?.target??["web","es5"],resolve:createResolve(s,c),module:{rules:m},devtool:o?"source-map":c?.sourceMap||!1,externalsType:c?.externalsType,externals:createExternals(c?.externals,u),performance:createPerformance(o,c?.performance),optimization:createOptimization(o,r,u),infrastructureLogging:c?.infrastructureLogging??{level:"warn"},stats:c?.stats??{preset:"errors-warnings"},cache:{type:"memory"}}};
|
@@ -1 +1 @@
|
|
1
|
-
import{existsSync,readFileSync}from"node:fs";import{isAbsolute,join}from"node:path";import{ensureSlash,urlJoin}from"@flatjs/common";import{parseTemplate}from"@hyperse/html-webpack-plugin-loader";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{getRuntimeCDNBase}from"../../helpers/get-runtime-cdn-base.js";import{normalizeEvolveEntryName}from"../../helpers/normalize-entry-map.js";import{normalizePageProxy}from"../../helpers/normalize-page-proxy.js";import{normalizeTemplateInjectTokens}from"../../helpers/normalize-template-inject-tokens.js";import{injectFederationScripts}from"../../helpers/script-injects.js";import{ErrorModuleParser}from"./error-module-parser.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,n)=>{const{entryMap:s,projectVirtualPath:
|
1
|
+
import{existsSync,readFileSync}from"node:fs";import{isAbsolute,join}from"node:path";import{ensureSlash,urlJoin}from"@flatjs/common";import{parseTemplate}from"@hyperse/html-webpack-plugin-loader";import{allowPx2remForModule}from"../../helpers/allow-px2rem-for-module.js";import{checkHtmlTemplateOptions}from"../../helpers/check-html-template-options.js";import{getHtmlMaxOrder,getHtmlMinOrder}from"../../helpers/get-html-max-order.js";import{getHtmlPluginConfig}from"../../helpers/get-html-plugin-config.js";import{getPackageDir}from"../../helpers/get-pacakge-dir.js";import{getRuntimeCDNBase}from"../../helpers/get-runtime-cdn-base.js";import{normalizeEvolveEntryName}from"../../helpers/normalize-entry-map.js";import{normalizePageProxy}from"../../helpers/normalize-page-proxy.js";import{normalizeTemplateInjectTokens}from"../../helpers/normalize-template-inject-tokens.js";import{injectFederationScripts}from"../../helpers/script-injects.js";import{ErrorModuleParser}from"./error-module-parser.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,n)=>{const{entryMap:s,projectVirtualPath:l}=n,i=Object.keys(s).sort((e,t)=>t.length-e.length),a=getPackageDir(),m=i.find(e=>{const r=normalizeEvolveEntryName(e,l);return ensureSlash(t.path.replace(/^\//,""),!0).startsWith(ensureSlash(r,!0))});if(!m){const e=readFileSync(join(a,"./templates/module-404.html"),"utf-8");return new ErrorModuleParser(e,{title:"404 Not Found",errorMeta:[{name:"@flatjs/evolve workspace",value:a},{name:"served entry names",value:JSON.stringify(i)},{name:"module path",value:`${t.path}`}]}).serialize()}const p=s[m],d=p.options,u=getDevServerHostUri(e,m,r),c=d?.templatePath||"./templates/module.html",g=join(n.projectCwd,"./templates/module.html"),h=readFileSync(isAbsolute(c)?c:existsSync(g)?g:join(a,"./templates/module.html"),"utf-8"),f=n.devServer,v=f?.defaultServeGlobalData?await f.defaultServeGlobalData(p,r):{},j={mode:"development",envCdn:urlJoin(r,["public"])},y=getNormalizedEntryName(m,l,e,f),S=normalizePageProxy(f?.pageProxy||"/pages"),H=normalizeTemplateInjectTokens(j,d);checkHtmlTemplateOptions(H);const M=parseTemplate(h);M.upsertTitleTag(getHtmlPluginConfig("title",j,d?.title));const P=H.favicon;P&&M.upsertFaviconTag(P.href,P.rel,P.attributes);const x=H.headMetaTags||[];M.upsertHeadMetaTags(x);const k=H.headStyles||[],b=getHtmlMaxOrder(k),z=getBundleAsset(u,y,".css");k.push({id:z,href:z,position:"end",order:b+1}),M.upsertHeadStyles(k);const O=H.headScripts||[],w=getHtmlMaxOrder(O),C=getHtmlMinOrder(O);getHmrRuntimeChunks(e,m,y,p,n,u).forEach(e=>{O.unshift({id:e,src:e,position:"end",order:w-1})}),M.upsertHeadScripts(O);const T=H.headInlineScripts||[],N=getHtmlMaxOrder(T),E=getHtmlMinOrder(T),D=Math.min(E,C),F={hostUrl:r,apiBase:urlJoin(r,[o]),virtualPath:join(S,l),moduleName:m.replace(l,"").replace(/^\//,""),...v,...d?.serveGlobalData||{}};T.push({id:"globalData",content:`window.GLOBAL=${JSON.stringify(F)}`,position:"end",order:D-2}),allowPx2remForModule([m,p],n)&&T.push({id:"viewport",content:getHtmlPluginConfig("viewport",j,d?.viewport),position:"end",order:E-1});const B=getRuntimeCDNBase(n.multiHtmlCdn,n.multiHtmlCdnEnvResolver||function cdnResolver(){});T.push({id:"flatjsMultiCdn",content:B,position:"end",order:N+1});const R=injectFederationScripts({me:[urlJoin(r,["public"])]},n.multiHtmlCdnEnvResolver);T.push({id:"evolveFetchMicroWidgets",content:R,position:"end",order:N+2}),M.upsertHeadInlineScripts(T);const A=H.headInlineStyles||[];M.upsertHeadInlineStyles(A);const I=H.bodyScripts||[],J=getHtmlMaxOrder(I),G=getBundleAsset(u,y,".js");return I.push({id:G,src:G,position:"end",order:J+1}),M.upsertBodyScripts(I),M.serialize()};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import type { EntryMapItem } from '../types/types-entry-map.js';
|
2
|
+
import type { FlatEvolveOptions } from '../types/types-options.js';
|
3
|
+
/**
|
4
|
+
* Assert the chunk filename based on the entry item and the extension.
|
5
|
+
* If we have customized `chunkFileVirtualPath`, we will join the `chunkFileVirtualPath` and the `chunkFilename`.
|
6
|
+
*
|
7
|
+
* @param evolveOptions - The evolve options.
|
8
|
+
* @param entryItem - The entry item.
|
9
|
+
* @param extension - The extension.
|
10
|
+
* @returns The chunk filename.
|
11
|
+
*/
|
12
|
+
export declare const assertChunkFilename: (evolveOptions: FlatEvolveOptions, entryItem: EntryMapItem, extension?: string) => string;
|
@@ -0,0 +1 @@
|
|
1
|
+
import{join}from"path";import{enableBundleHashNameForModule}from"./enable-bundle-hashname-for-module.js";export const assertChunkFilename=(e,n,a="js")=>{const{webpack:o}=e,t=n[1];let l=enableBundleHashNameForModule(e,t?.options)?`[id].[contenthash].${a}`:`[id].${a}`;return o?.chunkFileVirtualPath&&(l=join(o.chunkFileVirtualPath,l)),l};
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import type { TemplateOptions } from '@hyperse/html-webpack-plugin-loader';
|
2
|
+
declare const TokensKey: readonly ["headStyles", "headScripts", "bodyScripts", "headInlineScripts", "headInlineStyles"];
|
3
|
+
type TokensKeyType = (typeof TokensKey)[number];
|
4
|
+
export declare const checkHtmlTemplateOptions: <T extends Pick<TemplateOptions, TokensKeyType>>(options: T) => void;
|
5
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
import{logger}from"@flatjs/common";const TokensKey=["headStyles","headScripts","bodyScripts","headInlineScripts","headInlineStyles"];export const checkHtmlTemplateOptions=e=>{for(const o of Object.keys(e)){if(!TokensKey.includes(o))continue;const t=e[o];t?.forEach(e=>{void 0===e.order&&logger.warn(`The order of the ${o} is undefined, please check the ${o}`)})}};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/**
|
2
|
+
* Get the maximum order of the items
|
3
|
+
* @param items
|
4
|
+
* @returns
|
5
|
+
*/
|
6
|
+
export declare const getHtmlMaxOrder: <T extends {
|
7
|
+
order: number;
|
8
|
+
}>(items: T[]) => number;
|
9
|
+
/**
|
10
|
+
* Get the minimum order of the items
|
11
|
+
* @param items - The items to get the minimum order
|
12
|
+
* @returns The minimum order
|
13
|
+
*/
|
14
|
+
export declare const getHtmlMinOrder: <T extends {
|
15
|
+
order: number;
|
16
|
+
}>(items: T[]) => number;
|
@@ -0,0 +1 @@
|
|
1
|
+
export const getHtmlMaxOrder=t=>t.length>0?Math.max(...t.map(t=>t.order)):0;export const getHtmlMinOrder=t=>t.length>0?Math.min(...t.map(t=>t.order)):0;
|
@@ -1 +1 @@
|
|
1
|
-
import{dirname,join}from"path";import{fileURLToPath}from"url";import{searchPackageDir}from"@armit/package";import{logger,mergeOptions,requireResolve}from"@flatjs/common";import{normalizePageProxy}from"./normalize-page-proxy.js";export const mergeInspectorEvolveConfig=e=>{const{inspector:r,devServer:o}=e;if(!r)return e;const{externals:n}=e.webpack||{};if(n){let r=n;if("function"==typeof n&&(r=n()),r.react||r["react-dom"])return logger.warn("React and ReactDOM are external dependencies, you need to manually integrate Inspector"),e}const t=normalizePageProxy(o?.pageProxy||"/pages"),{keys:i=["$mod","i"],customLaunchEditorEndpoint:s="/__hps_inspector"}=r,a={"process.env.INSPECTOR_ENDPOINT":JSON.stringify(join(t,s)),"process.env.INSPECTOR_KEYS":JSON.stringify(i.join(",")),"process.env.INSPECTOR_HIDE_CONSOLE":JSON.stringify("FALSE"),"process.env.INSPECTOR_HIDE_CONTEXT":JSON.stringify("TRUE"),"process.env.INSPECTOR_HIDE_DOM_PATH_ATTR":JSON.stringify("TRUE"),"process.env.INSPECTOR_DISABLE":JSON.stringify("FALSE")},p=mergeOptions(e,{pluginOptions:{definePlugin:a}}),c=requireResolve(import.meta.url,"@hyperse/inspector"),g=searchPackageDir({cwd:fileURLToPath(dirname(c))});if(!g)return logger.debug("@hyperse/inspector package not found"),p;const m=join(g,"dist","client","index.js"),f=p.entryMap;for(const[e,r]of Object.entries(f)){r.entry.
|
1
|
+
import{dirname,join}from"path";import{fileURLToPath}from"url";import{searchPackageDir}from"@armit/package";import{logger,mergeOptions,requireResolve}from"@flatjs/common";import{normalizePageProxy}from"./normalize-page-proxy.js";export const mergeInspectorEvolveConfig=e=>{const{inspector:r,devServer:o}=e;if(!r)return e;const{externals:n}=e.webpack||{};if(n){let r=n;if("function"==typeof n&&(r=n()),r.react||r["react-dom"])return logger.warn("React and ReactDOM are external dependencies, you need to manually integrate Inspector"),e}const t=normalizePageProxy(o?.pageProxy||"/pages"),{keys:i=["$mod","i"],customLaunchEditorEndpoint:s="/__hps_inspector"}=r,a={"process.env.INSPECTOR_ENDPOINT":JSON.stringify(join(t,s)),"process.env.INSPECTOR_KEYS":JSON.stringify(i.join(",")),"process.env.INSPECTOR_HIDE_CONSOLE":JSON.stringify("FALSE"),"process.env.INSPECTOR_HIDE_CONTEXT":JSON.stringify("TRUE"),"process.env.INSPECTOR_HIDE_DOM_PATH_ATTR":JSON.stringify("TRUE"),"process.env.INSPECTOR_DISABLE":JSON.stringify("FALSE")},p=mergeOptions(e,{pluginOptions:{definePlugin:a}}),c=requireResolve(import.meta.url,"@hyperse/inspector"),g=searchPackageDir({cwd:fileURLToPath(dirname(c))});if(!g)return logger.debug("@hyperse/inspector package not found"),p;const m=join(g,"dist","client","index.js"),f=p.entryMap;for(const[e,r]of Object.entries(f)){r.entry.unshift(m)}return p};
|
@@ -1 +1 @@
|
|
1
|
-
import{FlatEvolveMultiCdnRspackPlugin}from"./multi-html-cdn-rspack-plugin.js";import{createMultiHtmlRspackPlugins}from"./multi-html-rspack-plugin.js";export const createHtmlRspackPlugins=(t,l,
|
1
|
+
import{FlatEvolveMultiCdnRspackPlugin}from"./multi-html-cdn-rspack-plugin.js";import{createMultiHtmlRspackPlugins}from"./multi-html-rspack-plugin.js";export const createHtmlRspackPlugins=(t,l,i)=>{const n=[new FlatEvolveMultiCdnRspackPlugin(i,l)],u=l[0];if(t||u[1]?.options?.output?.library)return n;const s=Object.keys(i.multiHtmlCdn);return n.unshift(...createMultiHtmlRspackPlugins(t,i,l,s)),n};
|
@@ -1 +1 @@
|
|
1
|
-
import HtmlWebpackPlugin from"html-webpack-plugin";import{existsSync}from"node:fs";import{logger,requireResolve}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";import{MultiHtmlModifyRspackPlugin}from"./multi-html-modify-rspack-plugin.js";const minifyOpts={minifyJS:!0,removeComments:!0,collapseWhitespace:!0,collapseBooleanAttributes:!1};export const createMultiHtmlRspackPlugins=(e,t,l,i)=>{const
|
1
|
+
import HtmlWebpackPlugin from"html-webpack-plugin";import{existsSync}from"node:fs";import{logger,requireResolve}from"@flatjs/common";import{allowPx2remForModule}from"../../../helpers/allow-px2rem-for-module.js";import{checkHtmlTemplateOptions}from"../../../helpers/check-html-template-options.js";import{getHtmlMinOrder}from"../../../helpers/get-html-max-order.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";import{MultiHtmlModifyRspackPlugin}from"./multi-html-modify-rspack-plugin.js";const minifyOpts={minifyJS:!0,removeComments:!0,collapseWhitespace:!0,collapseBooleanAttributes:!1};export const createMultiHtmlRspackPlugins=(e,t,l,i)=>{const o=l[0],[,n]=o,m=[new MultiHtmlModifyRspackPlugin(l)],{options:r}=n,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);checkHtmlTemplateOptions(i);const n=i?.headInlineScripts||[];if(allowPx2remForModule(o,t)){const e=getHtmlMinOrder(n),t=getHtmlPluginConfig("viewport",l,r?.viewport);n.push({id:"viewport",content:t,position:"end",order:e-1})}let a=getHtmlPluginConfig("templatePath",l,r?.templatePath).replace("{0}",e.trim());existsSync(a)||(logger.warn(`The template file ${a} is not exists, use \`prod\` instead!`),a=getHtmlPluginConfig("templatePath",l,r?.templatePath).replace("{0}","prod"));a=`${requireResolve(import.meta.url,"@hyperse/html-webpack-plugin-loader/loader")}!${a}`,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:a,templateParameters:{title:"",...i,headInlineScripts:n},multiCdn:{env:e,disabled:(r?.excludeCdnEnvs||["me","dev","ntv"]).includes(e)}}))}return m};
|
@@ -0,0 +1 @@
|
|
1
|
+
export class CodeCheckerError extends Error{constructor(r){super(Array.from(new Set(r)).join("\n")),this.stack=void 0}}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { type Compiler, type WebpackPluginInstance } from 'webpack';
|
2
|
+
import type { CodeCheckerPluginOptions } from '../../../types/types-code-checker-options.js';
|
3
|
+
/**
|
4
|
+
* CodeCheckerWebpackPlugin is a webpack plugin that checks the code for illegal codes.
|
5
|
+
*/
|
6
|
+
export declare class CodeCheckerWebpackPlugin implements WebpackPluginInstance {
|
7
|
+
errors: string[];
|
8
|
+
blackList: Array<{
|
9
|
+
input: string;
|
10
|
+
reg: RegExp;
|
11
|
+
}>;
|
12
|
+
whiteList: RegExp[];
|
13
|
+
whitelistExtractionRule: RegExp[];
|
14
|
+
constructor(options?: CodeCheckerPluginOptions);
|
15
|
+
/**
|
16
|
+
* Check code for illegal patterns and collect errors
|
17
|
+
*/
|
18
|
+
private checkCode;
|
19
|
+
private findUnallowedCode;
|
20
|
+
apply(compiler: Compiler): void;
|
21
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
import webpack from"webpack";import{defaultExtractionRule}from"../../../constants.js";import{CodeCheckerError}from"./code-checker-error.js";const PLUGIN_NAME="CodeCheckerWebpackPlugin";export class CodeCheckerWebpackPlugin{constructor(t={}){this.errors=[],this.blackList=[],this.whiteList=[],this.whitelistExtractionRule=[];const{blackList:e=[],whiteList:s=[],whitelistExtractionRule:o=defaultExtractionRule}=t;this.errors=[],this.blackList=e.map(t=>({input:t,reg:new RegExp(t)})),this.whiteList=s.map(t=>new RegExp(t)),this.whitelistExtractionRule=o.map(t=>new RegExp(t,"g"))}checkCode(t,e){const s=this.findUnallowedCode(t);for(const t of s)this.errors.push(`【 WhiteList 】${e} has unallowed code: ${t}`);for(const s of this.blackList)s.reg.test(t)&&this.errors.push(`【 BlackList 】${e} has unallowed code: ${s.input}`)}findUnallowedCode(t){const e=[],s=[];for(const e of this.whitelistExtractionRule)s.push(...t.match(e)??[]);if(s.length>0)for(const t of s){this.whiteList.findIndex(e=>e.test(t))<0&&e.push(t)}return e}apply(t){t.hooks.compilation.tap(PLUGIN_NAME,t=>{t.hooks.processAssets.tap({name:`${PLUGIN_NAME}PROCESS_ASSETS_STAGE_ANALYSE`,stage:webpack.Compilation.PROCESS_ASSETS_STAGE_ANALYSE},()=>{for(const[e,s]of Object.entries(t.assets)){if(!e.endsWith(".map")&&s.source){const t=s.source().toString();t&&t.length>0&&this.checkCode(t,e)}}})}),t.hooks.done.tap({name:`${PLUGIN_NAME}_DONE`},()=>{if(this.errors.length>0)throw new CodeCheckerError(this.errors)})}}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { type FlatEvolveOptions } from '../../../types/types-options.js';
|
2
|
+
import type { WebpackPlugin } from '../../../types/types-webpack.js';
|
3
|
+
/**
|
4
|
+
* Creates a list of webpack plugins for code checking.
|
5
|
+
*
|
6
|
+
* This function determines whether to enable the code checker plugin based on the provided serveMode and evolveOptions.
|
7
|
+
* - When `serveMode` is true (development mode), the code checker plugin is disabled to improve development experience and build speed.
|
8
|
+
* - The CodeCheckerWebpackPlugin is only enabled when `serveMode` is false and `evolveOptions.codeChecker` is set to a valid configuration.
|
9
|
+
*
|
10
|
+
* @example
|
11
|
+
* IF code include `http://test.example.com/xxxx`, will throw error
|
12
|
+
*
|
13
|
+
* @param serveMode - Indicates whether the current mode is serve (development) mode. If true, the code checker plugin will be disabled.
|
14
|
+
* @param evolveOptions - The complete Evolve configuration object, which may include codeChecker plugin options.
|
15
|
+
* @returns WebpackPlugin[] Returns an array containing the CodeCheckerWebpackPlugin if enabled; otherwise, returns an empty array.
|
16
|
+
*/
|
17
|
+
export declare const createCodeCheckerWebpackPlugins: (serveMode: boolean, evolveOptions: FlatEvolveOptions) => WebpackPlugin[];
|
@@ -0,0 +1 @@
|
|
1
|
+
import{CodeCheckerWebpackPlugin}from"./code-checker-webpack-plugin.js";export const createCodeCheckerWebpackPlugins=(e,c)=>{const r=[],{codeChecker:o}=c;return e||!o||r.push(new CodeCheckerWebpackPlugin(o)),r};
|
@@ -1 +1 @@
|
|
1
|
-
import{FlatEvolveMultiCdnWebpackPlugin}from"./multi-html-cdn-webpack-plugin.js";import{createMultiHtmlWebpackPlugins}from"./multi-html-webpack-plugins.js";export const createHtmlWebpackPlugins=(t,l,e)=>{const
|
1
|
+
import{FlatEvolveMultiCdnWebpackPlugin}from"./multi-html-cdn-webpack-plugin.js";import{createMultiHtmlWebpackPlugins}from"./multi-html-webpack-plugins.js";export const createHtmlWebpackPlugins=(t,l,e)=>{const i=[new FlatEvolveMultiCdnWebpackPlugin(e)],n=l[0];if(t||n[1]?.options?.output?.library)return i;const u=Object.keys(e.multiHtmlCdn);return i.unshift(...createMultiHtmlWebpackPlugins(t,e,l,u)),i};
|
@@ -1 +1 @@
|
|
1
|
-
import HtmlWebpackPlugin from"html-webpack-plugin";import{existsSync}from"node:fs";import{logger,requireResolve}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";import{MultiHtmlModifyWebpackPlugin}from"./multi-html-modify-webpack-plugin.js";const minifyOpts={minifyJS:!0,removeComments:!0,collapseWhitespace:!0,collapseBooleanAttributes:!1};export const createMultiHtmlWebpackPlugins=(e,t,l,i)=>{const
|
1
|
+
import HtmlWebpackPlugin from"html-webpack-plugin";import{existsSync}from"node:fs";import{logger,requireResolve}from"@flatjs/common";import{allowPx2remForModule}from"../../../helpers/allow-px2rem-for-module.js";import{checkHtmlTemplateOptions}from"../../../helpers/check-html-template-options.js";import{getHtmlMinOrder}from"../../../helpers/get-html-max-order.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";import{MultiHtmlModifyWebpackPlugin}from"./multi-html-modify-webpack-plugin.js";const minifyOpts={minifyJS:!0,removeComments:!0,collapseWhitespace:!0,collapseBooleanAttributes:!1};export const createMultiHtmlWebpackPlugins=(e,t,l,i)=>{const o=l[0],[,n]=o,m=[new MultiHtmlModifyWebpackPlugin(l)],{options:r}=n,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);checkHtmlTemplateOptions(i);const n=i?.headInlineScripts||[];if(allowPx2remForModule(o,t)){const e=getHtmlMinOrder(n),t=getHtmlPluginConfig("viewport",l,r?.viewport);n.unshift({id:"viewport",content:t,position:"end",order:e-1})}let a=getHtmlPluginConfig("templatePath",l,r?.templatePath).replace("{0}",e.trim());existsSync(a)||(logger.warn(`The template file ${a} is not exists, use \`prod\` instead!`),a=getHtmlPluginConfig("templatePath",l,r?.templatePath).replace("{0}","prod"));a=`${requireResolve(import.meta.url,"@hyperse/html-webpack-plugin-loader/loader")}!${a}`,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:a,templateParameters:{title:"",...i,headInlineScripts:n},multiCdn:{env:e,disabled:(r?.excludeCdnEnvs||["me","dev","ntv"]).includes(e)}}))}return m};
|
package/dist/types/index.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
export * from './types-analyzer.js';
|
2
2
|
export * from './types-build.js';
|
3
3
|
export * from './types-cli-options.js';
|
4
|
+
export * from './types-code-checker-options.js';
|
4
5
|
export * from './types-dev-server.js';
|
5
6
|
export * from './types-entry-map.js';
|
6
7
|
export * from './types-federation.js';
|
package/dist/types/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export*from"./types-analyzer.js";export*from"./types-build.js";export*from"./types-cli-options.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";
|
1
|
+
export*from"./types-analyzer.js";export*from"./types-build.js";export*from"./types-cli-options.js";export*from"./types-code-checker-options.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";
|
package/dist/types/types-ci.d.ts
CHANGED
@@ -21,7 +21,7 @@ export type FlatEvolveCI = {
|
|
21
21
|
* Dynamic build depends on persistent `branch`, e.g. `main`,`master`,`release`
|
22
22
|
* @default `origin/master`
|
23
23
|
*/
|
24
|
-
basedBranch
|
24
|
+
basedBranch?: string;
|
25
25
|
/**
|
26
26
|
* The release version will setup to `process.env.FLAT_RELEASE_VERSION`
|
27
27
|
* @default ''
|
@@ -0,0 +1,41 @@
|
|
1
|
+
export type CodeCheckerPluginOptions = {
|
2
|
+
/**
|
3
|
+
* The rules used to detect illegal code.
|
4
|
+
*
|
5
|
+
* use new RegExp() to create a RegExp object
|
6
|
+
*
|
7
|
+
* @default []
|
8
|
+
*
|
9
|
+
* @example
|
10
|
+
* ```ts
|
11
|
+
* blackList: ['console.log', 'debugger']
|
12
|
+
* ```
|
13
|
+
*/
|
14
|
+
blackList?: string[];
|
15
|
+
/**
|
16
|
+
* List of allowed domain resources.
|
17
|
+
*
|
18
|
+
* use new RegExp() to create a RegExp object
|
19
|
+
*
|
20
|
+
* @default []
|
21
|
+
*
|
22
|
+
* @example
|
23
|
+
* ```ts
|
24
|
+
* whiteList: ['http://test.example.com']
|
25
|
+
* ```
|
26
|
+
*/
|
27
|
+
whiteList?: string[];
|
28
|
+
/**
|
29
|
+
* Regular expression for domain matching.
|
30
|
+
|
31
|
+
* use new RegExp() to create a RegExp object
|
32
|
+
*
|
33
|
+
* @default [new RegExp(`https?://[a-zA-Z0-9\\.-]+`, 'g')]
|
34
|
+
*
|
35
|
+
* @example
|
36
|
+
* ```ts
|
37
|
+
* whitelistExtractionRule: [new RegExp(`https?://[a-zA-Z0-9\\.-]+`, 'g')]
|
38
|
+
* ```
|
39
|
+
*/
|
40
|
+
whitelistExtractionRule?: string[];
|
41
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export{};
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { type VerifyPackagePattern } from '@armit/package';
|
2
2
|
import type { TrustedEditor } from '@hyperse/inspector-common';
|
3
3
|
import { type FlatEvolveCI } from './types-ci.js';
|
4
|
+
import type { CodeCheckerPluginOptions } from './types-code-checker-options.js';
|
4
5
|
import { type FlatEvolveDevServerOptions } from './types-dev-server.js';
|
5
6
|
import { type EvolveEntryMap } from './types-entry-map.js';
|
6
7
|
import { type GlobalCompilerOptions } from './types-global-compiler-options.js';
|
@@ -175,4 +176,11 @@ export interface FlatEvolveOptions {
|
|
175
176
|
*/
|
176
177
|
trustedEditor?: `${TrustedEditor}`;
|
177
178
|
};
|
179
|
+
/**
|
180
|
+
* The options of code checker.
|
181
|
+
*
|
182
|
+
* If `serveMode` is `true`, it will be ignored. and close code checker plugin.
|
183
|
+
*
|
184
|
+
*/
|
185
|
+
codeChecker?: CodeCheckerPluginOptions;
|
178
186
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import type { Compiler, WebpackPluginInstance } from 'webpack';
|
2
2
|
import { type Configuration, type RuleSetRule } from 'webpack';
|
3
|
+
import type { ModuleOptions } from '@rspack/core';
|
3
4
|
import { type TerserMinimizerOptions } from '../minimizer/types.js';
|
4
5
|
export type WebpackPlugin = ((this: Compiler, compiler: Compiler) => void) | WebpackPluginInstance;
|
5
6
|
/**
|
@@ -147,4 +148,18 @@ export interface FlatEvolveWebpackOptions extends Pick<Configuration, 'infrastru
|
|
147
148
|
* @default `public`
|
148
149
|
*/
|
149
150
|
outputDir?: string | (() => string | Promise<string>);
|
151
|
+
/**
|
152
|
+
* The virtual path prefix for output chunk files.
|
153
|
+
* The actual chunk file name will be: `${chunkFileVirtualPath}/${chunkFilename}`
|
154
|
+
* For example: if chunkFileVirtualPath = 'runtime-chunks' and chunkFilename = '[id].js',
|
155
|
+
* the final output path will be 'runtime-chunks/[id].js'.
|
156
|
+
*/
|
157
|
+
chunkFileVirtualPath?: string;
|
158
|
+
/**
|
159
|
+
* The extra module options for rspack.
|
160
|
+
* Only effective when compiler is set to 'rspack'.
|
161
|
+
*
|
162
|
+
* @see {@link https://rspack.rs/zh/config/module}
|
163
|
+
*/
|
164
|
+
rspackExtraModuleOptions?: Omit<ModuleOptions, 'rules'>;
|
150
165
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@flatjs/evolve",
|
3
|
-
"version": "3.0.
|
3
|
+
"version": "3.0.3",
|
4
4
|
"license": "MIT",
|
5
5
|
"type": "module",
|
6
6
|
"exports": {
|
@@ -56,19 +56,19 @@
|
|
56
56
|
"@flatjs/forge-ts-checker": "1.1.2",
|
57
57
|
"@flatjs/graph": "2.2.9",
|
58
58
|
"@flatjs/mock": "2.4.1",
|
59
|
-
"@flatjs/swc-plugin-import": "1.0.
|
59
|
+
"@flatjs/swc-plugin-import": "1.0.1",
|
60
60
|
"@hyperse/config-loader": "^1.0.5",
|
61
|
-
"@hyperse/html-webpack-plugin-loader": "^1.0.
|
61
|
+
"@hyperse/html-webpack-plugin-loader": "^1.0.7",
|
62
62
|
"@hyperse/inspector": "^1.1.13",
|
63
63
|
"@hyperse/inspector-babel-plugin": "^1.1.7",
|
64
64
|
"@hyperse/inspector-common": "^1.1.4",
|
65
65
|
"@hyperse/inspector-middleware": "^1.1.7",
|
66
66
|
"@hyperse/inspector-swc-plugin": "^1.1.9",
|
67
67
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.6.0",
|
68
|
-
"@rsdoctor/rspack-plugin": "^1.
|
69
|
-
"@rspack/core": "~1.
|
70
|
-
"@rspack/dev-server": "~1.1.
|
71
|
-
"@rspack/plugin-react-refresh": "^1.
|
68
|
+
"@rsdoctor/rspack-plugin": "^1.2.3",
|
69
|
+
"@rspack/core": "~1.5.3",
|
70
|
+
"@rspack/dev-server": "~1.1.4",
|
71
|
+
"@rspack/plugin-react-refresh": "^1.5.1",
|
72
72
|
"@swc/helpers": "^0.5.17",
|
73
73
|
"@types/babel__core": "^7.20.5",
|
74
74
|
"babel-loader": "^10.0.0",
|