@flatjs/evolve 1.8.1-next.24 → 1.8.1-next.26
Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# @flatjs/evolve
|
2
2
|
|
3
|
+
## 1.8.1-next.26
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- Updated dependencies [898d48f]
|
8
|
+
- @flatjs/common@1.8.1-next.14
|
9
|
+
- @flatjs/forge-postcss-plugin-pixel@1.8.1-next.14
|
10
|
+
- @flatjs/mock@1.8.1-next.24
|
11
|
+
- @flatjs/evolve-preset-babel@1.8.1-next.6
|
12
|
+
|
13
|
+
## 1.8.1-next.25
|
14
|
+
|
15
|
+
### Patch Changes
|
16
|
+
|
17
|
+
- 52ab6a8: Change defaultServeGlobalData to support promise
|
18
|
+
|
3
19
|
## 1.8.1-next.24
|
4
20
|
|
5
21
|
### Patch Changes
|
package/dist/default-options.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const defaultEvolveOptions={projectCwd:process.cwd(),projectVirtualPath:"flatjs/evolve",rejectWarnings:!1,devServer:{autoOpen:!0,mockOptions:{mockBaseDir:"mocks"},middlewares:[],watchOptions:{poll:1e3,ignored:/node_modules/,aggregateTimeout:500},defaultServeGlobalData:()=>({})},webpack:{target:["web","es5"],plugins:[],ruleSets:[],publicPath:"auto",externals:{vue:"Vue",react:"React","react-dom":"ReactDOM"},enableBundleHashName:!0},loaderOptions:{assetDataUrlMaxSize:4096,babelOptions:{usePreset:"react",plugins:[],presets:[]},runTsChecker:!0,lessOptions:{},cssnanoOptions:{},pixelOptions:{rootValue:{px:100,rpx:1},outputUnit:"rem"},modularImports:[]},entryMap:{},multiHtmlCdn:{},multiHtmlCdnEnvResolver:function cdnResolver(){},needVerifyPackages:{},packageInstallChecker:{enabled:!1,detectModules:["@dimjs/*"],throwError:!1,showAllInstalledGraph:!0}};
|
1
|
+
export const defaultEvolveOptions={projectCwd:process.cwd(),projectVirtualPath:"flatjs/evolve",rejectWarnings:!1,devServer:{autoOpen:!0,mockOptions:{mockBaseDir:"mocks"},middlewares:[],watchOptions:{poll:1e3,ignored:/node_modules/,aggregateTimeout:500},defaultServeGlobalData:()=>Promise.resolve({})},webpack:{target:["web","es5"],plugins:[],ruleSets:[],publicPath:"auto",externals:{vue:"Vue",react:"React","react-dom":"ReactDOM"},enableBundleHashName:!0},loaderOptions:{assetDataUrlMaxSize:4096,babelOptions:{usePreset:"react",plugins:[],presets:[]},runTsChecker:!0,lessOptions:{},cssnanoOptions:{},pixelOptions:{rootValue:{px:100,rpx:1},outputUnit:"rem"},modularImports:[]},entryMap:{},multiHtmlCdn:{},multiHtmlCdnEnvResolver:function cdnResolver(){},needVerifyPackages:{},packageInstallChecker:{enabled:!1,detectModules:["@dimjs/*"],throwError:!1,showAllInstalledGraph:!0}};
|
@@ -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{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";const getPageMainHtml=async(e,t,l)=>{const r=getPackageDir(),o=readFileSync(join(r,"./templates/main.html"),"utf-8"),a=[],i=l.projectVirtualPath.replace(/^\//,"");for(const[r,o]of Object.entries(l.entryMap)){const l=o.options?.servePageMainLinkFn||(e=>e),n=Object.keys(e).includes(r),s=normalizeEvolveEntryName(r,i),m=urlJoin(t,["pages",s],{env:"me"});a.push({name:r.replace(i,"").replace(/^\//,""),link:l(m,{hostUri:t,entryName:r,virtualPath:i}),flagText:n?"serve":"static",isServed:n?1:0})}const n={title:"@flatjs/evolve",modules:a.sort(((e,t)=>t.isServed-e.isServed))};return _.template(o)(n)},getPageModuleHtml=async(e,t,l,r,o)=>{const{entryMap:a,projectVirtualPath:i}=o,n=Object.keys(a).sort(((e,t)=>t.length-e.length)),s=getPackageDir(),m=n.find((e=>{const l=normalizeEvolveEntryName(e,i);return ensureSlash(t.path.replace(/^\//,""),!0).startsWith(ensureSlash(l,!0))}));if(!m){const e=readFileSync(join(s,"./templates/module-404.html"),"utf-8");return _.template(e)({title:"404 Not Found",errorMeta:[{name:"@flatjs/evolve workspace",value:s},{name:"served entry names",value:JSON.stringify(n)},{name:"module path",value:`${t.path}`}]})}const p=normalizeEvolveEntryName(m,i),c=a[m],d=c.options,u=e[m],g=u?.devServerHostUri||l,f=d?.serveModuleTemplate||"./templates/module.html",v=join(o.projectCwd,"./templates/module.html"),h=readFileSync(isAbsolute(f)?f:existsSync(v)?v:join(s,"./templates/module.html"),"utf-8"),S=o.devServer,y=S?.defaultServeGlobalData?S.defaultServeGlobalData(c,l):{},j={title:getHtmlPluginConfig("title","development",d?.title),favicon:getHtmlPluginConfig("favicon","development",d?.favicon),viewport:allowPx2remForModule([m,c],o)?getHtmlPluginConfig("viewport","development",d?.viewport):"",headBeforeHtmlTags:getHtmlPluginConfig("headBeforeHtmlTags","development",d?.headBeforeHtmlTags),inlineScripts:getHtmlPluginConfig("inlineScripts","development",d?.inlineScripts),headBeforeStyles:getHtmlPluginConfig("headBeforeStyles","development",d?.headBeforeStyles),headBeforeScripts:getHtmlPluginConfig("headBeforeScripts","development",d?.headBeforeScripts),bodyAfterScripts:getHtmlPluginConfig("bodyAfterScripts","development",d?.bodyAfterScripts),moduleFederationScripts:injectFederationScripts({me:[urlJoin(l,["public"])]},o.multiHtmlCdnEnvResolver),global:{hostUrl:l,apiBase:urlJoin(l,[r]),virtualPath:join("/pages",i),moduleName:m.replace(i,"").replace(/^\//,""),...y,...d?.serveGlobalData||{}},styles:[urlJoin(g,[join("public",p,"bundle.css")])],scripts:[urlJoin(g,[join("public",p,"bundle.js")])]};return _.template(h)(j)};export const createPageMiddleware=(e,t,l,r)=>(r.devServer?.middlewares||[]).concat((async(o,a)=>{let i;i="/"===o.path?await getPageMainHtml(l,e,r):await getPageModuleHtml(l,o,e,t,r),a.send(i)}));
|
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{injectFederationScripts}from"../../helpers/script-injects.js";const getPageMainHtml=async(e,t,l)=>{const r=getPackageDir(),o=readFileSync(join(r,"./templates/main.html"),"utf-8"),a=[],i=l.projectVirtualPath.replace(/^\//,"");for(const[r,o]of Object.entries(l.entryMap)){const l=o.options?.servePageMainLinkFn||(e=>e),n=Object.keys(e).includes(r),s=normalizeEvolveEntryName(r,i),m=urlJoin(t,["pages",s],{env:"me"});a.push({name:r.replace(i,"").replace(/^\//,""),link:l(m,{hostUri:t,entryName:r,virtualPath:i}),flagText:n?"serve":"static",isServed:n?1:0})}const n={title:"@flatjs/evolve",modules:a.sort(((e,t)=>t.isServed-e.isServed))};return _.template(o)(n)},getPageModuleHtml=async(e,t,l,r,o)=>{const{entryMap:a,projectVirtualPath:i}=o,n=Object.keys(a).sort(((e,t)=>t.length-e.length)),s=getPackageDir(),m=n.find((e=>{const l=normalizeEvolveEntryName(e,i);return ensureSlash(t.path.replace(/^\//,""),!0).startsWith(ensureSlash(l,!0))}));if(!m){const e=readFileSync(join(s,"./templates/module-404.html"),"utf-8");return _.template(e)({title:"404 Not Found",errorMeta:[{name:"@flatjs/evolve workspace",value:s},{name:"served entry names",value:JSON.stringify(n)},{name:"module path",value:`${t.path}`}]})}const p=normalizeEvolveEntryName(m,i),c=a[m],d=c.options,u=e[m],g=u?.devServerHostUri||l,f=d?.serveModuleTemplate||"./templates/module.html",v=join(o.projectCwd,"./templates/module.html"),h=readFileSync(isAbsolute(f)?f:existsSync(v)?v:join(s,"./templates/module.html"),"utf-8"),S=o.devServer,y=S?.defaultServeGlobalData?await S.defaultServeGlobalData(c,l):{},j={title:getHtmlPluginConfig("title","development",d?.title),favicon:getHtmlPluginConfig("favicon","development",d?.favicon),viewport:allowPx2remForModule([m,c],o)?getHtmlPluginConfig("viewport","development",d?.viewport):"",headBeforeHtmlTags:getHtmlPluginConfig("headBeforeHtmlTags","development",d?.headBeforeHtmlTags),inlineScripts:getHtmlPluginConfig("inlineScripts","development",d?.inlineScripts),headBeforeStyles:getHtmlPluginConfig("headBeforeStyles","development",d?.headBeforeStyles),headBeforeScripts:getHtmlPluginConfig("headBeforeScripts","development",d?.headBeforeScripts),bodyAfterScripts:getHtmlPluginConfig("bodyAfterScripts","development",d?.bodyAfterScripts),moduleFederationScripts:injectFederationScripts({me:[urlJoin(l,["public"])]},o.multiHtmlCdnEnvResolver),global:{hostUrl:l,apiBase:urlJoin(l,[r]),virtualPath:join("/pages",i),moduleName:m.replace(i,"").replace(/^\//,""),...y,...d?.serveGlobalData||{}},styles:[urlJoin(g,[join("public",p,"bundle.css")])],scripts:[urlJoin(g,[join("public",p,"bundle.js")])]};return _.template(h)(j)};export const createPageMiddleware=(e,t,l,r)=>(r.devServer?.middlewares||[]).concat((async(o,a)=>{let i;i="/"===o.path?await getPageMainHtml(l,e,r):await getPageModuleHtml(l,o,e,t,r),a.send(i)}));
|
@@ -34,7 +34,7 @@ export type FlatEvolveDevServerOptions = {
|
|
34
34
|
/**
|
35
35
|
* Allow us costomized global serve data injected into `window.GLOBAL = {...globalData}`
|
36
36
|
*/
|
37
|
-
defaultServeGlobalData?: (entryItem: EvolveEntryMapContent, hostUrl: string) => Record<string, unknown
|
37
|
+
defaultServeGlobalData?: (entryItem: EvolveEntryMapContent, hostUrl: string) => Promise<Record<string, unknown>>;
|
38
38
|
/**
|
39
39
|
* The value indicates if we will auto open broswers page for `serve`
|
40
40
|
* @default true
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@flatjs/evolve",
|
3
|
-
"version": "1.8.1-next.
|
3
|
+
"version": "1.8.1-next.26",
|
4
4
|
"license": "MIT",
|
5
5
|
"type": "module",
|
6
6
|
"exports": {
|
@@ -40,10 +40,10 @@
|
|
40
40
|
"@armit/file-utility": "^0.0.19",
|
41
41
|
"@armit/package": "^0.0.29",
|
42
42
|
"@babel/core": "7.21.8",
|
43
|
-
"@flatjs/common": "1.8.1-next.
|
43
|
+
"@flatjs/common": "1.8.1-next.14",
|
44
44
|
"@flatjs/evolve-preset-babel": "1.8.1-next.6",
|
45
|
-
"@flatjs/forge-postcss-plugin-pixel": "1.8.1-next.
|
46
|
-
"@flatjs/mock": "1.8.1-next.
|
45
|
+
"@flatjs/forge-postcss-plugin-pixel": "1.8.1-next.14",
|
46
|
+
"@flatjs/mock": "1.8.1-next.24",
|
47
47
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
|
48
48
|
"@types/babel__core": "7.20.0",
|
49
49
|
"babel-loader": "9.1.2",
|
@@ -75,7 +75,7 @@
|
|
75
75
|
},
|
76
76
|
"devDependencies": {
|
77
77
|
"@armit/eslint-config-bases": "^0.0.16",
|
78
|
-
"@flatjs/testing": "1.8.1-next.
|
78
|
+
"@flatjs/testing": "1.8.1-next.11",
|
79
79
|
"@swc/core": "1.3.59",
|
80
80
|
"@types/express": "4.17.17",
|
81
81
|
"@types/node": "20.2.3",
|