@flatjs/evolve 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/default-options.js +1 -1
- package/dist/dev-server/create-app-page-route.js +1 -1
- package/dist/dev-server/middlewares/create-page-middleware.js +1 -1
- package/dist/dev-server/middlewares/create-public-assets-middleware.d.ts +1 -1
- package/dist/dev-server/middlewares/create-public-assets-middleware.js +1 -1
- package/dist/main/prepare-serve.js +1 -1
- package/dist/main/prepare-static.js +1 -1
- package/dist/types/types-dev-server.d.ts +4 -0
- package/package.json +28 -28
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"},clientOverlay:{errors:!0,warnings:!1},middlewares:[],watchOptions:{poll:1e3,ignored:["**/node_modules","**/mocks"],aggregateTimeout:500},defaultServeGlobalData:()=>Promise.resolve({})},webpack:{target:["web","es5"],plugins:[],ruleSets:[],publicPath:"auto",resolve:{},externals:{vue:"Vue",react:"React","react-dom":"ReactDOM"},outputDir:"public",enableBundleHashName:!0},pluginOptions:{},loaderOptions:{assetDataUrlMaxSize:4096,babelOptions:{usePreset:"react",plugins:[],presets:[]},runTsChecker:!0,lessOptions:{},postcssOptions:{cssnanoOptions:{}},pixelOptions:{rootValue:{px:100,rpx:1},outputUnit:"rem"},modularImports:[]},entryMap:{},multiHtmlCdn:{},multiHtmlCdnEnvResolver:function cdnResolver(){},needVerifyPackages:{},packageInstallChecker:{enabled:!1,detectModules:["@dimjs/*"],throwError:!1,showAllInstalledGraph:!0},maxProcesses:"50%",ci:{basedBranch:"origin/master"}};
|
1
|
+
export const defaultEvolveOptions={projectCwd:process.cwd(),projectVirtualPath:"flatjs/evolve",rejectWarnings:!1,devServer:{autoOpen:!0,pageProxy:"/pages",mockOptions:{mockBaseDir:"mocks"},clientOverlay:{errors:!0,warnings:!1},middlewares:[],watchOptions:{poll:1e3,ignored:["**/node_modules","**/mocks"],aggregateTimeout:500},defaultServeGlobalData:()=>Promise.resolve({})},webpack:{target:["web","es5"],plugins:[],ruleSets:[],publicPath:"auto",resolve:{},externals:{vue:"Vue",react:"React","react-dom":"ReactDOM"},outputDir:"public",enableBundleHashName:!0},pluginOptions:{},loaderOptions:{assetDataUrlMaxSize:4096,babelOptions:{usePreset:"react",plugins:[],presets:[]},runTsChecker:!0,lessOptions:{},postcssOptions:{cssnanoOptions:{}},pixelOptions:{rootValue:{px:100,rpx:1},outputUnit:"rem"},modularImports:[]},entryMap:{},multiHtmlCdn:{},multiHtmlCdnEnvResolver:function cdnResolver(){},needVerifyPackages:{},packageInstallChecker:{enabled:!1,detectModules:["@dimjs/*"],throwError:!1,showAllInstalledGraph:!0},maxProcesses:"50%",ci:{basedBranch:"origin/master"}};
|
@@ -1 +1 @@
|
|
1
|
-
import{createPageMiddleware,createPublicAssetsMiddleware}from"./middlewares/index.js";export const createAppPageRoute=(e,a,r,t,s)=>{const{devServer:d}=s;a.use(
|
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 +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
|
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=normalizeEvolveEntryName(m,i),p=o[m],d=p.options,u=e[m],f=u?.devServerHostUri||r,g=d?.serveModuleTemplate||"./templates/module.html",h=join(a.projectCwd,"./templates/module.html"),v=readFileSync(isAbsolute(g)?g:existsSync(h)?h:join(n,"./templates/module.html"),"utf-8"),S=a.devServer,j=S?.defaultServeGlobalData?await S.defaultServeGlobalData(p,r):{},y={mode:"development",envCdn:urlJoin(r,["public"])},P=S?.pageProxy||"/pages",b={title:getHtmlPluginConfig("title",y,d?.title),favicon:getHtmlPluginConfig("favicon",y,d?.favicon),viewport:allowPx2remForModule([m,p],a)?getHtmlPluginConfig("viewport",y,d?.viewport):"",headBeforeHtmlTags:getHtmlPluginConfig("headBeforeHtmlTags",y,d?.headBeforeHtmlTags),inlineScripts:getHtmlPluginConfig("inlineScripts",y,d?.inlineScripts),headBeforeStyles:getHtmlPluginConfig("headBeforeStyles",y,d?.headBeforeStyles),headBeforeScripts:getHtmlPluginConfig("headBeforeScripts",y,d?.headBeforeScripts),bodyAfterScripts:getHtmlPluginConfig("bodyAfterScripts",y,d?.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(/^\//,""),...j,...d?.serveGlobalData||{}},styles:[urlJoin(f,[join("public",c,"bundle.css")])],scripts:[urlJoin(f,[join("public",c,"bundle.js")])]};if(e[m]&&shouldEnableReactFastRefresh(!0,[c,p],a)){const e=[devReactFastRefresh.runtime,devReactFastRefresh.reactRefreshSetup];b.headBeforeHtmlTags?b.headBeforeHtmlTags=b.headBeforeHtmlTags.slice(0):b.headBeforeHtmlTags=[],e.forEach((e=>{const t=urlJoin(f,[join("public",join(c,e),"bundle.js")]);b.headBeforeHtmlTags?.push(`<script src="${t}"><\/script>`)}))}return _.template(v)(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,2 +1,2 @@
|
|
1
1
|
import { type RequestHandler } from 'express';
|
2
|
-
export declare const createPublicAssetsMiddleware: (projectCwd: string) => RequestHandler;
|
2
|
+
export declare const createPublicAssetsMiddleware: (projectCwd: string, pageProxy: string) => RequestHandler;
|
@@ -1 +1 @@
|
|
1
|
-
import{extname,join}from"node:path";import{fileWalk}from"@armit/file-utility";export const createPublicAssetsMiddleware=e=>async(
|
1
|
+
import{extname,join}from"node:path";import{fileWalk}from"@armit/file-utility";export const createPublicAssetsMiddleware=(e,i)=>async(t,s)=>{const a=t.baseUrl;if(a.startsWith("/public")){const i=await fileWalk(join("public/","**/*.{js,css}"),{cwd:e}),t=extname(a),l=i.find((e=>extname(e)===t&&-1!==e.indexOf(a.replace(/\.(?:js|css)$/,""))));l?s.sendFile(l):s.sendFile(join(e,a))}else s.redirect(i)};
|
@@ -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
|
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 +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=urlJoin(o,[
|
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)}`)};
|
@@ -22,6 +22,10 @@ export interface WebpackWatchOptions {
|
|
22
22
|
poll?: number | boolean;
|
23
23
|
}
|
24
24
|
export type FlatEvolveDevServerOptions = {
|
25
|
+
/**
|
26
|
+
* @default `/pages`
|
27
|
+
*/
|
28
|
+
pageProxy?: string;
|
25
29
|
/**
|
26
30
|
* Allow us provider customized middlewares for `page`, `modules`
|
27
31
|
*/
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@flatjs/evolve",
|
3
|
-
"version": "2.0.
|
3
|
+
"version": "2.0.1",
|
4
4
|
"license": "MIT",
|
5
5
|
"type": "module",
|
6
6
|
"exports": {
|
@@ -34,19 +34,19 @@
|
|
34
34
|
"typecheck": "tsc --project ./tsconfig.json --noEmit"
|
35
35
|
},
|
36
36
|
"dependencies": {
|
37
|
-
"@armit/config-loader": "^0.0
|
38
|
-
"@armit/file-utility": "^0.0
|
39
|
-
"@armit/git": "^0.0
|
40
|
-
"@armit/package": "^0.0
|
41
|
-
"@armit/worker-threads": "^0.0
|
42
|
-
"@babel/core": "7.23.
|
43
|
-
"@flatjs/common": "2.0.
|
44
|
-
"@flatjs/evolve-preset-babel": "2.0.
|
45
|
-
"@flatjs/forge-postcss-plugin-pixel": "2.0.
|
46
|
-
"@flatjs/graph": "2.0.
|
47
|
-
"@flatjs/mock": "2.0.
|
37
|
+
"@armit/config-loader": "^0.1.0",
|
38
|
+
"@armit/file-utility": "^0.1.0",
|
39
|
+
"@armit/git": "^0.1.0",
|
40
|
+
"@armit/package": "^0.1.0",
|
41
|
+
"@armit/worker-threads": "^0.1.0",
|
42
|
+
"@babel/core": "7.23.5",
|
43
|
+
"@flatjs/common": "2.0.1",
|
44
|
+
"@flatjs/evolve-preset-babel": "2.0.1",
|
45
|
+
"@flatjs/forge-postcss-plugin-pixel": "2.0.1",
|
46
|
+
"@flatjs/graph": "2.0.1",
|
47
|
+
"@flatjs/mock": "2.0.1",
|
48
48
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.11",
|
49
|
-
"@types/babel__core": "7.20.
|
49
|
+
"@types/babel__core": "7.20.5",
|
50
50
|
"babel-loader": "9.1.3",
|
51
51
|
"babel-merge": "3.0.0",
|
52
52
|
"babel-plugin-import": "1.13.8",
|
@@ -55,8 +55,8 @@
|
|
55
55
|
"css-loader": "6.8.1",
|
56
56
|
"cssnano": "6.0.1",
|
57
57
|
"express": "4.18.2",
|
58
|
-
"fork-ts-checker-webpack-plugin": "9.0.
|
59
|
-
"happy-dom": "12.
|
58
|
+
"fork-ts-checker-webpack-plugin": "9.0.2",
|
59
|
+
"happy-dom": "12.10.3",
|
60
60
|
"html-webpack-plugin": "5.5.3",
|
61
61
|
"image-minimizer-webpack-plugin": "3.8.3",
|
62
62
|
"less": "4.2.0",
|
@@ -67,40 +67,40 @@
|
|
67
67
|
"postcss": "8.4.31",
|
68
68
|
"postcss-loader": "7.3.3",
|
69
69
|
"react-refresh": "0.14.0",
|
70
|
-
"svgo": "3.0.
|
70
|
+
"svgo": "3.0.4",
|
71
71
|
"tarjan-graph": "3.0.0",
|
72
72
|
"terser-webpack-plugin": "5.3.9",
|
73
73
|
"tsconfig-paths-webpack-plugin": "4.1.0",
|
74
|
-
"type-fest": "^4.
|
75
|
-
"typescript": "5.
|
74
|
+
"type-fest": "^4.8.2",
|
75
|
+
"typescript": "5.3.2",
|
76
76
|
"webpack": "5.89.0",
|
77
|
-
"webpack-bundle-analyzer": "4.
|
77
|
+
"webpack-bundle-analyzer": "4.10.1",
|
78
78
|
"webpack-dev-server": "4.15.1",
|
79
79
|
"webpack-sources": "3.2.3"
|
80
80
|
},
|
81
81
|
"devDependencies": {
|
82
|
-
"@armit/eslint-config-bases": "^0.0
|
83
|
-
"@flatjs/testing": "2.0.
|
84
|
-
"@swc/core": "1.3.
|
85
|
-
"@types/express": "4.17.
|
86
|
-
"@types/listr": "0.14.
|
87
|
-
"@types/node": "20.
|
82
|
+
"@armit/eslint-config-bases": "^0.1.0",
|
83
|
+
"@flatjs/testing": "2.0.1",
|
84
|
+
"@swc/core": "1.3.100",
|
85
|
+
"@types/express": "4.17.21",
|
86
|
+
"@types/listr": "0.14.9",
|
87
|
+
"@types/node": "20.10.1",
|
88
88
|
"@vitest/coverage-istanbul": "0.34.6",
|
89
89
|
"@vitest/ui": "0.34.6",
|
90
|
-
"eslint": "8.
|
90
|
+
"eslint": "8.54.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.0
|
96
|
+
"prettier": "3.1.0",
|
97
97
|
"react": "18.2.0",
|
98
98
|
"rimraf": "5.0.5",
|
99
99
|
"swc-unplugin-ts": "1.0.2",
|
100
100
|
"ts-node": "10.9.1",
|
101
101
|
"vite-tsconfig-paths": "4.2.1",
|
102
102
|
"vitest": "0.34.6",
|
103
|
-
"vue-loader": "17.3.
|
103
|
+
"vue-loader": "17.3.1"
|
104
104
|
},
|
105
105
|
"peerDependencies": {
|
106
106
|
"imagemin-gifsicle": ">=7.0.0",
|