@flatjs/evolve 3.0.10 → 3.0.12
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 +0 -5
- package/dist/constants.js +1 -1
- package/dist/default-options.js +1 -1
- package/dist/dev-server/create-app-page-route.js +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/get-html-plugin-config.js +1 -1
- package/dist/helpers/merge-inspector-evolve-config.js +1 -1
- package/dist/main/prepare-serve.js +1 -1
- package/dist/main/prepare-static.js +1 -1
- package/dist/plugins/rspack/multi-html/multi-html-modify-rspack-plugin.d.ts +3 -1
- package/dist/plugins/rspack/multi-html/multi-html-modify-rspack-plugin.js +1 -1
- package/dist/plugins/rspack/multi-html/multi-html-rspack-plugin.js +1 -1
- package/dist/plugins/webpack/multi-html/multi-html-modify-webpack-plugin.d.ts +3 -1
- package/dist/plugins/webpack/multi-html/multi-html-modify-webpack-plugin.js +1 -1
- package/dist/plugins/webpack/multi-html/multi-html-webpack-plugins.js +1 -1
- package/dist/types/types-dev-server.d.ts +0 -5
- package/dist/types/types-options.d.ts +7 -0
- package/package.json +1 -1
package/dist/constants.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { TemplateOptions } from '@hyperse/html-webpack-plugin-loader';
|
|
2
1
|
import { type EvolveEntryItemOption } from './types/types-entry-map.js';
|
|
3
2
|
export declare const moduleName = "@flatjs/evolve";
|
|
4
3
|
/**
|
|
@@ -15,10 +14,6 @@ export declare const envVariablesName = "GLOBAL_ENV_VARIABLES";
|
|
|
15
14
|
* The viewport code is dynamically inserted to `html` file via `html-plugin`
|
|
16
15
|
*/
|
|
17
16
|
export declare 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);";
|
|
18
|
-
/**
|
|
19
|
-
* https://polyfill.io
|
|
20
|
-
*/
|
|
21
|
-
export declare const polyfill: TemplateOptions['headScripts'];
|
|
22
17
|
/**
|
|
23
18
|
* Applies the react-refresh Babel plugin on non-production modes only
|
|
24
19
|
* Ensure `react-refresh/runtime` is hoisted and shared
|
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 envVariablesName="GLOBAL_ENV_VARIABLES";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
|
|
1
|
+
import process from"node:process";export const moduleName="@flatjs/evolve";export const configFileName="flatjs-evolve";export const envVariablesName="GLOBAL_ENV_VARIABLES";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 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+)?"];
|
package/dist/default-options.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const defaultEvolveOptions={projectCwd:process.cwd(),projectVirtualPath:"flatjs/evolve",rejectWarnings:!1,devServer:{autoOpen:!0,
|
|
1
|
+
export const defaultEvolveOptions={projectCwd:process.cwd(),projectVirtualPath:"flatjs/evolve",routeBaseName:"/pages",rejectWarnings:!1,devServer:{autoOpen:!0,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:{},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:[]},globalCompilerOptions:{runTsChecker:!0},entryMap:{},multiHtmlCdn:{},multiHtmlCdnEnvResolver:function cdnResolver(){},needVerifyPackages:{},packageInstallChecker:{enabled:!1,detectModules:["@dimjs/*"],throwError:!1,showAllInstalledGraph:!0},ci:{basedBranch:"origin/master"},isolation:!1,maxEntryGroupSize:10,compiler:"webpack",openRsdoctor:!1,inspector:{keys:["$mod","i"],customLaunchEditorEndpoint:"/__hps_inspector",trustedEditor:"code",injectClient:!0}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLaunchEditorMiddleware}from"@hyperse/inspector-middleware";import{normalizePageProxy}from"../helpers/normalize-page-proxy.js";import{createPageMiddleware,createPublicAssetsMiddleware}from"./middlewares/index.js";export const createAppPageRoute=(e,r,t,a,o)=>{const{devServer:d,inspector:i}=o,
|
|
1
|
+
import{createLaunchEditorMiddleware}from"@hyperse/inspector-middleware";import{normalizePageProxy}from"../helpers/normalize-page-proxy.js";import{createPageMiddleware,createPublicAssetsMiddleware}from"./middlewares/index.js";export const createAppPageRoute=(e,r,t,a,o)=>{const{devServer:d,inspector:i,routeBaseName:s}=o,c=normalizePageProxy(s||"/pages");i&&d?.middlewares?.push(createLaunchEditorMiddleware({customLaunchEditorEndpoint:i.customLaunchEditorEndpoint,trustedEditor:i.trustedEditor,projectCwd:e})),r.use(c,...createPageMiddleware(t,d?.mockOptions?.apiContext||"api",a,o)),r.use("*splat",createPublicAssetsMiddleware(e,c))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFileSync}from"node:fs";import{join}from"node:path";import{urlJoin}from"@flatjs/common";import{getPackageDir}from"../../helpers/get-pacakge-dir.js";import{normalizePageProxy}from"../../helpers/normalize-page-proxy.js";import{getSortedModules}from"./get-all-sorted-modules.js";import{MainModuleParser}from"./main-module-parser.js";export const getPageMainHtml=async(e,r,t)=>{const o=getPackageDir(),a=readFileSync(join(o,"./templates/main.html"),"utf-8"),n=getSortedModules(t,e,r),i=normalizePageProxy(t.
|
|
1
|
+
import{readFileSync}from"node:fs";import{join}from"node:path";import{urlJoin}from"@flatjs/common";import{getPackageDir}from"../../helpers/get-pacakge-dir.js";import{normalizePageProxy}from"../../helpers/normalize-page-proxy.js";import{getSortedModules}from"./get-all-sorted-modules.js";import{MainModuleParser}from"./main-module-parser.js";export const getPageMainHtml=async(e,r,t)=>{const o=getPackageDir(),a=readFileSync(join(o,"./templates/main.html"),"utf-8"),n=getSortedModules(t,e,r),i=normalizePageProxy(t.routeBaseName||"/pages"),s=n.map(e=>{const{entryName:t,entryContent:o,isServedEntry:a,projectVirtualPath:n,normalizedEntryName:s}=e,m=urlJoin(r,[i,s],{env:"me"}),l=o.options?.servePageMainLinkFn||(e=>e);return{link:l(m,{hostUri:r,entryName:t,virtualPath:n}),name:t.replace(n,"").replace(/^\//,""),flagText:a?"serve":"static",isServed:a?1:0}});s.push({flagText:"serve",isServed:1,link:urlJoin(r,[i,"/runtime/manifest.json"]),name:"Runtime Manifest"});const m={title:"@flatjs/evolve",modules:s.sort((e,r)=>r.isServed-e.isServed)};return new MainModuleParser(a,m).serialize()};
|
|
@@ -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{envVariablesName}from"../../constants.js";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{loadEnvConfig}from"../../helpers/load-env-config.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:i}=n,
|
|
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{envVariablesName}from"../../constants.js";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{loadEnvConfig}from"../../helpers/load-env-config.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:i}=n,a=Object.keys(s).sort((e,t)=>t.length-e.length),l=getPackageDir(),m=a.find(e=>{const r=normalizeEvolveEntryName(e,i);return ensureSlash(t.path.replace(/^\//,""),!0).startsWith(ensureSlash(r,!0))});if(!m){const e=readFileSync(join(l,"./templates/module-404.html"),"utf-8");return new ErrorModuleParser(e,{title:"404 Not Found",errorMeta:[{name:"@flatjs/evolve workspace",value:l},{name:"served entry names",value:JSON.stringify(a)},{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(l,"./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,i,e,f),S=normalizePageProxy(n.routeBaseName||"/pages"),H=normalizeTemplateInjectTokens(j,d);checkHtmlTemplateOptions(H);const N=parseTemplate(h);N.upsertTitleTag(getHtmlPluginConfig("title",j,d?.title));const M=H.favicon;M&&N.upsertFaviconTag(M.href,M.rel,M.attributes);const b=H.headMetaTags||[];N.upsertHeadMetaTags(b);const P=H.headStyles||[],w=getHtmlMaxOrder(P),k=getBundleAsset(u,y,".css");P.push({id:k,href:k,position:"end",order:w+1}),N.upsertHeadStyles(P);const C=H.headScripts||[],x=getHtmlMinOrder(C);getHmrRuntimeChunks(e,m,y,p,n,u).forEach(e=>{C.unshift({id:e,src:e,position:"end",order:x-1})}),N.upsertHeadScripts(C);const z=H.headInlineScripts||[],O=getHtmlMaxOrder(z),E=getHtmlMinOrder(z),T=Math.min(E,x),B=await loadEnvConfig("me",n)||{};z.push({id:"envVariables",content:`window.${envVariablesName}=${JSON.stringify({appName:n.projectVirtualPath,routeBaseName:n.routeBaseName,moduleName:m.replace(i,"").replace(/^\//,""),...B})}`,position:"beginning",order:-99});const D={hostUrl:r,apiBase:urlJoin(r,[o]),virtualPath:join(S,i),moduleName:m.replace(i,"").replace(/^\//,""),...v,...d?.serveGlobalData||{}};z.push({id:"globalData",content:`window.GLOBAL=${JSON.stringify(D)}`,position:"end",order:T-2}),allowPx2remForModule([m,p],n)&&z.push({id:"viewport",content:getHtmlPluginConfig("viewport",j,d?.viewport),position:"end",order:E-1});const F=getRuntimeCDNBase(n.multiHtmlCdn,n.multiHtmlCdnEnvResolver||function cdnResolver(){});z.push({id:"flatjsMultiCdn",content:F,position:"end",order:O+1});const J=injectFederationScripts({me:[urlJoin(r,["public"])]},n.multiHtmlCdnEnvResolver);z.push({id:"evolveFetchMicroWidgets",content:J,position:"end",order:O+2}),N.upsertHeadInlineScripts(z);const R=H.headInlineStyles||[];N.upsertHeadInlineStyles(R);const A=H.bodyScripts||[],I=getHtmlMaxOrder(A),V=getBundleAsset(u,y,".js");return A.push({id:V,src:V,position:"end",order:I+1}),N.upsertBodyScripts(A),N.serialize()};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{viewportScripts}from"../constants.js";import{getPackageDir}from"./get-pacakge-dir.js";export const defaultHtmlPluginConfig={title:"",favicon:{href:"",rel:"icon",attributes:{type:"image/x-icon"}},headMetaTags:[],headInlineScripts:[],headInlineStyles:[],headStyles:[],headScripts:[],bodyScripts:[],viewport:viewportScripts,excludeCdnEnvs:["me","dev","ntv"],htmlMinify:!0,templatePath:getPackageDir("templates/html-plugin/index-{0}.html")};export const getHtmlPluginConfig=(t,e,i)=>{let n;if(void 0!==i&&(n="function"==typeof i?i(e):i),void 0===n){const i=defaultHtmlPluginConfig[t];return"function"==typeof i?i(e):i}return n};
|
|
@@ -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
|
|
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}=e;if(!r)return e;const{externals:o}=e.webpack||{};if(o){let r=o;if("function"==typeof o&&(r=o()),r.react||r["react-dom"])return logger.warn("React and ReactDOM are external dependencies, you need to manually integrate Inspector"),e}const n=normalizePageProxy(e.routeBaseName||"/pages"),{keys:t=["$mod","i"],customLaunchEditorEndpoint:i="/__hps_inspector"}=r,s={"process.env.INSPECTOR_ENDPOINT":JSON.stringify(join(n,i)),"process.env.INSPECTOR_KEYS":JSON.stringify(t.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")},a=mergeOptions(e,{pluginOptions:{definePlugin:s}}),c=requireResolve(import.meta.url,"@hyperse/inspector"),p=searchPackageDir({cwd:fileURLToPath(dirname(c))});if(!p)return logger.debug("@hyperse/inspector package not found"),a;const g=join(p,"dist","client","index.js"),m=a.entryMap;for(const[e,r]of Object.entries(m)){r.entry.unshift(g)}return a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{arrayUnique,chalk,logger,urlJoin}from"@flatjs/common";import{attachMockMiddlewares}from"@flatjs/mock";import{ignoreEntryOptionKeys,moduleName}from"../constants.js";import{createRspackCompilerTask}from"../core/rspack/dev-serve/create-rspack-compiler-task.js";import{createWebpackCompilerTask}from"../core/webpack/dev-serve/create-webpack-compiler-task.js";import{createAppPageRoute,createDevServer,createDevServerEntries}from"../dev-server/index.js";import{flatEntryMap,openPage}from"../helpers/index.js";import{normalizePageProxy}from"../helpers/normalize-page-proxy.js";import{printPromotions}from"../helpers/print-promotion.js";import{splitToEntryGroup}from"../helpers/split-to-entry-group.js";import{verifyGroupEntryOptions}from"../helpers/verify-group-entry-options.js";import{envVerify}from"./env-verify.js";export const prepareServe=async(e,r,o)=>{await envVerify(e,o);const t=splitToEntryGroup(r,o,ignoreEntryOptionKeys,!0);if(!t.length)return void logger.warn("No served entries provided!");const s=[],{app:a,devPort:n,devHostUri:p,publicIp:i}=await createDevServer(o),c=o.devServer?.mockOptions?.mockFilters||[];for(const[,e]of Object.entries(r))c.push(...e.options?.mockFilters||[]);await attachMockMiddlewares(a,{...o.devServer?.mockOptions,mockFilters:arrayUnique(c),projectCwd:e});let m=n;const l=[];for(const e of t){if(!verifyGroupEntryOptions(e,ignoreEntryOptionKeys,!0))throw new Error("The entry options in a group must be the same.");m++;const r=await createDevServerEntries(m,e,o);l.push(r)}const
|
|
1
|
+
import{arrayUnique,chalk,logger,urlJoin}from"@flatjs/common";import{attachMockMiddlewares}from"@flatjs/mock";import{ignoreEntryOptionKeys,moduleName}from"../constants.js";import{createRspackCompilerTask}from"../core/rspack/dev-serve/create-rspack-compiler-task.js";import{createWebpackCompilerTask}from"../core/webpack/dev-serve/create-webpack-compiler-task.js";import{createAppPageRoute,createDevServer,createDevServerEntries}from"../dev-server/index.js";import{flatEntryMap,openPage}from"../helpers/index.js";import{normalizePageProxy}from"../helpers/normalize-page-proxy.js";import{printPromotions}from"../helpers/print-promotion.js";import{splitToEntryGroup}from"../helpers/split-to-entry-group.js";import{verifyGroupEntryOptions}from"../helpers/verify-group-entry-options.js";import{envVerify}from"./env-verify.js";export const prepareServe=async(e,r,o)=>{await envVerify(e,o);const t=splitToEntryGroup(r,o,ignoreEntryOptionKeys,!0);if(!t.length)return void logger.warn("No served entries provided!");const s=[],{app:a,devPort:n,devHostUri:p,publicIp:i}=await createDevServer(o),c=o.devServer?.mockOptions?.mockFilters||[];for(const[,e]of Object.entries(r))c.push(...e.options?.mockFilters||[]);await attachMockMiddlewares(a,{...o.devServer?.mockOptions,mockFilters:arrayUnique(c),projectCwd:e});let m=n;const l=[];for(const e of t){if(!verifyGroupEntryOptions(e,ignoreEntryOptionKeys,!0))throw new Error("The entry options in a group must be the same.");m++;const r=await createDevServerEntries(m,e,o);l.push(r)}const f=flatEntryMap(l);createAppPageRoute(e,a,p,f,o);const v=normalizePageProxy(o.routeBaseName||"/pages"),d=urlJoin(p,[v]);o.devServer?.autoOpen&&openPage(d);const{compiler:u}=o;printPromotions(o);for(const e of l){const r="webpack"===u?createWebpackCompilerTask(i,e,l,o):createRspackCompilerTask(i,e,l,o);s.push(r)}return Promise.all(s).then(()=>(logger.info(`debug page ➩ ${chalk(["cyan"])(d)}`,moduleName),process.stdin.resume(),process.stdin.setEncoding("utf8"),process.stdin.on("data",e=>{const r=e.toString();12===r.charCodeAt(0)?console.clear():[102,70].includes(r.charCodeAt(0))&&logger.info(`debug page ➩ ${chalk(["cyan"])(d)}`,moduleName)}),a))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{chalk,logger,urlJoin}from"@flatjs/common";import{attachMockMiddlewares}from"@flatjs/mock";import{createAppPageRoute}from"../dev-server/create-app-page-route.js";import{createDevServer}from"../dev-server/create-dev-server.js";import{normalizePageProxy}from"../helpers/normalize-page-proxy.js";import{openPage}from"../helpers/open-page.js";export const prepareStatic=async(e,r)=>{const{app:a,devHostUri:o}=await createDevServer(r);await attachMockMiddlewares(a,{...r.devServer?.mockOptions,projectCwd:e}),createAppPageRoute(e,a,o,{},r);const t=normalizePageProxy(r.
|
|
1
|
+
import{chalk,logger,urlJoin}from"@flatjs/common";import{attachMockMiddlewares}from"@flatjs/mock";import{createAppPageRoute}from"../dev-server/create-app-page-route.js";import{createDevServer}from"../dev-server/create-dev-server.js";import{normalizePageProxy}from"../helpers/normalize-page-proxy.js";import{openPage}from"../helpers/open-page.js";export const prepareStatic=async(e,r)=>{const{app:a,devHostUri:o}=await createDevServer(r);await attachMockMiddlewares(a,{...r.devServer?.mockOptions,projectCwd:e}),createAppPageRoute(e,a,o,{},r);const t=normalizePageProxy(r.routeBaseName||"/pages"),p=urlJoin(o,[t]);r.devServer?.autoOpen&&openPage(p),logger.info(`${"static page".padEnd(12," ")} ➩ ${chalk(["cyan"])(p)}`)};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Compiler } from 'webpack';
|
|
2
2
|
import type { EntryMapItem } from '../../../types/types-entry-map.js';
|
|
3
|
+
import type { FlatEvolveOptions } from '../../../types/types-options.js';
|
|
3
4
|
/**
|
|
4
5
|
* The MultiHtmlModifyPlugin class is responsible for modifying the HTML output of the webpack compiler.
|
|
5
6
|
* It hooks into the compilation process and replaces occurrences of "<%= title %>" with the title specified in the options.
|
|
@@ -7,6 +8,7 @@ import type { EntryMapItem } from '../../../types/types-entry-map.js';
|
|
|
7
8
|
export declare class MultiHtmlModifyRspackPlugin {
|
|
8
9
|
private pluginName;
|
|
9
10
|
private entryMapItemList;
|
|
10
|
-
|
|
11
|
+
private evolveOptions;
|
|
12
|
+
constructor(evolveOptions: FlatEvolveOptions, list: EntryMapItem[]);
|
|
11
13
|
apply(compiler: Compiler): void;
|
|
12
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import HtmlWebpackPlugin from"html-webpack-plugin";import{ensureSlash}from"@flatjs/common";import{parseTemplate}from"@hyperse/html-webpack-plugin-loader";const
|
|
1
|
+
import HtmlWebpackPlugin from"html-webpack-plugin";import{ensureSlash}from"@flatjs/common";import{parseTemplate}from"@hyperse/html-webpack-plugin-loader";import{envVariablesName}from"../../../constants.js";import{loadEnvConfig}from"../../../helpers/load-env-config.js";const getCurrentEntry=(e=[],t)=>{const i=e.find(e=>t.includes(ensureSlash(e[0],!0)));return i||void 0};export class MultiHtmlModifyRspackPlugin{constructor(e,t){this.pluginName="MultiHtmlModifyRspackPlugin",this.evolveOptions=e,this.entryMapItemList=t}apply(e){e.hooks.compilation.tap(this.pluginName,e=>{HtmlWebpackPlugin.getHooks(e).beforeEmit.tapAsync(this.pluginName,async(e,t)=>{const{projectVirtualPath:i,routeBaseName:n}=this.evolveOptions,{userOptions:o}=e.plugin,a=getCurrentEntry(this.entryMapItemList,e.outputName);if(!a)throw new Error("No entry map found!");const s=a[0],r=a[1].options,l=parseTemplate(e.html,{title:r?.title||""}),p=await loadEnvConfig(o.multiCdn.env,this.evolveOptions)||{};l.upsertHeadInlineScripts([{id:"envVariables",content:`window.${envVariablesName}=${JSON.stringify({appName:i,routeBaseName:n,moduleName:s.replace(i,"").replace(/^\//,""),...p})}`,position:"beginning",order:-99}]),t(null,{...e,html:l.serialize()})})})}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import HtmlWebpackPlugin from"html-webpack-plugin";import{existsSync}from"node:fs";import{logger,requireResolve}from"@flatjs/common";import{
|
|
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=async(e,t,l,i)=>{const o=l[0],[,n]=o,m=[new MultiHtmlModifyRspackPlugin(t,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};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Compiler } from 'webpack';
|
|
2
2
|
import type { EntryMapItem } from '../../../types/types-entry-map.js';
|
|
3
|
+
import type { FlatEvolveOptions } from '../../../types/types-options.js';
|
|
3
4
|
/**
|
|
4
5
|
* The MultiHtmlModifyPlugin class is responsible for modifying the HTML output of the webpack compiler.
|
|
5
6
|
* It hooks into the compilation process and replaces occurrences of "<%= title %>" with the title specified in the options.
|
|
@@ -7,6 +8,7 @@ import type { EntryMapItem } from '../../../types/types-entry-map.js';
|
|
|
7
8
|
export declare class MultiHtmlModifyWebpackPlugin {
|
|
8
9
|
private pluginName;
|
|
9
10
|
private entryMapItemList;
|
|
10
|
-
|
|
11
|
+
private evolveOptions;
|
|
12
|
+
constructor(evolveOptions: FlatEvolveOptions, list: EntryMapItem[]);
|
|
11
13
|
apply(compiler: Compiler): void;
|
|
12
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import HtmlWebpackPlugin from"html-webpack-plugin";import{ensureSlash}from"@flatjs/common";import{parseTemplate}from"@hyperse/html-webpack-plugin-loader";const
|
|
1
|
+
import HtmlWebpackPlugin from"html-webpack-plugin";import{ensureSlash}from"@flatjs/common";import{parseTemplate}from"@hyperse/html-webpack-plugin-loader";import{envVariablesName}from"../../../constants.js";import{loadEnvConfig}from"../../../helpers/load-env-config.js";const getCurrentEntry=(e=[],t)=>{const i=e.find(e=>t.includes(ensureSlash(e[0],!0)));return i||void 0};export class MultiHtmlModifyWebpackPlugin{constructor(e,t){this.pluginName="MultiHtmlModifyWebpackPlugin",this.evolveOptions=e,this.entryMapItemList=t}apply(e){e.hooks.compilation.tap(this.pluginName,e=>{HtmlWebpackPlugin.getHooks(e).beforeEmit.tapAsync(this.pluginName,async(e,t)=>{const{projectVirtualPath:i,routeBaseName:n}=this.evolveOptions,{userOptions:o}=e.plugin,a=getCurrentEntry(this.entryMapItemList,e.outputName);if(!a)throw new Error("No entry map found!");const r=a[0],l=a[1].options,s=parseTemplate(e.html,{title:l?.title||""}),p=await loadEnvConfig(o.multiCdn.env,this.evolveOptions)||{};s.upsertHeadInlineScripts([{id:"envVariables",content:`window.${envVariablesName}=${JSON.stringify({appName:i,routeBaseName:n,moduleName:r.replace(i,"").replace(/^\//,""),...p})}`,position:"beginning",order:-99}]),t(null,{...e,html:s.serialize()})})})}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import HtmlWebpackPlugin from"html-webpack-plugin";import{existsSync}from"node:fs";import{logger,requireResolve}from"@flatjs/common";import{
|
|
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=async(e,t,l,i)=>{const o=l[0],[,n]=o,m=[new MultiHtmlModifyWebpackPlugin(t,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||[],a=getHtmlMinOrder(n);if(allowPx2remForModule(o,t)){const e=getHtmlPluginConfig("viewport",l,r?.viewport);n.unshift({id:"viewport",content:e,position:"end",order:a-1})}let c=getHtmlPluginConfig("templatePath",l,r?.templatePath).replace("{0}",e.trim());existsSync(c)||(logger.warn(`The template file ${c} is not exists, use \`prod\` instead!`),c=getHtmlPluginConfig("templatePath",l,r?.templatePath).replace("{0}","prod"));c=`${requireResolve(import.meta.url,"@hyperse/html-webpack-plugin-loader/loader")}!${c}`,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:c,templateParameters:{title:"",...i,headInlineScripts:n},multiCdn:{env:e,disabled:(r?.excludeCdnEnvs||["me","dev","ntv"]).includes(e)}}))}return m};
|
|
@@ -22,11 +22,6 @@ export interface WebpackWatchOptions {
|
|
|
22
22
|
poll?: number | boolean;
|
|
23
23
|
}
|
|
24
24
|
export type FlatEvolveDevServerOptions = {
|
|
25
|
-
/**
|
|
26
|
-
* must have prefix slash `/`
|
|
27
|
-
* @default `/pages`
|
|
28
|
-
*/
|
|
29
|
-
pageProxy?: string;
|
|
30
25
|
/**
|
|
31
26
|
* Allow us provider customized middlewares for `page`, `modules`
|
|
32
27
|
*/
|
|
@@ -39,6 +39,13 @@ export interface FlatEvolveOptions {
|
|
|
39
39
|
* The project workspace directory.
|
|
40
40
|
*/
|
|
41
41
|
projectCwd: string;
|
|
42
|
+
/**
|
|
43
|
+
* The route base name for current `project`
|
|
44
|
+
* must have prefix slash `/`
|
|
45
|
+
* e.g. `/pages` or `/route`
|
|
46
|
+
* @default `/pages`
|
|
47
|
+
*/
|
|
48
|
+
routeBaseName?: string;
|
|
42
49
|
/**
|
|
43
50
|
* The virtual path for current `project`
|
|
44
51
|
* e.g. `evolve/test`
|