@moneko/core 3.47.5 → 3.47.7
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.d.mts +48 -0
- package/lib/dev.mjs +2 -0
- package/package.json +6 -6
package/lib/dev.d.mts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { exec, spawn } from 'node:child_process';
|
|
2
|
+
import { watchFile } from 'node:fs';
|
|
3
|
+
import { join, relative } from 'node:path';
|
|
4
|
+
import process from 'node:process';
|
|
5
|
+
import { URL } from 'node:url';
|
|
6
|
+
import { ink, print, println, progressBar } from '@moneko/utils';
|
|
7
|
+
import webpack, { type Compiler, type OutputFileSystem, type Watching, type WebpackPluginInstance } from 'webpack';
|
|
8
|
+
import hotMiddleware, { type ClientOptions } from 'webpack-hot-middleware';
|
|
9
|
+
import { merge } from 'webpack-merge';
|
|
10
|
+
import { diffObject } from './commom/diff-object.mjs';
|
|
11
|
+
import paths, { config_files } from './commom/paths.mjs';
|
|
12
|
+
import sigintExit from './commom/sigint-exit.mjs';
|
|
13
|
+
import { devLog, PORT } from './dev/config.mjs';
|
|
14
|
+
import generateProgressHtml, { type CompliationProcess } from './dev/generate-progress-html.mjs';
|
|
15
|
+
import server, { type FileSystem, type Server } from './dev/server.mjs';
|
|
16
|
+
import reslove from './options/reslove.mjs';
|
|
17
|
+
import { ESLintPlugin } from './plugin/eslint.mjs';
|
|
18
|
+
import { generateManifest } from './plugin/manifest.mjs';
|
|
19
|
+
import { StylelintPlugin } from './plugin/stylelint.mjs';
|
|
20
|
+
import { empty } from './utils/index.mjs';
|
|
21
|
+
import { commonConfig } from './common.mjs';
|
|
22
|
+
import { CONFIG, getConfig } from './config.mjs';
|
|
23
|
+
import { outputFileSystem } from './file-system.mjs';
|
|
24
|
+
import type { ConfigType } from './index.mjs';
|
|
25
|
+
import moduleConfig from './module.config.mjs';
|
|
26
|
+
import { isLibrary, isReact, refresh } from './process-env.mjs';
|
|
27
|
+
type WebpackPlugin = new(opt?: object) => WebpackPluginInstance;
|
|
28
|
+
declare let isInitialBuildDone: boolean;
|
|
29
|
+
declare const progressApi: string;
|
|
30
|
+
declare const compilationProgress: CompliationProcess;
|
|
31
|
+
declare const hmrPath: string;
|
|
32
|
+
declare const clientParams: ClientOptions;
|
|
33
|
+
declare const hotParams: string;
|
|
34
|
+
declare const clientOption: webpack.Configuration;
|
|
35
|
+
declare function getLintFiles(exts: string[]);
|
|
36
|
+
declare const compiler: Compiler;
|
|
37
|
+
declare const watching: Watching;
|
|
38
|
+
declare const hotUrl: string;
|
|
39
|
+
declare const hot: ReturnType<typeof hotMiddleware>;
|
|
40
|
+
declare const manifestUrl: string | false;
|
|
41
|
+
declare const app: Server;
|
|
42
|
+
declare function exit();
|
|
43
|
+
declare const _prev: ConfigType[];
|
|
44
|
+
declare let prev: ConfigType;
|
|
45
|
+
declare function watchConfig(filepath: string);
|
|
46
|
+
declare function restart();
|
|
47
|
+
declare const isWindow: boolean;
|
|
48
|
+
declare function killPort(port: number);
|
package/lib/dev.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{exec as e,spawn as t}from"node:child_process";import{watchFile as o}from"node:fs";import{join as r,relative as i}from"node:path";import n from"node:process";import{URL as s}from"node:url";import{ink as a,print as m,println as l,progressBar as p}from"@moneko/utils";import c from"webpack";import f from"webpack-hot-middleware";import{merge as h}from"webpack-merge";import{diffObject as u}from"./commom/diff-object.mjs";import d,{config_files as g}from"./commom/paths.mjs";import w from"./commom/sigint-exit.mjs";import{devLog as y,PORT as j}from"./dev/config.mjs";import $ from"./dev/generate-progress-html.mjs";import b from"./dev/server.mjs";import v from"./options/reslove.mjs";import{ESLintPlugin as C}from"./plugin/eslint.mjs";import{generateManifest as x}from"./plugin/manifest.mjs";import{StylelintPlugin as P}from"./plugin/stylelint.mjs";import{empty as _}from"./utils/index.mjs";import{commonConfig as S}from"./common.mjs";import{CONFIG as k,getConfig as H}from"./config.mjs";import{outputFileSystem as O}from"./file-system.mjs";import T from"./module.config.mjs";import{isLibrary as B,isReact as I,refresh as q}from"./process-env.mjs";let G=!1,L="/____progress____",N={percentage:0,info:""},R="/__hmr__",U=new URLSearchParams({name:"client",path:R.substring(1),dynamicPublicPath:!0,timeout:2e3,reload:!q,quiet:!0,noInfo:!0,overlay:!1,autoConnect:!0}).toString(),E=h(S,{watchOptions:{stdin:!0,aggregateTimeout:300,ignored:/node_modules\/(?!(@app)\/)/},entry:{main:[`${v.hotMiddlewareClient}?${U}`]},module:T(!1),plugins:[new c.HotModuleReplacementPlugin,new c.WatchIgnorePlugin({paths:[/node_modules\/(?!(@app)\/)/,/\.d\.ts$/]}),new c.ProgressPlugin({handler(e,t,...o){let r=o.length?`[${t}] ${o.join(" ")}`:" ";G||(N.info=r,N.percentage=e,G=1===e);let i=k.bar;if(i){let t=i.name||"Build";i.quiet?n.stdout.write(`${r}
|
|
2
|
+
`):(p(e||0,1,{msg:r,name:t,barColor:i.barColor,nameColor:i.nameColor,barBgColor:i.barBgColor,msgColor:i.msgColor}),1===e&&n.stdout.write("\r\x1b[2K"))}}})]});if(I){let e=(await import("@pmmmwh/react-refresh-webpack-plugin")).default;E.plugins.push(new e({overlay:!1}))}function F(e){let t=e.join(","),o=[i(d.programPath,`${k.alias["@"]}/**/*.{${t}}`).replace(/\\/g,"/")];return B&&o.push(i(d.programPath,`${k.alias["@pkg"]}/**/*.{${t}}`).replace(/\\/g,"/")),o}k.eslint&&E.plugins.push(new C({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.eslintcache`,cacheStrategy:"metadata",files:F(["js","jsx","ts","tsx","json","html","vue"]),...k.eslint})),k.stylelint&&E.plugins.push(new P({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.stylelintcache`,files:F(["css","scss","sass","less","ts","tsx","js","jsx"]),...k.stylelint}));let J=c(E);J.outputFileSystem=O;let M=J.watch(J.options.watchOptions,y);J.hooks.done.tap("client-log",e=>{y(null,e)});let A=`${k.publicPath}/${R}`.replace(/\/+/g,"/"),K=f(J,{log:!1,path:A,heartbeat:2e3}),W=!!k.manifest&&r("auto"===k.publicPath?"/":k.publicPath,k.manifest.filename).replaceAll(/\\/g,"/"),z=await b({port:j,root_dir:J.options.output.path,fileSystem:J.outputFileSystem,headers:k.devServer.headers,https:k.devServer.https,host:k.devServer.host,open:k.devServer.open,basename:k.basename,onRequest(e,t){let o=new s(`${k.devServer.https?"https":"http"}://${e.headers.host}${e.url}`);if("GET"===e.method){if(W&&o.pathname===W)return t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(x({}))),!0;if(o.pathname===L)return t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(N)),!0;if(!G)return t.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),t.end($(L,N)),!0;if(o.pathname===A&&"text/event-stream"===e.headers.accept)return K(e,t,_),!0}return!1}});function D(){n.exit(0)}z.on("close",()=>{M.close(_),K.close()});let Q=await Promise.all(g.map(H)),V=h(Q[0]||{},Q[1]||{});g.forEach(function(t){o(t,async function(){let[o,r]=await Promise.all(g.map(H)),i=h(o||{},r||{}),s=u(V,i);1===Object.keys(s).length&&"proxy"in s?(m(a(`代理更新中...`,"yellow"),!0),m(a(`代理更新完成...`,"green"),!0),k.proxy=i.proxy,V.proxy=i.proxy,V=i):(V=i,l(a(`检测到工程配置${a(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),e(X?`netstat -ano | findstr :${j}`:`lsof -i :${j} -t`,(e,t)=>{if(e){l(a(`查找端口 ${j} 时发生错误: ${e.message}`,"red")),l(a("请尝试手动重启程序","yellow"));return}let o=t.trim().replace(/\r\n/g,"\n").split("\n").filter(Boolean),r=X?o[0]?.split(/\s+/).pop()?.trim():o[0]?.trim();if(!r){l(a(`未找到占用端口 ${j} 的进程, 请尝试手动重启程序`,"yellow"));return}try{n.kill(Number(r),"SIGHUP")}catch(e){l(a(`终止进程 ${r} 时发生错误: ${e.message}`,"red"))}}))})});let X="win32"===n.platform;n.on("SIGHUP",function(){z.close(_),function(){let e=t(n.argv[0],n.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",D)}()}),n.on("exit",function(){z.close(_)}),w(D);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.47.
|
|
3
|
+
"version": "3.47.7",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -108,17 +108,17 @@
|
|
|
108
108
|
"license": "MIT",
|
|
109
109
|
"dependencies": {
|
|
110
110
|
"@moneko/convert": "1.0.1",
|
|
111
|
-
"@moneko/eslint": "1.6.
|
|
111
|
+
"@moneko/eslint": "1.6.2",
|
|
112
112
|
"@moneko/mdx": "0.1.44",
|
|
113
113
|
"@moneko/raw-import": "0.0.3",
|
|
114
|
-
"@moneko/stylelint": "1.4.
|
|
114
|
+
"@moneko/stylelint": "1.4.1",
|
|
115
115
|
"@moneko/transform-imports": "0.6.1",
|
|
116
116
|
"@moneko/utils": "0.3.3",
|
|
117
117
|
"@swc/core": "1.6.13",
|
|
118
118
|
"browserslist": "4.25.0 ",
|
|
119
119
|
"chokidar": "4.0.3",
|
|
120
|
-
"core-js": "3.
|
|
121
|
-
"core-js-compat": "3.
|
|
120
|
+
"core-js": "3.43.0",
|
|
121
|
+
"core-js-compat": "3.43.0",
|
|
122
122
|
"husky": "9.1.7",
|
|
123
123
|
"less": "4.3.0",
|
|
124
124
|
"less-loader": "12.3.0",
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
"@types/stylis": "4.2.7",
|
|
141
141
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
142
142
|
"@types/webpack-hot-middleware": "2.25.9",
|
|
143
|
-
"sass": "1.89.
|
|
143
|
+
"sass": "1.89.2",
|
|
144
144
|
"sass-loader": "16.0.5",
|
|
145
145
|
"solid-refresh": "0.7.5",
|
|
146
146
|
"stylis": "4.3.6",
|