@flatjs/evolve 2.0.14 → 2.1.0-next.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. package/dist/dev-server/create-app-page-route.d.ts +1 -1
  2. package/dist/dev-server/create-app-page-route.js +1 -1
  3. package/dist/dev-server/create-dev-server-compiler-tasks.d.ts +1 -1
  4. package/dist/dev-server/create-dev-server-entries.d.ts +1 -1
  5. package/dist/dev-server/middlewares/create-page-middleware.d.ts +1 -24
  6. package/dist/dev-server/middlewares/create-page-middleware.js +1 -1
  7. package/dist/dev-server/middlewares/get-all-sorted-modules.d.ts +34 -0
  8. package/dist/dev-server/middlewares/get-all-sorted-modules.js +1 -0
  9. package/dist/dev-server/middlewares/get-bundle-asset.d.ts +1 -0
  10. package/dist/dev-server/middlewares/get-bundle-asset.js +1 -0
  11. package/dist/dev-server/middlewares/get-dev-server-host-uri.d.ts +2 -0
  12. package/dist/dev-server/middlewares/get-dev-server-host-uri.js +1 -0
  13. package/dist/dev-server/middlewares/get-hmr-runtime-chunks.d.ts +4 -0
  14. package/dist/dev-server/middlewares/get-hmr-runtime-chunks.js +1 -0
  15. package/dist/dev-server/middlewares/get-normalized-entry-name.d.ts +3 -0
  16. package/dist/dev-server/middlewares/get-normalized-entry-name.js +1 -0
  17. package/dist/dev-server/middlewares/get-page-main-html.d.ts +3 -0
  18. package/dist/dev-server/middlewares/get-page-main-html.js +1 -0
  19. package/dist/dev-server/middlewares/get-page-module-html.d.ts +4 -0
  20. package/dist/dev-server/middlewares/get-page-module-html.js +1 -0
  21. package/dist/dev-server/middlewares/get-project-virtual-path.d.ts +2 -0
  22. package/dist/dev-server/middlewares/get-project-virtual-path.js +1 -0
  23. package/dist/dev-server/middlewares/get-runtime-manifest.d.ts +13 -0
  24. package/dist/dev-server/middlewares/get-runtime-manifest.js +1 -0
  25. package/dist/dev-server/middlewares/types.d.ts +24 -0
  26. package/dist/dev-server/middlewares/types.js +1 -0
  27. package/dist/helpers/get-html-plugin-config.d.ts +1 -1
  28. package/dist/helpers/normalize-page-proxy.d.ts +6 -0
  29. package/dist/helpers/normalize-page-proxy.js +1 -0
  30. package/dist/main/create-thread-worker.d.ts +3 -3
  31. package/dist/main/prepare-serve.js +1 -1
  32. package/dist/main/prepare-static.js +1 -1
  33. package/dist/main/start-build-dynamic.d.ts +1 -1
  34. package/dist/types/types-dev-server.d.ts +1 -0
  35. package/package.json +38 -38
@@ -1,6 +1,6 @@
1
1
  import { type Application } from 'express';
2
2
  import { type FlatEvolveOptions } from '../types/index.js';
3
- import { type EvolveDevServerEntryMap } from './middlewares/index.js';
3
+ import { type EvolveDevServerEntryMap } from './middlewares/types.js';
4
4
  /**
5
5
  * Add route `/pages`, `*` to main web-server
6
6
  */
@@ -1 +1 @@
1
- import{createPageMiddleware,createPublicAssetsMiddleware}from"./middlewares/index.js";export const createAppPageRoute=(e,a,r,t,s)=>{const{devServer:d}=s,i=d?.pageProxy||"/pages";a.use(i,...createPageMiddleware(r,d?.mockOptions?.apiContext||"api",t,s)),a.use("*",createPublicAssetsMiddleware(e,i))};
1
+ import{normalizePageProxy}from"../helpers/normalize-page-proxy.js";import{createPageMiddleware,createPublicAssetsMiddleware}from"./middlewares/index.js";export const createAppPageRoute=(e,r,a,o,i)=>{const{devServer:s}=i,t=normalizePageProxy(s?.pageProxy||"/pages");r.use(t,...createPageMiddleware(a,s?.mockOptions?.apiContext||"api",o,i)),r.use("*",createPublicAssetsMiddleware(e,t))};
@@ -1,3 +1,3 @@
1
1
  import { type FlatEvolveOptions } from '../types/types-options.js';
