@moneko/core 3.17.31 → 3.17.32
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/config.d.mts +1 -0
- package/lib/dev/config.mjs +3 -3
- package/lib/dev.mjs +1 -1
- package/package.json +1 -1
- package/typings/global.d.ts +6 -2
package/lib/dev/config.d.mts
CHANGED
package/lib/dev/config.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import e from"chalk";import{getIPv4 as
|
|
2
|
-
`);function v(e){return`http://${"local"===e?r.devServer.host:
|
|
3
|
-
${a(" Network ")} ${
|
|
1
|
+
import e from"chalk";import{getIPv4 as o,getPort as t}from"./net.mjs";import{CONFIG as r}from"../config.mjs";import s from"../utils/log.mjs";let{yellow:n,green:i,grey:l,gray:c,bgBlue:m,bgGreenBright:a,blueBright:p,greenBright:d}=e,$=r.devServer.port||3e3;export const PORT=await t($,r.devServer.host);r.devServer.port=PORT;let f="/"===r.basename?"":r.basename,u=$!==PORT&&c(`Port ${n($)} is in use, trying ${i(PORT)} instead.
|
|
2
|
+
`);function v(e){return`http://${"local"===e?r.devServer.host:o()}:${PORT}${f}`}let T=c("You application is running here:"),O=`${m(" Local ")} ${p(v("local"))}
|
|
3
|
+
${a(" Network ")} ${d(v("net"))}`;export function devLog(e,o){!e&&o&&(process.stdout.write("\x1b[2J\x1b[3J\x1b[H"),s([T,"",O,"",l(`Compiled successfully in ${i(`${o.endTime-o.startTime}ms`)}`)]),u&&s(u))}export const headers={"X-Content-Type-Options":"nosniff","Access-Control-Allow-Origin":"*","Access-Control-Allow-Headers":"*"};
|
package/lib/dev.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"express";import t from"multer";import o from"webpack";import i from"webpack-dev-middleware";import s from"webpack-hot-middleware";import{merge as
|
|
1
|
+
import e from"express";import t from"multer";import o from"webpack";import i from"webpack-dev-middleware";import s from"webpack-hot-middleware";import{merge as r}from"webpack-merge";import l from"./build/server.mjs";import{commonConfig as n}from"./common.mjs";import{CONFIG as m,PUBLICPATH as a}from"./config.mjs";import{PORT as c,devLog as p,headers as u}from"./dev/config.mjs";import f from"./dev/mock.mjs";import d from"./dev/proxy.mjs";import h from"./module.config.mjs";import g,{CUSTOMCONFIG as w}from"./paths.mjs";import{SSR as x,isLibrary as j,isReact as $}from"./process-env.mjs";import k from"./utils/has-pkg.mjs";import{empty as y,resolveProgram as b}from"./utils/index.mjs";import v from"./utils/progress.mjs";import P from"./utils/sigint-exit.mjs";import S from"./options/reslove.mjs";import{watchFile as C}from"fs";import{spawn as _,exec as B}from"child_process";import M from"./utils/log.mjs";import A from"chalk";import{directoryExists as D,loadFileSync as G,removeDir as I}from"@moneko/utils";let{HotModuleReplacementPlugin:L,ProgressPlugin:U,WatchIgnorePlugin:F}=o,H=k("stylelint-webpack-plugin")&&(await import("stylelint-webpack-plugin")).default,O=k("eslint-webpack-plugin")&&(await import("eslint-webpack-plugin")).default,R=$&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,T=["js","jsx","ts","tsx","json","html","vue"],W=T.join(","),q=["css","scss","sass","less","ts","tsx","js","jsx"],E=q.join(","),N=["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],z=k("solid-refresh")||k("react-refresh"),J=`${a.endsWith("/")?"":"/"}__hmr__`,K=new URLSearchParams({name:"client",path:J,dynamicPublicPath:!0,timeout:2e3,reload:!z,quiet:!0,noInfo:!0,overlay:!0}).toString(),Q=n.output.path;x&&(Q=b(`${j?"docs":"dist"}/client`));let V=!!m.bar,X=r(n,{entry:{main:[`${S.hotMiddlewareClient}?${K}`]},output:{path:Q},module:h(!1),plugins:[new L,new F({paths:[/\.d\.ts$/]}),R&&new R,O&&new O({fix:!0,threads:!0,files:[`${m.alias["@"]}/**/*.{${W}}`,j&&`${m.alias["@pkg"]}/**/*.{${W}}`].filter(Boolean),extensions:T,exclude:N,cache:!0,cacheLocation:`${g.lineCachePath}/.eslintcache`,lintDirtyModulesOnly:!0}),H&&new H({fix:!0,threads:!0,files:[`${m.alias["@"]}/**/*.{${E}}`,j&&`${m.alias["@pkg"]}/**/*.{${E}}`].filter(Boolean),extensions:q,exclude:N,cache:!0,cacheLocation:`${g.lineCachePath}/.stylelintcache`,lintDirtyModulesOnly:!0}),new U({handler(e,t,...o){let i=m.bar||{};v({showBar:V,percentage:e,title:i.name||"Build",color:i.color,info:o.length?`[${t}] ${o.join(" ")}`:"",output:X.output?.path})}})].filter(Boolean)}),Y=[X];x&&Y.push(r(n,l));let Z=o(Y);Z.compilers[0].hooks.done.tap("client-log",e=>{p(null,e)});let ee=e(),et=t(),eo=i(Z,{writeToDisk:!1,index:"index.html",headers:u,serverSideRender:x,lastModified:!0}),ei=s(Z,{log:!1,path:J,heartbeat:2e3});if(ee.use(eo),ee.use(ei),ee.use(e.static(X.output.path)),m.proxy&&d(ee,m.proxy),D(g.mockPath)){let e=f(g.mockPath);ee.use(e)}let es=`${X.output.path}/index.html`;ee.all("/*",et.any(),function(e,t,o){if("GET"!==e.method)return o();{let i=e.get("Accept");if(i?.includes("text/html")){let e=eo.context.outputFileSystem,o=e?.readFileSync?.(es);t.end(o)}else if("text/event-stream"===i&&e.url.endsWith(J))return e.url=J,ei(e,t,o);else return o()}});let er=ee.listen(c,()=>{});function el(){process.exit(0)}function en(e,t){let o=G(e);t&&null!==o&&C(e,async function(){let i=G(e);o.trim().replace(/^\s*[\r\n]/gm,"")!==i?.trim().replace(/^\s*[\r\n]/gm,"")?(M(A.yellow(`检测到工程配置${A.blue(`[${t}]`)}变更, 程序即将重启...`)),B("win32"===process.platform?`netstat -ano | findstr :${c}`:`lsof -i :${c}`,(e,t,o)=>{let i=em?t.split(/\s+/).pop():t.split("\n")[1]?.split(/\s+/)[1];i?process.kill(Number(i),"SIGHUP"):M(`未找到占用端口 ${c} 的进程`)})):M(A.gray(`未变更`))})}en(g.configPath,"index"),en(g.customConfigPath,w);let em="win32"===process.platform;process.on("SIGHUP",function(){eo.close(y),er.close(y),er.closeAllConnections(),function(){let e=_(process.argv[0],process.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",el)}()}),process.on("exit",function(){eo.close(y),er.close(y),er.closeAllConnections(),I(g.cachePath)}),P(el);
|
package/package.json
CHANGED
package/typings/global.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ import type {
|
|
|
4
4
|
JsxDomExpressions,
|
|
5
5
|
OptimizationSplitChunksOptions,
|
|
6
6
|
OverrideResolverOption,
|
|
7
|
-
ProxyConfig,
|
|
8
7
|
VirtualModulePluginOption,
|
|
9
8
|
} from '../lib/index';
|
|
9
|
+
import type { Options } from 'http-proxy-middleware';
|
|
10
10
|
import type { DonePluginOption } from '../lib/plugin/done';
|
|
11
11
|
import type { MdxOptions } from '@moneko/mdx';
|
|
12
12
|
import type { Config as SwcConfig, JsMinifyOptions as SwcMinifyOptions } from '@swc/core';
|
|
@@ -20,7 +20,7 @@ import type {
|
|
|
20
20
|
WebpackPluginInstance,
|
|
21
21
|
ModuleOptions,
|
|
22
22
|
FileCacheOptions,
|
|
23
|
-
MemoryCacheOptions
|
|
23
|
+
MemoryCacheOptions,
|
|
24
24
|
} from 'webpack';
|
|
25
25
|
import type { PluginOptions as MiniCssExtractPluginOptions } from 'mini-css-extract-plugin';
|
|
26
26
|
import type { CopyPluginOption } from '../lib/plugin/copy.mjs';
|
|
@@ -29,6 +29,10 @@ export type { TerserMinifyOptions, SwcMinifyOptions, MiniCssExtractPluginOptions
|
|
|
29
29
|
export type MinifierType = 'swc' | 'terser';
|
|
30
30
|
export declare type AppType = 'mobile' | 'site' | 'backstage' | 'micro' | 'library';
|
|
31
31
|
export declare type Framework = 'react' | 'solid';
|
|
32
|
+
export interface ProxyConfig {
|
|
33
|
+
[key: string]: Options;
|
|
34
|
+
}
|
|
35
|
+
|
|
32
36
|
export type HtmlWebpackOption = HtmlWebpackPluginOptions & {
|
|
33
37
|
/**
|
|
34
38
|
* 自定义额外的 tags, 当需要添加远程cdn时很有用
|