@moneko/core 3.34.0 → 3.34.1
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/lib/dev.mjs +1 -1
- package/lib/options/split-chunk.mjs +1 -1
- package/package.json +1 -1
package/lib/dev.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{exec as e,spawn as t}from"node:child_process";import{watchFile as o}from"node:fs";import{extname as r,relative as s,sep as n}from"node:path";import{ink as i,loadFile as l,print as a,println as m,progressBar as
|
|
1
|
+
import{exec as e,spawn as t}from"node:child_process";import{watchFile as o}from"node:fs";import{extname as r,relative as s,sep as n}from"node:path";import{ink as i,loadFile as l,print as a,println as m,progressBar as c}from"@moneko/utils";import p from"fastify";import d from"webpack";import u from"webpack-hot-middleware";import{merge as h}from"webpack-merge";import{diffObject as f}from"./commom/diff-object.mjs";import g from"./commom/mime.mjs";import y,{config_files as w}from"./commom/paths.mjs";import $ from"./commom/sigint-exit.mjs";import{devLog as x,PORT as C}from"./dev/config.mjs";import v from"./dev/mock.mjs";import{setupProxy as j}from"./dev/proxy.mjs";import P from"./options/reslove.mjs";import k from"./plugin/eslint.mjs";import S from"./plugin/stylelint.mjs";import{empty as b}from"./utils/index.mjs";import{commonConfig as A}from"./common.mjs";import{CONFIG as O,getConfig as T,PUBLICPATH as H}from"./config.mjs";import{outputFileSystem as _}from"./file-system.mjs";import E from"./module.config.mjs";import{isLibrary as I,isReact as R,refresh as z}from"./process-env.mjs";let M=`${H.endsWith("/")?"":"/"}__hmr__`,U=new URLSearchParams({name:"client",path:M,dynamicPublicPath:!0,timeout:2e3,reload:!z,quiet:!0,noInfo:!0,overlay:!1,autoConnect:!0}).toString(),F=A.output.path,q=h(A,{watchOptions:{ignored:/node_modules\/(?!(@app|@moneko)).+/},entry:{main:[`${P.hotMiddlewareClient}?${U}`]},output:{path:F},module:E(!1),optimization:{splitChunk:{cacheGroups:{"monaco-editor":{test:/[\\/]node_modules[\\/]monaco-editor/,name:"monaco-editor",chunks:"all"}}}},plugins:[new d.HotModuleReplacementPlugin,new d.WatchIgnorePlugin({paths:[/node_modules\/(?!(@app|@moneko)).+/,/\.d\.ts$/]})]});if(q.plugins||(q.plugins=[]),R){let e=(await import("@pmmmwh/react-refresh-webpack-plugin")).default;q.plugins.push(new e({overlay:!1}))}function B(e){let t=e.join(","),o=[s(y.programPath,`${O.alias["@"]}/**/*.{${t}}`).replace(/\\/g,"/")];return I&&o.push(s(y.programPath,`${O.alias["@pkg"]}/**/*.{${t}}`).replace(/\\/g,"/")),o}if(O.eslint&&q.plugins.push(new k({fix:!0,cache:!0,cacheLocation:`${y.lintCachePath}/.eslintcache`,cacheStrategy:"metadata",lintDirtyModulesOnly:!0,...O.eslint,files:B(["js","jsx","ts","tsx","json","html","vue"])})),O.stylelint&&q.plugins.push(new S({fix:!0,cache:!0,cacheLocation:`${y.lintCachePath}/.stylelintcache`,...O.stylelint,files:B(["css","scss","sass","less","ts","tsx","js","jsx"])})),O.bar){let e=O.bar,t=e.name||"Build";q.plugins.push(new d.ProgressPlugin({handler(o,r,...s){c(o||0,1,{msg:s.length?`[${r}] ${s.join(" ")}`:"",name:t,barColor:e.barColor,nameColor:e.nameColor,barBgColor:e.barBgColor,msgColor:e.msgColor}),1===o&&process.stdout.write("\r\x1b[2K")}}))}let G=d(q);G.outputFileSystem=_;let L=G.watch(G.options.watchOptions,x);G.hooks.done.tap("client-log",e=>{x(null,e)});let N={};if(O.devServer.https){let[e,t]=await Promise.all([l(O.devServer.https.key),l(O.devServer.https.cert)]);e||(m(i(`法加载私钥。请检查路径和文件是否存在,并确保路径正确:${O.devServer.https.key}`,"red")),process.exit(1)),t||(m(i(`无法加载证书。请检查路径和文件是否存在,并确保路径正确:${O.devServer.https.cert}`,"red")),process.exit(1)),N.http2=!0,N.https={key:e,cert:t}}let D=u(G,{log:!1,path:M,heartbeat:2e3}),W=p({logger:!1,...N});v(W,{directory:y.mockPath}),j(W,O.proxy);let K={"Access-Control-Allow-Credentials":"true","Access-Control-Allow-Headers":"DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization","Access-Control-Allow-Methods":"GET, POST, OPTIONS, DELETE, PATCH, PUT","Access-Control-Allow-Origin":"*","Cache-Control":"no-store, no-cache, must-revalidate, proxy-revalidate",Pragma:"no-cache",Expires:"0",...O.devServer.headers||{}};function X(e,t,o){t.headers(K),e.headers.origin&&t.header("Access-Control-Allow-Origin",e.headers.origin);let s=G.outputFileSystem,n=e.headers["accept-encoding"],i=n?.includes("gzip"),l=s.existsSync?.(`${o}.gz`);i&&l&&t.header("content-encoding","gzip");let a=s.createReadStream?.(i&&l?`${o}.gz`:o,{autoClose:!0});a?.on("error",e=>{if(a.destroy(),!t.sent)return t.code(404).type("text/html").send(`File not found: ${e.message}`)});let m=g[r(o)];return m&&t.header("content-type",m),t.send(a)}function J(){process.exit(0)}W.get(`/${M}`.replace("//","/"),async(e,t)=>{if("text/event-stream"===e.headers.accept){e.raw.url=M,D(e.raw,t.raw,()=>{t.raw.writableEnded&&(t.sent=!0)});return}}),W.addHook("onRequest",(e,t,o)=>{let r=decodeURIComponent(`${q.output.path}${n}${"/"===e.url?"index.html":e.url}`);return G.outputFileSystem?.existsSync?.(r)?X(e,t,r):o()}),W.setNotFoundHandler((e,t)=>X(e,t,`${q.output.path}${n}index.html`)),W.addHook("onClose",()=>{L.close(b),W.server.close(b)}),W.listen({port:C});let Q=await Promise.all(w.map(T)),V=h(Q[0]||{},Q[1]||{});w.forEach(function(t){o(t,async function(){let[o,r]=await Promise.all(w.map(T)),s=h(o||{},r||{}),n=f(V,s);1===Object.keys(n).length&&"proxy"in n?(a(i(`代理更新中...`,"yellow"),!0),await j(W,s.proxy),a(i(`代理更新完成...`,"green"),!0),O.proxy=s.proxy,V.proxy=s.proxy,V=s):(V=s,m(i(`检测到工程配置${i(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),e(Y?`netstat -ano | findstr :${C}`:`lsof -i :${C} -t`,(e,t)=>{if(e){m(i(`查找端口 ${C} 时发生错误: ${e.message}`,"red")),m(i("请尝试手动重启程序","yellow"));return}let o=t.trim().replace(/\r\n/g,"\n").split("\n").filter(Boolean),r=Y?o[0]?.split(/\s+/).pop()?.trim():o[0]?.trim();if(!r){m(i(`未找到占用端口 ${C} 的进程, 请尝试手动重启程序`,"yellow"));return}try{process.kill(Number(r),"SIGHUP")}catch(e){m(i(`终止进程 ${r} 时发生错误: ${e.message}`,"red"))}}))})});let Y="win32"===process.platform;process.on("SIGHUP",function(){W.close(b),function(){let e=t(process.argv[0],process.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",J)}()}),process.on("exit",function(){W.close(b)}),$(J);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
let e=function(){let e={priority:-10,reuseExistingChunk:!0};return function(
|
|
1
|
+
let e=function(){let e={priority:-10,reuseExistingChunk:!0};return function(n){return{...e,test:n}}}(),n={chunks:"all",minChunks:1,minSize:2e4,maxSize:25e4,enforceSizeThreshold:5e4,maxAsyncRequests:30,maxInitialRequests:30,minRemainingSize:0,hidePathInfo:!0,cacheGroups:{CHANGELOG:e(/CHANGELOG\.md/),site:e(/site/),vendors:{test:/[\\/]node_modules[\\/]/,priority:-10,reuseExistingChunk:!0},"monaco-editor":{test:/[\\/]node_modules[\\/]monaco-editor/,name:"monaco-editor",chunks:"all"},common:{minChunks:2,priority:-20,reuseExistingChunk:!0}}};export default n;
|