2
- import { type EvolveDevServerEntryMap } from './middlewares/create-page-middleware.js';
2
+ import { type EvolveDevServerEntryMap } from './middlewares/types.js';
3
3
  export declare const createDevServerCompilerTasks: (projectCwd: string, mainPage: string, publicIp: string, servedDevServerEntries: EvolveDevServerEntryMap, evolveOptions: FlatEvolveOptions) => Promise<Promise<boolean>[]>;
@@ -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
- import { type EvolveDevServerEntryMap } from './middlewares/create-page-middleware.js';
3
+ import { type EvolveDevServerEntryMap } from './middlewares/types.js';
4
4
  export declare const createDevServerEntries: (startPort: number, servedEntries: EvolveEntryMap, evolveOptions: FlatEvolveOptions) => Promise<EvolveDevServerEntryMap>;
@@ -1,29 +1,6 @@
1
1
  import { type RequestHandler } from 'express';
2
- import { type EvolveEntryMapContent } from '../../types/types-entry-map.js';
3
2
  import { type FlatEvolveOptions } from '../../types/types-options.js';
4
- export type EvolveDevServerEntryMap = {
5
- /**
6
- * entryName: `home`
7
- */
8
- [entryName: string]: {
9
- /**
10
- * entryMapItem config options.
11
- */
12
- entryConfig: EvolveEntryMapContent;
13
- /**
14
- * dev server port number
15
- */
16
- devServerPort: number;
17
- /**
18
- * dev server host uri.
19
- */
20
- devServerHostUri: string;
21
- /**
22
- * entryName: `home` should be normallized to ${`projectVirtualPath`}/home
23
- */
24
- normalizedEntryName: string;
25
- };
26
- };
3
+ import { type EvolveDevServerEntryMap } from './types.js';
27
4
  /**
28
5
  * A middleware to proxy the page modules template.
29
6
  * @example `http://dev.flatjs.com:3001/pages`
@@ -1 +1 @@
1
- import{existsSync,readFileSync}from"node:fs";import{isAbsolute,join}from"node:path";import{ensureSlash,urlJoin}from"@flatjs/common";import _ from"lodash";import{devReactFastRefresh}from"../../constants.js";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{injectFederationScripts}from"../../helpers/script-injects.js";import{shouldEnableReactFastRefresh}from"../../helpers/should-enable-react-fast-refresh.js";const getPageMainHtml=async(e,t,r)=>{const l=getPackageDir(),a=readFileSync(join(l,"./templates/main.html"),"utf-8"),o=[],i=r.projectVirtualPath.replace(/^\//,"");for(const[l,a]of Object.entries(r.entryMap)){const s=a.options?.servePageMainLinkFn||(e=>e),n=Object.keys(e).includes(l),m=normalizeEvolveEntryName(l,i),c=r.devServer?.pageProxy||"/pages",p=urlJoin(t,[c,m],{env:"me"});o.push({name:l.replace(i,"").replace(/^\//,""),link:s(p,{hostUri:t,entryName:l,virtualPath:i}),flagText:n?"serve":"static",isServed:n?1:0})}const s={title:"@flatjs/evolve",modules:o.sort(((e,t)=>t.isServed-e.isServed))};return _.template(a)(s)},getPageModuleHtml=async(e,t,r,l,a)=>{const{entryMap:o,projectVirtualPath:i}=a,s=Object.keys(o).sort(((e,t)=>t.length-e.length)),n=getPackageDir(),m=s.find((e=>{const r=normalizeEvolveEntryName(e,i);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 c=o[m],p=c.options,d=e[m],u=d?.devServerHostUri||r,f=p?.serveModuleTemplate||"./templates/module.html",g=join(a.projectCwd,"./templates/module.html"),h=readFileSync(isAbsolute(f)?f:existsSync(g)?g:join(n,"./templates/module.html"),"utf-8"),v=a.devServer,S=v?.defaultServeGlobalData?await v.defaultServeGlobalData(c,r):{},j={mode:"development",envCdn:urlJoin(r,["public"])};let y=normalizeEvolveEntryName(m,i);if(v?.bundleDirResolver){const t=Object.keys(e).includes(m);y=v?.bundleDirResolver(y,{currEntry:m,projectVirtualPath:i,isServedModule:t})}const P=v?.pageProxy||"/pages",b={title:getHtmlPluginConfig("title",j,p?.title),favicon:getHtmlPluginConfig("favicon",j,p?.favicon),viewport:allowPx2remForModule([m,c],a)?getHtmlPluginConfig("viewport",j,p?.viewport):"",headBeforeHtmlTags:getHtmlPluginConfig("headBeforeHtmlTags",j,p?.headBeforeHtmlTags),inlineScripts:getHtmlPluginConfig("inlineScripts",j,p?.inlineScripts),headBeforeStyles:getHtmlPluginConfig("headBeforeStyles",j,p?.headBeforeStyles),headBeforeScripts:getHtmlPluginConfig("headBeforeScripts",j,p?.headBeforeScripts),bodyAfterScripts:getHtmlPluginConfig("bodyAfterScripts",j,p?.bodyAfterScripts),moduleFederationScripts:injectFederationScripts({me:[urlJoin(r,["public"])]},a.multiHtmlCdnEnvResolver),global:{hostUrl:r,apiBase:urlJoin(r,[l]),virtualPath:join(P,i),moduleName:m.replace(i,"").replace(/^\//,""),...S,...p?.serveGlobalData||{}},styles:[urlJoin(u,[join("public",y,"bundle.css")])],scripts:[urlJoin(u,[join("public",y,"bundle.js")])]};if(e[m]&&shouldEnableReactFastRefresh(!0,[y,c],a)){const e=[devReactFastRefresh.runtime,devReactFastRefresh.reactRefreshSetup];b.headBeforeHtmlTags?b.headBeforeHtmlTags=b.headBeforeHtmlTags.slice(0):b.headBeforeHtmlTags=[],e.forEach((e=>{const t=urlJoin(u,[join("public",join(y,e),"bundle.js")]);b.headBeforeHtmlTags?.push(`<script src="${t}"><\/script>`)}))}return _.template(h)(b)};export const createPageMiddleware=(e,t,r,l)=>(l.devServer?.middlewares||[]).concat((async(a,o)=>{let i;i="/"===a.path?await getPageMainHtml(r,e,l):await getPageModuleHtml(r,a,e,t,l),o.send(i)}));
1
+ import{getPageMainHtml}from"./get-page-main-html.js";import{getPageModuleHtml}from"./get-page-module-html.js";import{getRuntimeManifest}from"./get-runtime-manifest.js";export const createPageMiddleware=(e,t,a,m)=>(m.devServer?.middlewares||[]).concat((async(i,n)=>{let g;if("/runtime/manifest.json"===i.path){const t=await getRuntimeManifest(a,e,m);return n.json(t)}g="/"===i.path?await getPageMainHtml(a,e,m):await getPageModuleHtml(a,i,e,t,m),n.send(g)}));
@@ -0,0 +1,34 @@
1
+ import { type EvolveEntryMapContent } from '../../types/types-entry-map.js';
2
+ import { type FlatEvolveOptions } from '../../types/types-options.js';
3
+ import { type EvolveDevServerEntryMap } from './types.js';
4
+ export interface SortedModuleItem {
5
+ /**
6
+ * The entry name defined in `entryMap`
7
+ */
8
+ entryName: string;
9
+ /**
10
+ * The value indicates whether the entry is served by the dev server.
11
+ */
12
+ isServedEntry: boolean;
13
+ /**
14
+ * The normalized project virtual path.
15
+ */
16
+ projectVirtualPath: string;
17
+ /**
18
+ * THe entry content defined in `entryMap`
19
+ */
20
+ entryContent: EvolveEntryMapContent;
21
+ /**
22
+ * The main dev server host uri
23
+ */
24
+ devHostUri: string;
25
+ /**
26
+ * The normalized dev server host uri
27
+ */
28
+ devServerHostUri: string;
29
+ /**
30
+ * The normalized entry name.
31
+ */
32
+ normalizedEntryName: string;
33
+ }
34
+ export declare function getSortedModules(evolveOptions: FlatEvolveOptions, servedDevServerEntries: EvolveDevServerEntryMap, devHostUri: string): SortedModuleItem[];
@@ -0,0 +1 @@
1
+ import{getDevServerHostUri}from"./get-dev-server-host-uri.js";import{getNormalizedEntryName}from"./get-normalized-entry-name.js";import{getProjectVirtualPath}from"./get-project-virtual-path.js";export function getSortedModules(e,t,r){const o=[],n=getProjectVirtualPath(e);for(const[i,a]of Object.entries(e.entryMap)){const s=Object.keys(t).includes(i),m=getDevServerHostUri(t,i,r),v=getNormalizedEntryName(i,n,t,e.devServer);o.push({entryName:i,entryContent:a,devHostUri:r,devServerHostUri:m,normalizedEntryName:v,projectVirtualPath:n,isServedEntry:s})}return o}
@@ -0,0 +1 @@
1
+ export declare const getBundleAsset: (devServerHostUri: string, normalizedCurrEntry: string, extension: '.css' | '.js') => string;
@@ -0,0 +1 @@
1
+ import{join}from"node:path/posix";import{urlJoin}from"@flatjs/common";export const getBundleAsset=(o,n,i)=>urlJoin(o,[join("public",n,`bundle${i}`)]);
@@ -0,0 +1,2 @@
1
+ import { type EvolveDevServerEntryMap } from './types.js';
2
+ export declare function getDevServerHostUri(servedDevServerEntries: EvolveDevServerEntryMap, currEntry: string, devHostUri: string): string;
@@ -0,0 +1 @@
1
+ export function getDevServerHostUri(e,r,t){const o=e[r];return o?.devServerHostUri||t}
@@ -0,0 +1,4 @@
1
+ import { type EvolveEntryMapContent } from '../../types/types-entry-map.js';
2
+ import { type FlatEvolveOptions } from '../../types/types-options.js';
3
+ import { type EvolveDevServerEntryMap } from './types.js';
4
+ export declare function getHmrRuntimeChunks(servedDevServerEntries: EvolveDevServerEntryMap, entryName: string, normalizedCurrEntry: string, currEntryItem: EvolveEntryMapContent, evolveOptions: FlatEvolveOptions, devServerHostUri: string): string[];
@@ -0,0 +1 @@
1
+ import{join}from"node:path";import{devReactFastRefresh}from"../../constants.js";import{shouldEnableReactFastRefresh}from"../../helpers/should-enable-react-fast-refresh.js";import{getBundleAsset}from"./get-bundle-asset.js";export function getHmrRuntimeChunks(e,t,s,r,n,a){if(e[t]&&shouldEnableReactFastRefresh(!0,[s,r],n)){return[getBundleAsset(a,join(s,devReactFastRefresh.runtime),".js"),getBundleAsset(a,join(s,devReactFastRefresh.reactRefreshSetup),".js")]}return[]}
@@ -0,0 +1,3 @@
1
+ import { type FlatEvolveDevServerOptions } from '../../types/types-dev-server.js';
2
+ import { type EvolveDevServerEntryMap } from './types.js';
3
+ export declare function getNormalizedEntryName(entryName: string, projectVirtualPath: string, servedDevServerEntries: EvolveDevServerEntryMap, devServer?: FlatEvolveDevServerOptions): string;
@@ -0,0 +1 @@
1
+ import{normalizeEvolveEntryName}from"../../helpers/normalize-entry-map.js";export function getNormalizedEntryName(e,r,t,l){let n=normalizeEvolveEntryName(e,r);if(l?.bundleDirResolver){const o=Object.keys(t).includes(e);n=l?.bundleDirResolver(n,{currEntry:e,projectVirtualPath:r,isServedModule:o})}return n}
@@ -0,0 +1,3 @@
1
+ import { type FlatEvolveOptions } from '../../types/types-options.js';
2
+ import { type EvolveDevServerEntryMap } from './types.js';
3
+ export declare const getPageMainHtml: (servedDevServerEntries: EvolveDevServerEntryMap, devHostUri: string, evolveOptions: FlatEvolveOptions) => Promise<string>;
@@ -0,0 +1 @@
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)};
@@ -0,0 +1,4 @@
1
+ import { type Request } from 'express';
2
+ import { type FlatEvolveOptions } from '../../types/types-options.js';
3
+ import { type EvolveDevServerEntryMap } from './types.js';
4
+ export declare const getPageModuleHtml: (servedDevServerEntries: EvolveDevServerEntryMap, req: Request, devHostUri: string, apiContext: string, evolveOptions: FlatEvolveOptions) => Promise<string>;
@@ -0,0 +1 @@
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,2 @@
1
+ import { type FlatEvolveOptions } from '../../types/types-options.js';
2
+ export declare const getProjectVirtualPath: (evolveOptions: FlatEvolveOptions) => string;
@@ -0,0 +1 @@
1
+ export const getProjectVirtualPath=t=>t.projectVirtualPath.replace(/^\//,"");
@@ -0,0 +1,13 @@
1
+ import { type FlatEvolveOptions } from '../../types/types-options.js';
2
+ import { type EvolveDevServerEntryMap } from './types.js';
3
+ interface RuntimeManifest {
4
+ [normalizedEntryName: string]: {
5
+ entryName: string;
6
+ styles: string[];
7
+ scripts: string[];
8
+ runtimeChunks: string[];
9
+ isServed: boolean;
10
+ };
11
+ }
12
+ export declare const getRuntimeManifest: (servedDevServerEntries: EvolveDevServerEntryMap, devHostUri: string, evolveOptions: FlatEvolveOptions) => Promise<RuntimeManifest>;
13
+ export {};
@@ -0,0 +1 @@
1
+ import{getSortedModules}from"./get-all-sorted-modules.js";import{getBundleAsset}from"./get-bundle-asset.js";import{getHmrRuntimeChunks}from"./get-hmr-runtime-chunks.js";export const getRuntimeManifest=async(e,t,s)=>{const r=getSortedModules(s,e,t),n={};for(const t of r){const{entryName:r,isServedEntry:o,entryContent:m,devServerHostUri:u,normalizedEntryName:d}=t,i=[getBundleAsset(u,d,".js")],g=[getBundleAsset(u,d,".css")],l=getHmrRuntimeChunks(e,r,d,m,s,u);n[d]={entryName:r,styles:g,scripts:i,isServed:o,runtimeChunks:l}}return n};
@@ -0,0 +1,24 @@
1
+ import { type EvolveEntryMapContent } from '../../types/types-entry-map.js';
2
+ export type EvolveDevServerEntryMap = {
3
+ /**
4
+ * entryName: `home`
5
+ */
6
+ [entryName: string]: {
7
+ /**
8
+ * entryMapItem config options.
9
+ */
10
+ entryConfig: EvolveEntryMapContent;
11
+ /**
12
+ * dev server port number
13
+ */
14
+ devServerPort: number;
15
+ /**
16
+ * dev server host uri.
17
+ */
18
+ devServerHostUri: string;
19
+ /**
20
+ * entryName: `home` should be normallized to ${`projectVirtualPath`}/home
21
+ */
22
+ normalizedEntryName: string;
23
+ };
24
+ };
@@ -0,0 +1 @@
1
+ export{};
@@ -16,5 +16,5 @@ export type HtmlPluginConfigTokenType<T extends Json> = T | ((configData: HtmlPl
16
16
  * @param preferredValue 用户首选的值, 如果返回为undefined, 将使用默认值
17
17
  * @returns
18
18
  */
19
- export declare const getHtmlPluginConfig: <T extends Json>(key: keyof typeof defaultHtmlPluginConfig, configData: HtmlPluginConfigConfigData, preferredValue?: HtmlPluginConfigTokenType<T> | undefined) => T;
19
+ export declare const getHtmlPluginConfig: <T extends Json>(key: keyof typeof defaultHtmlPluginConfig, configData: HtmlPluginConfigConfigData, preferredValue?: HtmlPluginConfigTokenType<T>) => T;
20
20
  export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * We need to normalize the page proxy to make sure that we have prefix slash.
3
+ * @param pageProxy `/pages`
4
+ * @returns The normalized page proxy
5
+ */
6
+ export declare const normalizePageProxy: (pageProxy?: string) => string;
@@ -0,0 +1 @@
1
+ export const normalizePageProxy=(e="/pages")=>"/"+(e.replace(/^\//,"").replace(/\/$/,"")||"pages");
@@ -3,14 +3,14 @@ import { startBuildWorker } from './start-build-worker.js';
3
3
  declare class ThreadPoolForUnittest implements BaseWorker {
4
4
  private workerSize;
5
5
  constructor(workerSize: number);
6
- startBuildWorker(...args: Parameters<typeof startBuildWorker>): Promise<import("./start-one-entry-build.js").EvolveBuildResult>;
6
+ startBuildWorker(...args: Parameters<typeof startBuildWorker>): Promise<import("src/main/start-one-entry-build.js").EvolveBuildResult>;
7
7
  get pool(): PoolInterface;
8
8
  }
9
9
  export declare const createThreadWorker: (workerSize: number) => Promise<ThreadPoolForUnittest | (BaseWorker & {
10
10
  all: {
11
- readonly startBuildWorker: (projectCwd: string, entryKey: string, serializedEvolveOptions: string, configLoaderOptions?: import("../load-config/types.js").ConfigLoaderOptions | undefined) => Promise<import("./start-one-entry-build.js").EvolveBuildResult>;
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
12
  };
13
13
  } & {
14
- readonly startBuildWorker: (projectCwd: string, entryKey: string, serializedEvolveOptions: string, configLoaderOptions?: import("../load-config/types.js").ConfigLoaderOptions | undefined) => Promise<import("./start-one-entry-build.js").EvolveBuildResult>;
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
15
  })>;
16
16
  export {};
@@ -1 +1 @@
1
- import{arrayUnique,urlJoin}from"@flatjs/common";import{attachMockMiddlewares}from"@flatjs/mock";import{createAppPageRoute,createDevServer,createDevServerCompilerTasks,createDevServerEntries}from"../dev-server/index.js";import{openPage}from"../helpers/index.js";import{envVerify}from"./env-verify.js";export const prepareServe=async(e,r,t)=>{await envVerify(e,t);const{app:o,devPort:a,devHostUri:i,publicIp:s}=await createDevServer(t),c=t.devServer?.mockOptions?.mockFilters||[];for(const[,e]of Object.entries(r))c.push(...e.options?.mockFilters||[]);await attachMockMiddlewares(o,{...t.devServer?.mockOptions,mockFilters:arrayUnique(c),projectCwd:e});const p=await createDevServerEntries(a,r,t);createAppPageRoute(e,o,i,p,t);const v=t.devServer?.pageProxy||"/pages",n=urlJoin(i,[v]);t.devServer?.autoOpen&&openPage(n);const m=await createDevServerCompilerTasks(e,n,s,p,t);return Promise.all(m).then((()=>o))};
1
+ import{arrayUnique,urlJoin}from"@flatjs/common";import{attachMockMiddlewares}from"@flatjs/mock";import{createAppPageRoute,createDevServer,createDevServerCompilerTasks,createDevServerEntries}from"../dev-server/index.js";import{openPage}from"../helpers/index.js";import{normalizePageProxy}from"../helpers/normalize-page-proxy.js";import{envVerify}from"./env-verify.js";export const prepareServe=async(e,r,o)=>{await envVerify(e,o);const{app:t,devPort:a,devHostUri:i,publicIp:s}=await createDevServer(o),p=o.devServer?.mockOptions?.mockFilters||[];for(const[,e]of Object.entries(r))p.push(...e.options?.mockFilters||[]);await attachMockMiddlewares(t,{...o.devServer?.mockOptions,mockFilters:arrayUnique(p),projectCwd:e});const n=await createDevServerEntries(a,r,o);createAppPageRoute(e,t,i,n,o);const c=normalizePageProxy(o.devServer?.pageProxy||"/pages"),v=urlJoin(i,[c]);o.devServer?.autoOpen&&openPage(v);const m=await createDevServerCompilerTasks(e,v,s,n,o);return Promise.all(m).then((()=>t))};
@@ -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{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=r.devServer?.pageProxy||"/pages",p=urlJoin(o,[t]);r.devServer?.autoOpen&&openPage(p),logger.info(`${"static page".padEnd(12," ")} ➩ ${chalk(["cyan"])(p)}`)};
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.devServer?.pageProxy||"/pages"),p=urlJoin(o,[t]);r.devServer?.autoOpen&&openPage(p),logger.info(`${"static page".padEnd(12," ")} ➩ ${chalk(["cyan"])(p)}`)};
@@ -8,7 +8,7 @@ export declare function getBuildEntryFiles(projectCwd: string, diffFiles: string
8
8
  * @returns
9
9
  */
10
10
  export declare function dynamicCheckBuildEntryMap(projectCwd: string, earlyCommit?: string | null, lastCommit?: string, overrideEvolveOptions?: PartialDeep<FlatEvolveOptions>, configLoaderOptions?: ConfigLoaderOptions): Promise<{
11
- buildEntries: import("../index.js").EvolveEntryMap;
11
+ buildEntries: import("src/index.js").EvolveEntryMap;
12
12
  newEvolveOptions: FlatEvolveOptions;
13
13
  }>;
14
14
  /**
@@ -23,6 +23,7 @@ export interface WebpackWatchOptions {
23
23
  }
24
24
  export type FlatEvolveDevServerOptions = {
25
25
  /**
26
+ * must have prefix slash `/`
26
27
  * @default `/pages`
27
28
  */
28
29
  pageProxy?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatjs/evolve",
3
- "version": "2.0.14",
3
+ "version": "2.1.0-next.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -18,7 +18,7 @@
18
18
  "./templates"
19
19
  ],
20
20
  "scripts": {
21
- "serve": "yarn ts-node-esm ./tests/dev-server/dev-server.ts",
21
+ "serve": "yarn node --import=@armit/path-alias/register ./tests/dev-server/dev-server.ts",
22
22
  "build": "rimraf dist && tsc -p ./tsconfig.build.json && npm run minify",
23
23
  "?build-release": "When https://github.com/atlassian/changesets/issues/432 has a solution we can remove this trick",
24
24
  "build-release": "yarn build && rimraf ./_release && yarn pack && mkdir ./_release && tar zxvf ./package.tgz --directory ./_release && rm ./package.tgz",
@@ -34,72 +34,72 @@
34
34
  "typecheck": "tsc --project ./tsconfig.json --noEmit"
35
35
  },
36
36
  "dependencies": {
37
- "@armit/babel-merge": "^0.1.4",
38
- "@armit/config-loader": "^0.1.5",
39
- "@armit/file-utility": "^0.1.3",
40
- "@armit/git": "^0.1.3",
41
- "@armit/package": "^0.1.4",
42
- "@armit/worker-threads": "^0.1.3",
43
- "@babel/core": "7.23.9",
44
- "@flatjs/common": "2.0.4",
45
- "@flatjs/evolve-preset-babel": "2.0.4",
46
- "@flatjs/forge-postcss-plugin-pixel": "2.0.4",
47
- "@flatjs/graph": "2.0.6",
48
- "@flatjs/mock": "2.0.8",
37
+ "@armit/babel-merge": "^0.1.5",
38
+ "@armit/config-loader": "^0.1.6",
39
+ "@armit/file-utility": "^0.1.4",
40
+ "@armit/git": "^0.1.4",
41
+ "@armit/package": "^0.1.5",
42
+ "@armit/worker-threads": "^0.1.4",
43
+ "@babel/core": "7.24.3",
44
+ "@flatjs/common": "2.1.0-next.0",
45
+ "@flatjs/evolve-preset-babel": "2.1.0-next.0",
46
+ "@flatjs/forge-postcss-plugin-pixel": "2.1.0-next.0",
47
+ "@flatjs/graph": "2.1.0-next.0",
48
+ "@flatjs/mock": "2.1.0-next.0",
49
49
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.11",
50
50
  "@types/babel__core": "7.20.5",
51
51
  "babel-loader": "9.1.3",
52
52
  "babel-plugin-import": "1.13.8",
53
53
  "better-opn": "3.0.2",
54
54
  "case-sensitive-paths-webpack-plugin": "2.4.0",
55
- "css-loader": "6.9.1",
56
- "cssnano": "6.0.3",
57
- "express": "4.18.2",
55
+ "css-loader": "6.10.0",
56
+ "cssnano": "6.1.2",
57
+ "express": "4.19.2",
58
58
  "fork-ts-checker-webpack-plugin": "9.0.2",
59
- "happy-dom": "13.3.1",
59
+ "happy-dom": "14.3.10",
60
60
  "html-webpack-plugin": "5.6.0",
61
61
  "image-minimizer-webpack-plugin": "4.0.0",
62
62
  "less": "4.2.0",
63
- "less-loader": "12.1.0",
63
+ "less-loader": "12.2.0",
64
64
  "listr": "0.14.3",
65
65
  "lodash": "4.17.21",
66
- "mini-css-extract-plugin": "2.7.7",
67
- "postcss": "8.4.33",
68
- "postcss-loader": "8.0.0",
66
+ "mini-css-extract-plugin": "2.8.1",
67
+ "postcss": "8.4.38",
68
+ "postcss-loader": "8.1.1",
69
69
  "react-refresh": "0.14.0",
70
70
  "svgo": "3.2.0",
71
71
  "tarjan-graph": "3.0.0",
72
72
  "terser-webpack-plugin": "5.3.10",
73
73
  "tsconfig-paths-webpack-plugin": "4.1.0",
74
- "type-fest": "^4.10.1",
75
- "typescript": "5.3.3",
76
- "webpack": "5.90.0",
74
+ "type-fest": "^4.14.0",
75
+ "typescript": "5.4.3",
76
+ "webpack": "5.91.0",
77
77
  "webpack-bundle-analyzer": "4.10.1",
78
- "webpack-dev-server": "4.15.1",
78
+ "webpack-dev-server": "5.0.4",
79
79
  "webpack-sources": "3.2.3"
80
80
  },
81
81
  "devDependencies": {
82
- "@armit/eslint-config-bases": "^0.1.4",
83
- "@flatjs/testing": "2.0.4",
84
- "@swc/core": "1.3.106",
82
+ "@armit/eslint-config-bases": "^0.1.5",
83
+ "@flatjs/testing": "2.1.0-next.0",
84
+ "@swc/core": "1.4.11",
85
85
  "@types/express": "4.17.21",
86
86
  "@types/listr": "0.14.9",
87
- "@types/node": "20.11.6",
88
- "@vitest/coverage-istanbul": "1.2.1",
89
- "@vitest/ui": "1.2.1",
90
- "eslint": "8.56.0",
87
+ "@types/node": "20.12.2",
88
+ "@vitest/coverage-istanbul": "1.4.0",
89
+ "@vitest/ui": "1.4.0",
90
+ "eslint": "8.57.0",
91
91
  "imagemin-gifsicle": "7.0.0",
92
92
  "imagemin-jpegtran": "7.0.0",
93
93
  "imagemin-pngquant": "9.0.2",
94
94
  "imagemin-svgo": "10.0.1",
95
95
  "npm-run-all": "4.1.5",
96
- "prettier": "3.2.4",
96
+ "prettier": "3.2.5",
97
97
  "react": "18.2.0",
98
98
  "rimraf": "5.0.5",
99
- "swc-unplugin-ts": "1.0.2",
100
- "ts-node": "10.9.2",
101
- "vite-tsconfig-paths": "4.3.1",
102
- "vitest": "1.2.1",
99
+ "swc-unplugin-ts": "1.0.3",
100
+ "ts-node": "11.0.0-beta.1",
101
+ "vite-tsconfig-paths": "4.3.2",
102
+ "vitest": "1.4.0",
103
103
  "vue-loader": "17.4.2"
104
104
  },
105
105
  "peerDependencies": {