@moneko/core 3.55.18 → 3.56.0-bate.0
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/common.mjs +1 -1
- package/lib/dev/server.mjs +1 -1
- package/lib/dev.mjs +2 -2
- package/lib/module.config.mjs +2 -2
- package/lib/plugin/exposes-declararion.mjs +1 -1
- package/lib/plugin/external-remotes.mjs +1 -1
- package/lib/plugin/html-plugin.d.mts +1 -1
- package/lib/plugin/html-plugin.mjs +1 -1
- package/lib/plugin/module-federation.mjs +1 -1
- package/lib/plugin/virtual-module.mjs +1 -1
- package/lib/polyfills/public-path.d.mts +2 -0
- package/lib/polyfills/public-path.mjs +1 -0
- package/lib/vm/modules.mjs +1 -1
- package/lib/worker/dts.mjs +1 -1
- package/package.json +3 -3
- package/typings/typings.d.ts +0 -1
- package/lib/vm/public-path.d.mts +0 -6
- package/lib/vm/public-path.mjs +0 -1
package/lib/common.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extname as e,join as t,resolve as o}from"node:path";import
|
|
1
|
+
import{extname as e,join as t,resolve as o}from"node:path";import s,{config_files as a,CUSTOMCONFIG as n,TMP_DIR as i}from"./commom/paths.mjs";import{OverrideResolverPlugin as r}from"./plugin/override-resolve.mjs";import{isObject as l,node_modules as m,resolveProgram as p}from"./utils/index.mjs";import{exampleModuleName as c}from"./vm/example.mjs";import u from"./vm/info.mjs";import{CONFIG as d}from"./config.mjs";import h from"./plugins.config.mjs";import{isCI as f,isDev as g,isLibrary as b,NODE_ENV as y,packageJson as j}from"./process-env.mjs";export const outputConfig={path:p(b?"docs":"dist"),filename:"js/[name].[contenthash].bundle.js",chunkFilename:"js/[contenthash].chunk.js",assetModuleFilename:t=>{let o=e(t.filename||"").substring(1);return`assets/${o}/[hash][ext]`},library:{name:`${u.projectName}`,type:"umd",umdNamedDefine:!0},globalObject:"self",chunkLoadingGlobal:`webpackJsonp_${j.name}`,pathinfo:g,clean:!g,publicPath:d.publicPath,asyncChunks:!0,charset:!0,iife:!0,crossOriginLoading:"use-credentials",enabledWasmLoadingTypes:["fetch"],uniqueName:`${u.projectName}`};let v={main:[m("@app/entry")]},C=[t(s.corePath,"./polyfills/public-path.mjs")];if(d.polyfill&&C.push(t(s.corePath,"./polyfills/replace-children.mjs")),d.entry&&("string"==typeof d.entry?v={...v,main:[d.entry]}:Object.keys(d.entry)&&(v=Object.assign(v,d.entry))),"string"==typeof v.main?v.main=[...C,v.main]:Array.isArray(v.main)&&(v.main=[...C,...v.main]),d.output){if("string"==typeof d.output)outputConfig.path=d.output;else if(Object.keys(d.output)){let e=d.output,t={...outputConfig.library};Object.assign(outputConfig,e),"object"==typeof d.output&&e.library&&(outputConfig.library=Object.assign(t,e.library))}}let P={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:s.webpackCachePath,memoryCacheUnaffected:!0,name:`.${[n,y].filter(Boolean).join("-")}`,version:`${j.version}`,buildDependencies:{config:a},maxMemoryGenerations:1};!1===d.cache?P=!1:l(d.cache)&&(P=Object.assign(P,d.cache)),f&&(void 0===d.cache||d.cache&&!d.cache.cacheDirectory)&&(P.cacheDirectory=o(i,j.name));export const commonConfig={name:"client",target:"web",devtool:d.devtool,entry:v,mode:g?"development":"production",stats:"errors-only",cache:P,snapshot:{immutablePaths:[s.pnpmNodeModules,s.denoNodeModules,/node_modules\/(?!(@app)\/)/],managedPaths:[s.pnpmNodeModules,s.denoNodeModules,/node_modules\/(?!(@app)\/)/],resolveBuildDependencies:{timestamp:!0,hash:!0},resolve:{timestamp:!0,hash:!0},module:{timestamp:!0,hash:!0},buildDependencies:{timestamp:!0,hash:!0},contextModule:{timestamp:!0,hash:!0}},infrastructureLogging:{level:"error"},externalsPresets:d.externalsPresets,plugins:h,node:{global:!1,__filename:!1,__dirname:!1},experiments:{asyncWebAssembly:!0,cacheUnaffected:!0,lazyCompilation:d.lazyCompilation&&g&&{imports:!0,entries:!0,test:e=>{let t=e.nameForCondition();return!!(t&&(t.startsWith(m(c))||t.startsWith(m("@app/comment"))||t.startsWith(s.pagesPath)||t.startsWith(s.componentsPath)))}},buildHttp:l(d.buildHttp)?{allowedUris:[],lockfileLocation:o(s.httpCachePath,"http.lock"),cacheLocation:o(s.httpCachePath,"data"),upgrade:!0,...d.buildHttp}:d.buildHttp,backCompat:!0,futureDefaults:!0,css:!1,outputModule:!1},resolve:{extensions:[".mts",".mjs",".ts",".tsx",".js",".jsx",".json",".wasm"],alias:d.alias,modules:[s.nodeModules,s.pnpmNodeModules,s.denoNodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:d.resolvePlugins,preferAbsolute:!0,cache:!0,fallback:{}},externals:d.externals,output:outputConfig,recordsPath:d.recordsPath?t(s.programPath,d.recordsPath):t(s.webpackCachePath,"records.json")};d.overrideResolve&&commonConfig.resolve.plugins.push(new r(Object.assign({original:d.alias["@"],override:n&&p(n)},d.overrideResolve)));
|
package/lib/dev/server.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createServer as e}from"node:http";import{createServer as t}from"node:https";import{platform as o}from"node:os";import{extname as r,join as n,sep as i}from"node:path";import{env as s}from"node:process";import{ink as a,println as m}from"@moneko/utils";import{CA_ORGANIZATION as p,isCertificateInstalled as
|
|
1
|
+
import{createServer as e}from"node:http";import{createServer as t}from"node:https";import{platform as o}from"node:os";import{extname as r,join as n,sep as i}from"node:path";import{env as s}from"node:process";import{ink as a,println as m}from"@moneko/utils";import{CA_ORGANIZATION as p,isCertificateInstalled as l}from"../commom/ca.mjs";import c from"../commom/mime.mjs";import d from"../commom/open.mjs";import C from"../commom/paths.mjs";import{CONFIG as f}from"../config.mjs";import h from"../dev/get-cert.mjs";import{setupProxy as u}from"../dev/proxy.mjs";import A,{cacheBody as y}from"./mock.mjs";let E={"Access-Control-Allow-Credentials":"true","Access-Control-Allow-Headers":"Authorization, Content-Type, Accept, X-Requested-With, Origin, DNT, User-Agent, Cache-Control, X-CSRF-Token, X-API-Key, X-Client-Version, X-Device-ID, Content-Language, Accept-Language, X-Custom-Header, X-Mx-ReqToken, Keep-Alive, If-Modified-Since","Access-Control-Allow-Methods":"GET, DELETE, HEAD, OPTIONS, POST, PUT, PATCH, PURGE, LINK, UNLINK, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK, REPORT, SEARCH, CONNECT, TRACE","Access-Control-Allow-Origin":"*","Cache-Control":"no-store, no-cache, must-revalidate, proxy-revalidate",Pragma:"no-cache",Expires:"0"};async function T(T){let g=n(T.root_dir,"index.html"),w=A({directory:C.mockPath});function O(e,t,o){let n=e.headers["accept-encoding"],i=n?.includes("br"),s=`${o}.${i?"br":"gz"}`,a=T.fileSystem.existsSync(s);a&&t.setHeader("Content-Encoding",i?"br":"gzip");let m=T.fileSystem.createReadStream(a?s:o,{autoClose:!0});m.on("open",()=>{t.writeHead(200,Object.assign({},E,T.headers,{"Access-Control-Allow-Origin":e.headers.origin??"*","Content-Type":c[r(o)]||"application/octet-stream"}))}),m.on("error",e=>{switch(m.readable=!0,e.code){case"ENOENT":t.writeHead(301,{Location:"/index.html"}),t.end();break;case"EACCES":t.writeHead(403,{"Content-Type":"text/plain"}),t.end(`Forbidden: ${e.message}`);break;default:t.writeHead(500,{"Content-Type":"text/plain"}),t.end(`Internal Server Error: ${e.message}`)}}),m.pipe(t)}async function x(e,t){if(y(e),!(T.onRequest&&T.onRequest(e,t))){if(!(f.proxy&&await u(e,t,f.proxy)||t.writableEnded||w&&w(e,t))&&!t.writableEnded){if("GET"===e.method){let o="/"===e.url?g:decodeURIComponent(n(T.root_dir,e.url.replace(T.basename??"/","/")));if(T.fileSystem.existsSync(o))return O(e,t,o)}if(e.headers.accept?.includes("text/html"))return O(e,t,g);t.writeHead(404,{"Content-Type":"text/plain"}),t.end("File Not Found")}}}let S=T.https?t(await h(T.host,!0===T.https?{install:!0}:T.https),x):e(x);if(S.listen(T.port),T.https&&!await l(p)&&"darwin"===o()){let e=s.npm_execpath?.split(i).pop()?.split(".").shift()||"npm",t=s.npm_lifecycle_event??"start",o=`> sudo ${e} ${t}`;m(a("⚠️ 未检测到本地 SSL 证书,请通过以下命令重启项目以安装证书: ","yellow")),m(a(o,"yellow")),m("")}return T.open&&d(`${T.https?"https:":"http:"}//${T.host}:${T.port}${"/"===T.basename?"":T.basename}`),S}export default T;
|
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{join as r,relative as
|
|
2
|
-
`):(p(e||0,1,{msg:r,name:t,barColor:
|
|
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 v from"./dev/server.mjs";import b from"./options/reslove.mjs";import{ESLintPlugin as C}from"./plugin/eslint.mjs";import{generateManifest as x}from"./plugin/manifest.mjs";import{StylelintPlugin as _}from"./plugin/stylelint.mjs";import{empty as P}from"./utils/index.mjs";import{commonConfig as S}from"./common.mjs";import{CONFIG as k,getConfig as H}from"./config.mjs";import{outputFileSystem as E}from"./file-system.mjs";import O from"./module.config.mjs";import{isLibrary as T,isReact as B,refresh as I}from"./process-env.mjs";let q=!1,G="/____progress____",L={percentage:0,info:""},N="/__hmr__",R=new URLSearchParams({name:"client",path:N.substring(1),dynamicPublicPath:!0,timeout:2e3,reload:!I,quiet:!0,noInfo:!0,overlay:!1,autoConnect:!0}).toString(),U=h(S,{watchOptions:{stdin:!0,aggregateTimeout:300,ignored:/node_modules\/(?!(@app)\/)/},entry:{main:[`${b.hotMiddlewareClient}?${R}`]},module:O(!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(" ")}`:" ";q||(L.info=r,L.percentage=e,q=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(B){let e=(await import("@pmmmwh/react-refresh-webpack-plugin")).default;U.plugins.push(new e({overlay:!1}))}function F(e){let t=e.join(","),o=[i(d.programPath,`${k.alias["@"]}/**/*.{${t}}`).replace(/\\/g,"/")];return T&&o.push(i(d.programPath,`${k.alias["@pkg"]}/**/*.{${t}}`).replace(/\\/g,"/")),o}k.eslint&&U.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&&U.plugins.push(new _({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.stylelintcache`,files:F(["css","scss","sass","less","ts","tsx","js","jsx"]),...k.stylelint}));let J=c(U);if(!J)throw Error("无法创建编译器");J.outputFileSystem=E;let M=J.watch(J.options.watchOptions,y);if(!M)throw Error("无法创建监视器");J.hooks.done.tap("client-log",e=>{y(null,e)});let A=`${k.basename}/${N}`.replace(/\/+/g,"/"),K=f(J,{log:!1,path:A,heartbeat:2e3}),W=!!k.manifest&&r(k.basename,k.manifest.filename).replaceAll(/\\/g,"/"),z=await v({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){if(!t.writableEnded){if("GET"===e.method){let o=new s(`${k.devServer.https?"https":"http"}://${e.headers.host}${e.url}`);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===G)return t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(L)),!0;if(!q)return t.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),t.end($(G,L)),!0;if(o.pathname===A&&"text/event-stream"===e.headers.accept)return K(e,t,P),!0}return!1}}});function D(){n.exit(0)}z.on("close",()=>{M.close(P),K.close()});let Q=await Promise.all(g.map(H)),V=h(Q[0]||{},Q[1]||{});g.forEach(function(t){o(t,async function(){var o;let[r,i]=await Promise.all(g.map(H)),s=h(r||{},i||{}),p=u(V,s);1===Object.keys(p).length&&"proxy"in p?(m(a(`代理更新中...`,"yellow"),!0),m(a(`代理更新完成...`,"green"),!0),k.proxy=s.proxy,V.proxy=s.proxy,V=s):(V=s,l(a(`检测到工程配置${a(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),o=j,e(X?`netstat -ano | findstr :${o}`:`lsof -i :${o} -t`,(e,t)=>{if(e){l(a(`查找端口 ${o} 时发生错误: ${e.message}`,"red")),l(a("请尝试手动重启程序","yellow"));return}let r=t.trim().replace(/\r\n/g,"\n").split("\n").filter(Boolean),i=X?r[0]?.split(/\s+/).pop()?.trim():r[0]?.trim();if(!i)return void l(a(`未找到占用端口 ${o} 的进程, 请尝试手动重启程序`,"yellow"));try{n.kill(Number(i),"SIGHUP")}catch(e){l(a(`终止进程 ${i} 时发生错误: ${e.message}`,"red"))}}))})});let X="win32"===n.platform;n.on("SIGHUP",function(){z.close(P);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(P)}),w(D);
|
package/lib/module.config.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let e;import{join as
|
|
2
|
-
`)}:void 0},importLoaders:2}},k={loader:
|
|
1
|
+
let e;import{join as o,sep as s}from"node:path";import{saveFileSync as t}from"@moneko/utils";import r,{CUSTOMCONFIG as a}from"./commom/paths.mjs";import n from"./commom/reactive-object.mjs";import i from"./commom/require.mjs";import m from"./commom/rule.mjs";import l from"./options/css-extract.mjs";import c from"./options/modify-vars.mjs";import p from"./options/reslove.mjs";import d from"./options/swcrc.mjs";import{getLightningCssTargets as u}from"./polyfills/targets.mjs";import{node_modules as f,resolveProgram as h,toCamelCase as j}from"./utils/index.mjs";import x from"./utils/svg-to-data-uri.mjs";import{comment as y,getCommentPath as g}from"./vm/docs.mjs";import v from"./vm/generate-doc.mjs";import{outputConfig as w}from"./common.mjs";import{CONFIG as M}from"./config.mjs";import{FRAMEWORK as P,isDev as L,isLibrary as O}from"./process-env.mjs";let _={loader:o(r.corePath,"/loader/lightning-css/loader.cjs"),options:{sourceMap:!!M.sourceMap,targets:u(),rem:!!M.rem,esModule:!0,modules:{auto(e){if(e){if(e.endsWith(".css")&&!e.endsWith("module.css"))return!1;for(let o=0,s=$.length;o<s;o++)if(e.includes($[o]))return m.css_module.test(e)}return m.node_modules_css_module.test(e)},localIdentName:"[hash]_[local]",namedExport:!0,exportLocalsConvention:"dashesOnly",exportOnlyLocals:!1,getJSON:M.cssModuleDefinition?function(e){q.setData(`${e.resourcePath}.d.ts`,`${e.exports.map(({name:e,value:o})=>`export const ${j(e)}: '${o}';`).join("\n")}
|
|
2
|
+
`)}:void 0},importLoaders:2}},k={loader:p.lessLoader,options:{sourceMap:!!M.sourceMap,lessOptions:{modifyVars:c,javascriptEnabled:!0}}},C=new Map;function I(e){if(C.has(e))return C.get(e);try{let o,t=i.resolve(e).split(s),r=t.lastIndexOf("node_modules");return o=-1!==r?t.slice(0,r).join(s):t.join(s),C.set(e,[o]),[o]}catch{try{let o=i.resolve(`${e}${s}package.json`).replace(`${s}package.json`,"");C.set(e,[o])}catch{C.set(e,[f(e),f(`.pnpm/${e}`)])}return C.get(e)}}let $=[...M.cssModules,`@moneko/${P}`,"neko-ui"].map(I).flat(),b=["components","example","mock","site","src","server"].map(h);function S(e){return new Promise(o=>{o([...b,r.corePath,...M.rulesInclude?.[e]?.map(I).flat()||[]])})}a&&b.push(h(a)),M.overrideResolve&&M.overrideResolve.override&&b.push(M.overrideResolve.override);let B=await Promise.all([S("css"),S("js"),S("media"),S("wasm"),S("font")]),J=B[0],N=B[1],W=B[2],E=B[3],R=B[4];p.sassLoader&&(e={loader:p.sassLoader,options:{implementation:await import("sass"),sassOptions:{}}});let D=O&&L&&{test:m.tsdoc,include:M.alias["@pkg"],exclude:[/node_modules\/(?!(@app|@moneko)).+/,m.__tests__],enforce:"pre",loader:o(r.corePath,"/loader/ts-doc.cjs"),options:{comment:y,generateDoc:v,getCommentPath:g}},z=w.library?.type==="umd"&&!1===M.htmlPluginOption,Q=[{resourceQuery:/raw/i,type:"asset/source"},{resourceQuery:/url/i,type:"asset/resource",generator:{filename(e){let o=e.filename;return o&&o.toLocaleLowerCase().endsWith("wasm?url")?"wasm/[hash][ext]":"assets/[hash][ext]"}}},{test:m.wasm,type:"webassembly/async",include:E},{test:m.txt,type:"asset/source"},{test:m.image,type:"asset",dependency:{not:["url"]},parser:{dataUrlCondition:z?()=>!0:{maxSize:4096}},generator:{filename:e=>e.filename?.toLocaleLowerCase().endsWith(".svg")?"assets/svg/[hash][ext]":"assets/images/[hash][ext]",dataUrl:(e,o)=>o.filename.toLocaleLowerCase().endsWith(".svg")?x(e.toString()):e},include:W},{test:m.video,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/video/[hash][ext]"},include:W},{test:m.font,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/fonts/[hash][ext]"},include:R}],U=M.prefixJsLoader.filter(Boolean)||[];"react"===P&&M.reactCompiler&&U.unshift({loader:o(r.corePath,"/loader/react-compiler.cjs"),options:{panicThreshold:L?void 0:"NONE",...M.reactCompiler}}),M.cssInJs&&"object"==typeof M.cssInJs.minify&&U.unshift({loader:o(r.corePath,"/loader/css-in-js-minify.cjs"),options:Object.assign({moduleName:"@moneko/css",allowFuncs:["css","injectGlobal"]},M.cssInJs.minify)});let q=new n({});q.on("change",(e,o)=>{t(e,o)});export default(s=>{let t={react:{loader:p.swcLoader,options:d(s)},solid:{loader:o(r.corePath,"/loader/solid.cjs"),options:{jsxOptions:M.jsxDomExpressions,refresh:M.refresh}}}[P];return{parser:{javascript:{commonjsMagicComments:!0,dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,importMeta:!0,importMetaContext:!0}},noParse:M.noParse,rules:[!1!==M.htmlPluginOption&&D,{oneOf:[...Q,{test:m.js,use:[...U,t].filter(Boolean),include:N,extractSourceMap:!0},{test:m.css,use:[l,_],include:J,extractSourceMap:!0},e&&{test:m.scss,use:[l,_,e],include:J,extractSourceMap:!0},{test:m.less,use:[l,_,k],include:J,extractSourceMap:!0},{test:m.markdown,use:[...U,{loader:o(r.corePath,"/loader/mdx.cjs"),options:M.mdx}].filter(Boolean),exclude:[/node_modules\/(?!(@app|@moneko)).+/],extractSourceMap:!0}].filter(Boolean)},...M.moduleRules].filter(Boolean)}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as e,parse as t,resolve as
|
|
1
|
+
import{join as e,parse as t,resolve as s}from"node:path";import{fileURLToPath as o}from"node:url";import{Worker as i}from"node:worker_threads";import{fileExists as r,loadFile as a}from"@moneko/utils";import n from"webpack";import m from"../utils/create-types.mjs";export class ModuleFederationExposesDeclarationPlugin{constructor(e){this.name="ModuleFederationExposesDeclarationPlugin",this.assetName="module-federation.d.ts",this.dts="",this.option=e,this.worker=new i(o(new URL("../worker/dts.mjs",import.meta.url))),this.worker.setMaxListeners(0),this.worker.postMessage({options:{compilerOptions:{isolatedModules:!1,outFile:this.assetName,verbatimModuleSyntax:!1},include:[...Object.values(e.exposes),"typings/**/*.d.ts"]}}),this.worker.once("message",e=>{this.dts=e,this.worker.terminate()})}apply(o){let{exposes:i}=this.option,p=Object.keys(i).map(e=>{let t=e.replace(/\.tsx?$/i,"");return{key:e,name:t,path:s(`types/${this.option.name}/${t}.d.ts`),originPath:i[e]}});o.hooks.thisCompilation.tap({name:this.name,stage:o.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS},s=>{s.hooks.processAssets.tapPromise(this.name,async()=>{let o=p.map(async s=>{if(r(s.originPath)){let o=t(s.originPath),i=`export * from '${t(o.dir).name}/${o.name}'`;if("public-path"===o.name){let e=await a(s.originPath.replace(/\.mjs$/,".d.mts"));e&&(i=e)}return`${m(e(this.option.name,s.name),i)}`}return""}),i=await Promise.all(o);i.unshift(this.dts),s.emitAsset("module-federation.d.ts",new n.sources.RawSource(i.join("\n")),{javascriptModule:!1})})})}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"webpack";let t=e.sources,r="ExternalRemotesPlugin";export class ExternalRemotesPlugin{apply(e){e.hooks.make.tap(r,e=>{let n=[];e.hooks.buildModule.tap(r,e=>{"ExternalModule"===e.constructor.name&&"script"===e.externalType&&n.push(e)}),e.hooks.afterCodeGeneration.tap(r,function(){n.map(r=>{let n=function(e){let t=e.indexOf("@");if(t<=0||t===e.length-1)throw Error(`Invalid request "${e}"`);return[e.substring(t+1),e.substring(0,t)]}(r.request)[0],o=function(e){let t=[],r=[],n=!1,o=!1;for(let s of e)if("["===s){if(n){o=!0;break}n=!0,r.length&&(t.push(`"${r.join("")}"`),r.length=0)}else if("]"===s){if(!n){o=!0;break}n=!1,r.length&&(t.push(`${r.join("")}`),r.length=0),r.length=0}else r.push(s);if(n||o)throw Error(`Invalid template URL "${e}"`);return r.length&&t.push(`"${r.join("")}"`),t.join(" + ")}(n),s=e.codeGenerationResults
|
|
1
|
+
import e from"webpack";let t=e.sources,r="ExternalRemotesPlugin";export class ExternalRemotesPlugin{apply(e){e.hooks.make.tap(r,e=>{let n=[];e.hooks.buildModule.tap(r,e=>{"ExternalModule"===e.constructor.name&&"script"===e.externalType&&n.push(e)}),e.hooks.afterCodeGeneration.tap(r,function(){n.map(r=>{let n=function(e){let t=e.indexOf("@");if(t<=0||t===e.length-1)throw Error(`Invalid request "${e}"`);return[e.substring(t+1),e.substring(0,t)]}(r.request)[0],o=function(e){let t=[],r=[],n=!1,o=!1;for(let s of e)if("["===s){if(n){o=!0;break}n=!0,r.length&&(t.push(`"${r.join("")}"`),r.length=0)}else if("]"===s){if(!n){o=!0;break}n=!1,r.length&&(t.push(`${r.join("")}`),r.length=0),r.length=0}else r.push(s);if(n||o)throw Error(`Invalid template URL "${e}"`);return r.length&&t.push(`"${r.join("")}"`),t.join(" + ")}(n),s=e.codeGenerationResults?.get(r,void 0).sources,l=s?.get("javascript")?.source();l&&s&&s.set("javascript",new t.RawSource(l.replace(`"${n}"`,o)))})})})}}
|
|
@@ -51,7 +51,7 @@ export declare class HtmlPlugin {
|
|
|
51
51
|
private cachedMetaTags;
|
|
52
52
|
private cachedCustomTags;
|
|
53
53
|
constructor(options?: HtmlPluginOption);
|
|
54
|
-
getPublicPath(compilation: Compilation
|
|
54
|
+
getPublicPath(compilation: Compilation): string;
|
|
55
55
|
apply(compiler: Compiler): void;
|
|
56
56
|
private generateDefaultTemplate;
|
|
57
57
|
private generateMetaTags;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as t,readFileSync as e}from"node:fs";import{basename as s,
|
|
1
|
+
import{existsSync as t,readFileSync as e}from"node:fs";import{basename as s,resolve as i}from"node:path";import n from"webpack";export class HtmlPlugin{constructor(t={}){this.AddEntry=/(?:.*\/)?main\.[a-zA-Z0-9]+\.bundle\.js$/,this.faviconPath="",this.name="HtmlPlugin",this.cachedMetaTags=null,this.cachedCustomTags=null,this.options={title:"WebApp",filename:"index.html",inject:"head",...t}}getPublicPath(t){let e=t.getAssetPath(t.outputOptions.publicPath,{hash:t.hash}),s="auto"===e?"/":e;return s.length&&!s.endsWith("/")&&(s+="/"),s}apply(o){o.hooks.compilation.tap(this.name,a=>{a.hooks.processAssets.tap({name:this.name,stage:n.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL},()=>{let h;if(this.options.favicon){let h=i(o.context,this.options.favicon);if(t(h)){let t=s(this.options.favicon),i=e(h);a.emitAsset(t,new n.sources.RawSource(i),{javascriptModule:!1});let o=this.getPublicPath(a);this.faviconPath=o+t}else a.warnings.push(new n.WebpackError(`Favicon file ${h} does not exist`))}if(h=this.options.templateContent?this.options.templateContent(this.options):this.options.template?e(i(o.context,this.options.template),{encoding:"utf-8"}):this.generateDefaultTemplate(),this.options.inject){let t=this.getAssets(a);h=this.injectAssets(h,t,this.options.inject)}let l="function"==typeof this.options.filename?this.options.filename("index"):this.options.filename||"index.html";a.emitAsset(l,new n.sources.RawSource(h),{javascriptModule:!1})})})}generateDefaultTemplate(){let t=this.generateMetaTags();return`<!DOCTYPE html><html><head><meta charset="utf-8">${t}<title>${this.options.title}</title><link rel="icon" type="image/x-icon" href="${this.faviconPath}"></head><body><div id="root"></div></body></html>`}generateMetaTags(){if(null!==this.cachedMetaTags)return this.cachedMetaTags;if(!this.options.meta)return this.cachedMetaTags="","";let t=Object.entries(this.options.meta).map(([t,e])=>{if("string"==typeof e)return`<meta name="${t}" content="${e}">`;if(void 0===e)return"";let s=Object.entries(e).map(([t,e])=>`${t}="${e}"`).join(" ");return`<meta ${s}>`}).join("");return this.cachedMetaTags=t,t}generateCustomTags(){if(null!==this.cachedCustomTags)return this.cachedCustomTags;let t={head:"",body:""};if(!this.options.tags)return this.cachedCustomTags=t,t;let e=[],s=[];return this.options.tags.forEach(t=>{let{tag:i="script",textContent:n="",inject:o=this.options.inject,...a}=t,h=Object.entries(a).filter(([,t])=>null!=t).map(([t,e])=>!0===e?t:`${t}="${e}"`).join(" "),l=`<${i} ${h}>${n}</${i}>`;"head"===o?e.push(l):s.push(l)}),t.head=e.join(""),t.body=s.join(""),this.cachedCustomTags=t,t}getAssets(t){let e={js:[],css:[]},s=this.getPublicPath(t);for(let i of t.entrypoints.values())for(let t of i.chunks)for(let i of t.files)i.endsWith(".js")?e.js.push(s+i):i.endsWith(".css")&&e.css.push(s+i);return e}injectAssets(t,e,s){let i=e.css.length?e.css.map(t=>`<link href="${t}" rel="stylesheet" />`).join(""):"",n=e.js.length?e.js.map(t=>`<script defer ${this.AddEntry.test(t)?'entry="true" ':""}src="${t}"></script>`).join(""):"",o=this.generateCustomTags(),a=t.split("</head>");if(2===a.length){let[t,e]=a,h=e.split("</body>");return"head"===s?`${t}${i}${n}${o.head}</head>${h[0]}${o.body}</body>${h[1]||""}`:`${t}${o.head}</head>${h[0]}${i}${n}${o.body}</body>${h[1]||""}`}return t}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"webpack";import
|
|
1
|
+
import{join as e,relative as t}from"node:path";import r from"webpack";import o from"../commom/module-resolve.mjs";import s from"../commom/paths.mjs";import{CONFIG as m}from"../config.mjs";import a from"../utils/fetch-module-federation-dts.mjs";import{resolveProgram as l}from"../utils/index.mjs";import{ModuleFederationExposesDeclarationPlugin as i}from"./exposes-declararion.mjs";import{ExternalRemotesPlugin as n}from"./external-remotes.mjs";let p=r.NormalModuleReplacementPlugin,f=r.container.ModuleFederationPlugin,h={},u=[],c=m.moduleFederation?.map(r=>{let m={},n={},p={};if(Array.isArray(r.remotes))for(let e=0,t=r.remotes.length;e<t;e++){let t=r.remotes[e],o=t.alias||t.name,s=t.filename||"remote_entry.js";if(n[o]=`${t.name}@${t.host}/${s}`,Array.isArray(t.library))for(let e=0,r=t.library.length;e<r;e++)h[t.library[e]]=`${o}/${t.library[e]}`;a(t.host,t.name)}if(Array.isArray(r.exposes)){r.exposes.push({name:"public-path",path:`./${t(s.programPath,e(s.corePath,"./polyfills/public-path.mjs"))}`});for(let e=0,t=r.exposes.length;e<t;e++){let t=r.exposes[e];if("string"==typeof t){let e=t.startsWith(".");m[`./${t}`]=o(e?l(t):t),e&&(p[t]=m[`./${t}`])}else if("[object Object]"===Object.prototype.toString.call(t)){let e=t.path.startsWith(".");m[`./${t.name}`]=o(e?l(t.path):t.path),e&&(p[`./${t.name}`]=m[`./${t.name}`])}}r.exposes?.length&&u.push(new i({exposes:p,name:r.name}))}return new f({filename:"remote_entry.js",...r,remotes:n,exposes:m})});c.length>0&&(c.push(new n),c.push(new p(/(.*)/,e=>{h[e.request]&&(e.request=h[e.request])})),u.forEach(e=>c.push(e))),m.env.injectRemoteReactRefresh=Object.keys(h).includes("react-dom");export default c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import t from"webpack-virtual-modules";import o from"../commom/parse-module-meta.mjs";import i from"../commom/paths.mjs";import{isLibrary as e}from"../process-env.mjs";import{node_modules as s,transformModule as r}from"../utils/index.mjs";import{comment as l,docs as m}from"../vm/docs.mjs";import{examples as n}from"../vm/example.mjs";import{locales as p}from"../vm/locales.mjs";import a from"../vm/modules.mjs";import{route as f}from"../vm/routes.mjs";let c={};for(let t in a)if(Object.prototype.hasOwnProperty.call(a,t)){let{file:i,pkg:e,meta:s}=o(t);c[e]=s,c[i]=r(a[t])}export class VirtualModuleWebpackPlugin{constructor(i={}){this.options={},this.init=!1,this.virtualModules=new t(c);let e={};for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)){let{file:s,pkg:l,meta:m}=o(t),n=i[t],p=n;p=s.endsWith("json")?"string"==typeof n?n:JSON.stringify(n):r(n),Object.assign(e,{[s]:p,[l]:m})}this.options=e}modify(t,o,e){let r=e||"",l=o.startsWith(i.nodeModules)?o:s(o),m=t.inputFileSystem;for(;m&&m._inputFileSystem;)m=m._inputFileSystem;let n=m?._virtualFiles?.[l];n&&n.contents===r||(this.virtualModules.writeModule(l,r),t.watching?.invalidate())}apply(t){this.virtualModules.apply(t);let o=(o,i)=>{this.modify(t,o,i)};f.on("change",o),p.on("change",o),e&&(n.on("change",o),m.on("change",o),l.on("change",o)),t.hooks.compilation.tap("VirtualModuleWebpackPlugin",()=>{if(!this.init){for(let t in this.init=!0,this.options)Object.prototype.hasOwnProperty.call(this.options,t)&&o(t,this.options[t]);for(let t of n)o(t[0],t[1]);for(let t of m)o(t[0],t[1]);for(let t of l)o(t[0],t[1])}})}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function set(_){__webpack_public_path__=_}export function get(){return __webpack_public_path__}
|
package/lib/vm/modules.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as
|
|
1
|
+
import{join as p}from"node:path";import{getAppEntry as m,getAppFallback as o,getAppMdxScope as e,getAppMergeRouter as t,getAppNormalizeCss as r,getAppPrefixRouter as s,getAppRem as a,getAppSuspense as i}from"@moneko/mdx";import{updateFileSync as n}from"@moneko/utils";import f from"../commom/has-pkg.mjs";import l from"../commom/paths.mjs";import d from"../commom/rule.mjs";import{CONFIG as c}from"../config.mjs";import j from"../plugin/module-federation.mjs";import{APPTYPE as x,FRAMEWORK as u}from"../process-env.mjs";import g from"../utils/create-types.mjs";import{generateDeclaration as v}from"../utils/dts.mjs";import{node_modules as h,transformModule as k}from"../utils/index.mjs";import y from"./coverage.mjs";import{docs as b,docsModuleName as z}from"./docs.mjs";import D from"./info.mjs";import{locales as C,localesModuleName as P}from"./locales.mjs";import M from"./render-app.mjs";import{route as O,routesModuleName as S}from"./routes.mjs";let q=f(p(c.alias["@"],"./mdx-scope.tsx"))||f(p(c.alias["@"],"./mdx-scope.ts")),w={"@app/env.ts":c.env,"@app/info.ts":D,"@app/render.tsx":"react"===u?M:"","@app/entry.ts":m(p(c.alias["@"],"./index.ts"),!!j.length,!!c.rem,!!c.normalizeCss,x,u),"@app/rem":a(c.rem?.designSize||1680),"@app/fallback":o(c.fallbackCompPath),"@app/coverage":y(l.coveragePath),"@app/merge-router":t(),"@app/prefix-router":s(),"@app/normalize/index.css":r(),"@app/suspense/index.tsx":i(x,u),"@app/mdx-scope.tsx":q?e(q):"export default {}","@app/routes":O.getData(S),"@app/locales":C.getData(P),"@app/docs":b.getData(z)};n(h("@types/@app/index.d.ts"),["@app/env.ts","@app/info.ts","@app/entry.ts","@app/mdx-scope.tsx"].map(p=>g(p.replace(d.js,""),v(k(w[p]),p))).join("\n"));let A=h("@types/@vm/index.d.ts"),B=c.virtualModule||{};n(A,Object.keys(B).map(p=>g(p,v(k(B[p]),p))).join("\n"));export default w;
|
package/lib/worker/dts.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parentPort as s}from"node:worker_threads";import{compileDts as e}from"../utils/compile-dts.mjs";if(!s)throw Error("This file must be run as a worker");s?.setMaxListeners(0),s.on("message",async({options:r})=>{let
|
|
1
|
+
import{parentPort as s}from"node:worker_threads";import{compileDts as e}from"../utils/compile-dts.mjs";if(!s)throw Error("This file must be run as a worker");s?.setMaxListeners(0),s.on("message",async({options:r})=>{try{let t=e(r);s.postMessage(t)}catch{s.postMessage("")}});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.56.0-bate.0",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -124,14 +124,14 @@
|
|
|
124
124
|
"husky": "9.1.7",
|
|
125
125
|
"less": "4.4.1",
|
|
126
126
|
"less-loader": "12.3.0",
|
|
127
|
-
"lightningcss": "1.30.
|
|
127
|
+
"lightningcss": "1.30.2",
|
|
128
128
|
"marked-completed": "1.2.14",
|
|
129
129
|
"memfs": "4.47.0",
|
|
130
130
|
"mini-css-extract-plugin": "2.9.4",
|
|
131
131
|
"style-loader": "4.0.0",
|
|
132
132
|
"swc-loader": "0.2.6",
|
|
133
133
|
"typescript": "5.9.2",
|
|
134
|
-
"webpack": "5.
|
|
134
|
+
"webpack": "5.102.0",
|
|
135
135
|
"webpack-hot-middleware": "2.26.1",
|
|
136
136
|
"webpack-merge": "6.0.1",
|
|
137
137
|
"webpack-virtual-modules": "0.6.2"
|
package/typings/typings.d.ts
CHANGED
package/lib/vm/public-path.d.mts
DELETED
package/lib/vm/public-path.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
let t="@app/public-path",e=`module '${t}' {export function set(value: string): void;export function get(): string;}`;export default{source:"// __webpack_public_path__ = '../';export function set(value: string) {__webpack_public_path__ = value;};export function get() {return __webpack_public_path__;}",moduleName:t,dts:e};
|