@moneko/core 3.42.2-beta.2 → 3.42.2-beta.3
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/build.d.mts +1 -1
- package/lib/build.mjs +2 -2
- package/lib/commom/sigint-exit.d.mts +1 -1
- package/lib/commom/sigint-exit.mjs +1 -1
- package/lib/dev.mjs +2 -2
- package/package.json +1 -1
package/lib/build.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { relative } from 'node:path';
|
|
2
|
-
import
|
|
2
|
+
import process from 'node:process';
|
|
3
3
|
import { analyzeBundleSize, completedInfo, ink, println, progressBar } from '@moneko/utils';
|
|
4
4
|
import webpack, { type Compiler, type Configuration, type Stats } from 'webpack';
|
|
5
5
|
import { merge } from 'webpack-merge';
|
package/lib/build.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{relative as o}from"node:path";import
|
|
2
|
-
`):(
|
|
1
|
+
import{relative as o}from"node:path";import r from"node:process";import{analyzeBundleSize as m,completedInfo as t,ink as i,println as e,progressBar as n}from"@moneko/utils";import s from"webpack";import{merge as a}from"webpack-merge";import p from"./build/common.mjs";import l from"./commom/paths.mjs";import u from"./plugin/done.mjs";import{empty as g}from"./utils/index.mjs";import c from"./utils/seo.mjs";import{CONFIG as f}from"./config.mjs";import d from"./module.config.mjs";let h=a(p,{module:d(!1),plugins:[]});if(f.done&&h.plugins.push(new u({done:f.done})),f.bar){let o=f.bar,m=o.name||"Build";h.plugins.push(new s.ProgressPlugin({handler(t,i,...e){let s=e.length?`[${i}] ${e.join(" ")}`:" ";o.quiet?r.stdout.write(`${s}
|
|
2
|
+
`):(n(t||0,1,{msg:s,name:m,barColor:o.barColor,nameColor:o.nameColor,barBgColor:o.barBgColor,msgColor:o.msgColor}),1===t&&r.stdout.write("\r\x1b[2K"))}}))}let w=s(h);async function b(){let r=await new Promise((o,r)=>{w.run((m,t)=>{m&&r(m),t?o(t):r(Error("编译过程中没有生成统计信息"))})});(r.hasErrors()||r.hasWarnings())&&function(o){let{warnings:r,errors:m}=o.compilation;r.forEach(o=>{e(i(o.message,"178"))}),m.forEach(o=>{e(i(o.message,"red"))})}(r),await new Promise(n=>{r.compilation.compiler.cache.shutdown(s=>{s&&e(i(s.toString(),"red")),m(r.compilation.outputOptions.path,["\\.js$"]),t(~~((r.endTime-r.startTime)/10)/100,o(l.programPath,r.compilation.outputOptions.path)),n()})}),f.seo&&c()}r.on("exit",g),await b();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import o from"node:process";export default function(n){o.on("SIGINT",n),o.on("SIGTERM",n),o.on("SIGQUIT",n)}
|
package/lib/dev.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{exec as e,spawn as t}from"node:child_process";import{watchFile as o}from"node:fs";import{relative as r}from"node:path";import i from"node:process";import{ink as n,print as s,println as l,progressBar as m}from"@moneko/utils";import a from"webpack";import p from"webpack-hot-middleware";import{merge as c}from"webpack-merge";import{diffObject as f}from"./commom/diff-object.mjs";import
|
|
2
|
-
`):(m(o||0,1,{msg:s,name:t,barColor:e.barColor,nameColor:e.nameColor,barBgColor:e.barBgColor,msgColor:e.msgColor}),1===o&&i.stdout.write("\r\x1b[2K"))}}))}let M=a(q);M.outputFileSystem=S;let N=M.watch(M.options.watchOptions,g);M.hooks.done.tap("client-log",e=>{g(null,e)});let W={};
|
|
1
|
+
import{exec as e,spawn as t}from"node:child_process";import{watchFile as o}from"node:fs";import{relative as r}from"node:path";import i from"node:process";import{ink as n,print as s,println as l,progressBar as m}from"@moneko/utils";import a from"webpack";import p from"webpack-hot-middleware";import{merge as c}from"webpack-merge";import{diffObject as f}from"./commom/diff-object.mjs";import h,{config_files as u}from"./commom/paths.mjs";import d from"./commom/sigint-exit.mjs";import{devLog as g,PORT as w}from"./dev/config.mjs";import y from"./dev/generate-progress-html.mjs";import j from"./dev/get-cert.mjs";import $ from"./options/reslove.mjs";import b from"./plugin/eslint.mjs";import x from"./plugin/stylelint.mjs";import{empty as v}from"./utils/index.mjs";import{commonConfig as C}from"./common.mjs";import{CONFIG as _,getConfig as P,PUBLICPATH as k}from"./config.mjs";import{outputFileSystem as S}from"./file-system.mjs";import H from"./http-server.mjs";import B from"./module.config.mjs";import{isLibrary as I,isReact as L,refresh as O}from"./process-env.mjs";let R=`${k.endsWith("/")?"":"/"}__hmr__`,U=new URLSearchParams({name:"client",path:R,dynamicPublicPath:!0,timeout:2e3,reload:!O,quiet:!0,noInfo:!0,overlay:!1,autoConnect:!0}).toString(),q=c(C,{watchOptions:{stdin:!0,ignored:/node_modules\/(?!(@app|@moneko)).+/},entry:{main:[`${$.hotMiddlewareClient}?${U}`]},module:B(!1),plugins:[new a.HotModuleReplacementPlugin,new a.WatchIgnorePlugin({paths:[/node_modules\/(?!(@app|@moneko)).+/,/\.d\.ts$/]})]});if(q.plugins||(q.plugins=[]),L){let e=(await import("@pmmmwh/react-refresh-webpack-plugin")).default;q.plugins.push(new e({overlay:!1}))}function E(e){let t=e.join(","),o=[r(h.programPath,`${_.alias["@"]}/**/*.{${t}}`).replace(/\\/g,"/")];return I&&o.push(r(h.programPath,`${_.alias["@pkg"]}/**/*.{${t}}`).replace(/\\/g,"/")),o}_.eslint&&q.plugins.push(new b({fix:!0,cache:!0,cacheLocation:`${h.lintCachePath}/.eslintcache`,cacheStrategy:"metadata",files:E(["js","jsx","ts","tsx","json","html","vue"]),..._.eslint})),_.stylelint&&q.plugins.push(new x({fix:!0,cache:!0,cacheLocation:`${h.lintCachePath}/.stylelintcache`,files:E(["css","scss","sass","less","ts","tsx","js","jsx"]),..._.stylelint}));let G=!1,T="/____progress____",F={percentage:0,info:""};if(_.bar){let e=_.bar,t=e.name||"Build";q.plugins.push(new a.ProgressPlugin({handler(o,r,...n){let s=n.length?`[${r}] ${n.join(" ")}`:" ";G||(F.info=s,F.percentage=o,G=1===o),e.quiet?i.stdout.write(`${s}
|
|
2
|
+
`):(m(o||0,1,{msg:s,name:t,barColor:e.barColor,nameColor:e.nameColor,barBgColor:e.barBgColor,msgColor:e.msgColor}),1===o&&i.stdout.write("\r\x1b[2K"))}}))}let M=a(q);M.outputFileSystem=S;let N=M.watch(M.options.watchOptions,g);M.hooks.done.tap("client-log",e=>{g(null,e)});let W={};_.devServer.https&&(W.http2=!0,W.https=await j());let J=p(M,{log:!1,path:R,heartbeat:2e3}),K=await H({port:w,root_dir:M.options.output.path,fileSystem:M.outputFileSystem,onRequest(e,t){let o=new URL(`${_.devServer.https?"https":"http"}://localhost:${w}${e.url}`);if("GET"===e.method){if(o.pathname===T){t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(F));return}if(!G){t.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),t.end(y(T,F));return}if(o.pathname===`/${R}`.replace("//","/")&&"text/event-stream"===e.headers.accept){e.url=R,J(e,t,()=>{if(t.writableEnded)return});return}}}});function z(){i.exit(0)}K.on("close",()=>{N.close(v)});let A=await Promise.all(u.map(P)),D=c(A[0]||{},A[1]||{});u.forEach(function(t){o(t,async function(){let[o,r]=await Promise.all(u.map(P)),m=c(o||{},r||{}),a=f(D,m);1===Object.keys(a).length&&"proxy"in a?(s(n(`代理更新中...`,"yellow"),!0),s(n(`代理更新完成...`,"green"),!0),_.proxy=m.proxy,D.proxy=m.proxy,D=m):(D=m,l(n(`检测到工程配置${n(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),e(Q?`netstat -ano | findstr :${w}`:`lsof -i :${w} -t`,(e,t)=>{if(e){l(n(`查找端口 ${w} 时发生错误: ${e.message}`,"red")),l(n("请尝试手动重启程序","yellow"));return}let o=t.trim().replace(/\r\n/g,"\n").split("\n").filter(Boolean),r=Q?o[0]?.split(/\s+/).pop()?.trim():o[0]?.trim();if(!r){l(n(`未找到占用端口 ${w} 的进程, 请尝试手动重启程序`,"yellow"));return}try{i.kill(Number(r),"SIGHUP")}catch(e){l(n(`终止进程 ${r} 时发生错误: ${e.message}`,"red"))}}))})});let Q="win32"===i.platform;i.on("SIGHUP",function(){K.close(v),function(){let e=t(i.argv[0],i.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",z)}()}),i.on("exit",function(){K.close(v)}),d(z);
|