@moneko/core 3.44.5 → 3.44.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/build/common.mjs +1 -1
- package/lib/common.mjs +1 -1
- package/lib/config.mjs +1 -1
- package/lib/dev.mjs +2 -2
- package/lib/loader/lightning-css/utils.cjs +1 -1
- package/lib/plugin/compression.mjs +1 -1
- package/lib/plugin/lightningcss-plugin.mjs +1 -1
- package/lib/plugin/swc-minify-plugin.d.mts +2 -1
- package/lib/plugin/swc-minify-plugin.mjs +1 -1
- package/lib/plugins.config.d.mts +11 -0
- package/lib/plugins.config.mjs +1 -0
- package/lib/worker/react-compiler.mjs +1 -1
- package/package.json +1 -1
- package/typings/global.d.ts +1 -1
package/lib/build/common.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"mini-css-extract-plugin";import i from"webpack";import{merge as n}from"webpack-merge";import{commonConfig as t}from"../common.mjs";import{CONFIG as r}from"../config.mjs";import{LightningCssMinifyPlugin as m}from"../plugin/lightningcss-plugin.mjs";import s from"../plugin/swc-minify-plugin.mjs";import{getLightningCssTargets as l}from"../polyfills/targets.mjs";let o=[];r.minifier&&(o.push(new s(r.minifier)),o.push(new m({targets:l()})));let p={maxAssetSize:256e3,maxEntrypointSize:256e3,assetFilter:e=>!e.endsWith(".map")&&!e.endsWith("ce28377f3a428346.js"),...r.performance},a=n(t,{performance:r.performance&&p,plugins:[new e({filename:"style/[contenthash].css",chunkFilename:"style/[contenthash].css",ignoreOrder:!0})],optimization:{splitChunks:r.splitChunk,runtimeChunk:r.runtimeChunk,chunkIds:"deterministic",moduleIds:"deterministic",concatenateModules:!0,emitOnErrors:!1,removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,minimize:!0,minimizer:o,sideEffects:!0,providedExports:!0}});if(r.splitChunk&&a.plugins?.push(new i.optimize.MinChunkSizePlugin({minChunkSize:r.minChunkSize||1e3})),r.bundleAnalyzer){let e=(await import("webpack-bundle-analyzer")).BundleAnalyzerPlugin;a.plugins?.push(new e({analyzerMode:"static",reportFilename:"report.html",openAnalyzer:!1,defaultSizes:"gzip",logLevel:"silent",...r.bundleAnalyzer}))}export default a;
|
|
1
|
+
import e from"mini-css-extract-plugin";import i from"webpack";import{merge as n}from"webpack-merge";import{commonConfig as t}from"../common.mjs";import{CONFIG as r}from"../config.mjs";import{LightningCssMinifyPlugin as m}from"../plugin/lightningcss-plugin.mjs";import s from"../plugin/swc-minify-plugin.mjs";import{getLightningCssTargets as l}from"../polyfills/targets.mjs";let o=[];r.minifier&&(o.push(new s(r.minifier)),o.push(new m({targets:l()})));let p={maxAssetSize:256e3,maxEntrypointSize:256e3,assetFilter:e=>!e.endsWith(".map")&&!e.endsWith("ce28377f3a428346.js"),...r.performance},a=n(t,{performance:r.performance&&p,plugins:[new e({filename:"style/[contenthash].css",chunkFilename:"style/[contenthash].css",ignoreOrder:!0})],optimization:{splitChunks:r.splitChunk,runtimeChunk:r.runtimeChunk,chunkIds:"deterministic",moduleIds:"deterministic",concatenateModules:!0,emitOnErrors:!1,removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,minimize:!0,minimizer:o,sideEffects:!0,providedExports:!0,flagIncludedChunks:!0,innerGraph:!1,mangleExports:"deterministic",portableRecords:!0,realContentHash:!1}});if(r.splitChunk&&a.plugins?.push(new i.optimize.MinChunkSizePlugin({minChunkSize:r.minChunkSize||1e3})),r.bundleAnalyzer){let e=(await import("webpack-bundle-analyzer")).BundleAnalyzerPlugin;a.plugins?.push(new e({analyzerMode:"static",reportFilename:"report.html",openAnalyzer:!1,defaultSizes:"gzip",logLevel:"silent",...r.bundleAnalyzer}))}export default a;
|
package/lib/common.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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 r from"./commom/require.mjs";import l from"./plugin/override-resolve.mjs";import{isObject as m,node_modules as c,resolveProgram as p}from"./utils/index.mjs";import{exampleModuleName as u}from"./vm/example.mjs";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 r from"./commom/require.mjs";import l from"./plugin/override-resolve.mjs";import{isObject as m,node_modules as c,resolveProgram as p}from"./utils/index.mjs";import{exampleModuleName as u}from"./vm/example.mjs";import d from"./vm/info.mjs";import{CONFIG as h,PUBLICPATH as f}from"./config.mjs";import g from"./plugins.config.mjs";import{isCI as b,isDev as y,isLibrary as j,NODE_ENV as v,packageJson as C}from"./process-env.mjs";export const outputConfig={path:p(j?"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:`${d.projectName}`,type:"umd",umdNamedDefine:!0},globalObject:"self",chunkLoadingGlobal:`webpackJsonp_${C.name}`,pathinfo:y,clean:!y,publicPath:f,asyncChunks:!0,charset:!0,iife:!0,crossOriginLoading:"use-credentials",enabledWasmLoadingTypes:["fetch"]};let x={main:[c("@app/entry")]};if(h.polyfill&&x.main.unshift(t(s.corePath,"./polyfills/replace-children.mjs")),y&&h.refresh&&h.env.injectRemoteReactRefresh&&x.main.unshift(r.resolve("@moneko/react/lib/injectRemoteReactRefresh.js")),h.entry&&("string"==typeof h.entry?x={main:[h.entry]}:Object.keys(h.entry)&&(x=Object.assign(x,h.entry))),"string"==typeof x.main&&(x.main=[x.main]),h.output){if("string"==typeof h.output)outputConfig.path=h.output;else if(Object.keys(h.output)){let e=h.output,t={...outputConfig.library};Object.assign(outputConfig,e),"object"==typeof h.output&&e.library&&(outputConfig.library=Object.assign(t,e.library))}}let k={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:s.webpackCachePath,memoryCacheUnaffected:!0,name:`.${[n,v].filter(Boolean).join("-")}`,version:`${C.version}`,buildDependencies:{config:a},maxMemoryGenerations:1};!1===h.cache?k=!1:m(h.cache)&&(k=Object.assign(k,h.cache)),b&&(void 0===h.cache||h.cache&&!h.cache.cacheDirectory)&&(k.cacheDirectory=o(i,C.name));export const commonConfig={name:"client",target:"web",devtool:h.devtool,entry:x,mode:y?"development":"production",stats:"errors-only",cache:k,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}},infrastructureLogging:{level:"error"},externalsPresets:h.externalsPresets,plugins:g,node:{global:!1,__filename:!1,__dirname:!1},experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:h.lazyCompilation&&y&&{imports:!0,entries:!0,test:e=>{let t=e.nameForCondition();return!!(t&&(t.startsWith(c(u))||t.startsWith(c("@app/comment"))||t.startsWith(s.pagesPath)||t.startsWith(s.componentsPath)))}},buildHttp:m(h.buildHttp)?{allowedUris:[],lockfileLocation:o(s.httpCachePath,"http.lock"),cacheLocation:o(s.httpCachePath,"data"),upgrade:!0,...h.buildHttp}:h.buildHttp,backCompat:!0,futureDefaults:!0,css:!1,outputModule:!1},resolve:{extensions:[".mts",".mjs",".ts",".tsx",".js",".jsx",".json",".wasm"],alias:h.alias,modules:[s.nodeModules,s.pnpmNodeModules,s.denoNodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:h.resolvePlugins,preferAbsolute:!0,cache:!0,fallback:{}},externals:h.externals,output:outputConfig,recordsPath:t(s.webpackCachePath,"records.json")};h.overrideResolve&&commonConfig.resolve.plugins.push(new l(Object.assign({original:h.alias["@"],override:n&&p(n)},h.overrideResolve)));
|
package/lib/config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{relative as e}from"node:path";import o from"node:process";import{fileExists as t}from"@moneko/utils";import{merge as r}from"webpack-merge";import n from"./commom/paths.mjs";import s from"./commom/require.mjs";import i from"./commom/setup-env.mjs";import a from"./options/jsx-dom-expressions.mjs";import l from"./options/split-chunk.mjs";import{isFunction as m,node_modules as p,resolveProgram as c}from"./utils/index.mjs";import{APPTYPE as u,FRAMEWORK as d,frameworkVersion as f,isCI as h,isDev as g,isLibrary as v,isMobile as x,isReact as j,jsxImportSource as C,mainDirectory as P,NODE_ENV as
|
|
1
|
+
import{relative as e}from"node:path";import o from"node:process";import{fileExists as t}from"@moneko/utils";import{merge as r}from"webpack-merge";import n from"./commom/paths.mjs";import s from"./commom/require.mjs";import i from"./commom/setup-env.mjs";import a from"./options/jsx-dom-expressions.mjs";import l from"./options/split-chunk.mjs";import{isFunction as m,node_modules as p,resolveProgram as c}from"./utils/index.mjs";import{APPTYPE as u,FRAMEWORK as d,frameworkVersion as f,isCI as h,isDev as g,isLibrary as v,isMobile as x,isReact as j,jsxImportSource as C,mainDirectory as P,NODE_ENV as k,PACKAGENAME as b}from"./process-env.mjs";let w=["@app","@moneko","neko-ui",".cache/http/data","@element-plus","ant-design-vue","element-plus","element-ui","ng-zorro-antd","@mui","@du","@fontsource","@fortawesome","font-pingfang-sc","font-pingfang-tc","katex","react-markdown-editor-lite","react-photo-view","schema-design","monaco-editor"];export function getConfig(e){return delete s.cache[e],new Promise(r=>{if(t(e)){let t=s(e).default;return r(m(t)?t(o):t)}return r({})})}let O=await Promise.all([i(k,u,d,[]),getConfig(n.configPath),getConfig(n.customConfigPath)]),y=O[0],S=O[1],M=O[2],I={strict:!1,devtool:g?"eval-cheap-module-source-map":"cheap-module-source-map",seo:!1,mode:"csr",bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{},sourceMap:{filename:"[file].map",publicPath:"",namespace:b,moduleFilenameTemplate:"moneko://[namespace]/[resource-path]?[loaders]",fallbackModuleFilenameTemplate:"moneko://[namespace]/[resource-path]?[loaders]"},env:y,basename:"/",publicPath:"/",rem:{designSize:x?375:1920},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:Object.assign({"@":c(P)},j&&f<18?{"react/package.json":p("react/package.json"),"react/jsx-runtime":p("react/jsx-runtime.js"),"react/jsx-dev-runtime":p("react/jsx-dev-runtime.js")}:{}),moduleRules:[],prefixJsLoader:[],cssModules:[],cssModuleDefinition:!0,importOnDemand:{},proxy:{},devServer:{host:"localhost",port:3e3,open:!0},htmlPluginOption:{title:b.toLocaleUpperCase(),favicon:e(n.programPath,`${n.corePath}/options/favicon.ico`)},copy:{},routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:l,runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:w,js:w,media:w,font:w,wasm:[]},mdx:{jsx:!1,development:g,jsxImportSource:C,providerImportSource:`@moneko/${d}/mdx`},jsxDomExpressions:a,bar:{name:"Client",nameColor:"68",msgColor:"242",barBgColor:"15",barColor:"69",quiet:h},normalizeCss:!0,externalsPresets:{},buildHttp:void 0,virtualModule:{},cssExtract:{},externals:["@swc/core"],lazyCompilation:!1,performance:!1,refresh:"solid"!==d,bundleId:"com.moneko.bid",bundles:[],stylelint:{},eslint:{lintDirtyModulesOnly:!1},minChunkSize:1e3,compression:g};v&&(I.alias=Object.assign(I.alias,{"@pkg":n.componentsPath,[b]:n.componentsPath}));let z=I;(!1===(z=r(z,S,M)).devtool||!1===z.sourceMap)&&(z.sourceMap=!1,z.devtool=!1),z.fixBrowserRouter&&z.htmlPluginOption&&(z.htmlPluginOption.tags||(z.htmlPluginOption.tags=[]),z.htmlPluginOption.tags.push({textContent:"(function(l) {if (l.search[1] === '/' ) {var decoded = l.search.slice(1).split('&').map(function(s) {return s.replace(/~and~/g, '&')}).join('?');window.history.replaceState(null, null,l.pathname.slice(0, -1) + decoded + l.hash);}}(window.location))"})),"true"===o.env.CODESPACES&&(z.devServer.https=!1),!1===z.devServer.https&&"darwin"===o.platform&&(z.devServer.open=!1);export const CONFIG=z;export const PUBLICPATH=CONFIG.publicPath;
|
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
|
|
2
|
-
`):(l(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{relative as r}from"node:path";import i from"node:process";import{URL as n}from"node:url";import{ink as s,print as m,println as a,progressBar as l}from"@moneko/utils";import p from"webpack";import c from"webpack-hot-middleware";import{merge as h}from"webpack-merge";import{diffObject as f}from"./commom/diff-object.mjs";import u,{config_files as d}from"./commom/paths.mjs";import g from"./commom/sigint-exit.mjs";import{devLog as w,PORT as y}from"./dev/config.mjs";import $ from"./dev/generate-progress-html.mjs";import j from"./dev/server.mjs";import v from"./options/reslove.mjs";import b from"./plugin/eslint.mjs";import x from"./plugin/stylelint.mjs";import{empty as C}from"./utils/index.mjs";import{commonConfig as P}from"./common.mjs";import{CONFIG as _,getConfig as S}from"./config.mjs";import{outputFileSystem as k}from"./file-system.mjs";import H from"./module.config.mjs";import{isLibrary as B,isReact as I,refresh as O}from"./process-env.mjs";let T=!1,q="/____progress____",G={percentage:0,info:""},L="/__hmr__",R=new URLSearchParams({name:"client",path:L.substring(1),dynamicPublicPath:!0,timeout:2e3,reload:!O,quiet:!0,noInfo:!0,overlay:!1,autoConnect:!0}).toString(),U=h(P,{watchOptions:{stdin:!0,aggregateTimeout:300,ignored:/node_modules\/(?!(@app)\/)/},entry:{main:[`${v.hotMiddlewareClient}?${R}`]},module:H(!1),plugins:[new p.HotModuleReplacementPlugin,new p.WatchIgnorePlugin({paths:[/node_modules\/(?!(@app)\/)/,/\.d\.ts$/]}),new p.ProgressPlugin({handler(e,t,...o){let r=o.length?`[${t}] ${o.join(" ")}`:" ";T||(G.info=r,G.percentage=e,T=1===e);let n=_.bar;if(n){let t=n.name||"Build";n.quiet?i.stdout.write(`${r}
|
|
2
|
+
`):(l(e||0,1,{msg:r,name:t,barColor:n.barColor,nameColor:n.nameColor,barBgColor:n.barBgColor,msgColor:n.msgColor}),1===e&&i.stdout.write("\r\x1b[2K"))}}})]});if(I){let e=(await import("@pmmmwh/react-refresh-webpack-plugin")).default;U.plugins.push(new e({overlay:!1}))}function E(e){let t=e.join(","),o=[r(u.programPath,`${_.alias["@"]}/**/*.{${t}}`).replace(/\\/g,"/")];return B&&o.push(r(u.programPath,`${_.alias["@pkg"]}/**/*.{${t}}`).replace(/\\/g,"/")),o}_.eslint&&U.plugins.push(new b({fix:!0,cache:!0,cacheLocation:`${u.lintCachePath}/.eslintcache`,cacheStrategy:"metadata",files:E(["js","jsx","ts","tsx","json","html","vue"]),..._.eslint})),_.stylelint&&U.plugins.push(new x({fix:!0,cache:!0,cacheLocation:`${u.lintCachePath}/.stylelintcache`,files:E(["css","scss","sass","less","ts","tsx","js","jsx"]),..._.stylelint}));let F=p(U);F.outputFileSystem=k;let M=F.watch(F.options.watchOptions,w);F.hooks.done.tap("client-log",e=>{w(null,e)});let N=`${_.publicPath}/${L}`.replace(/\/+/g,"/"),J=c(F,{log:!1,path:N,heartbeat:2e3}),K=await j({port:y,root_dir:F.options.output.path,fileSystem:F.outputFileSystem,proxy:_.proxy,headers:_.devServer.headers,https:_.devServer.https,host:_.devServer.host,open:_.devServer.open,basename:_.basename,onRequest(e,t){let o=new n(`${_.devServer.https?"https":"http"}://${e.headers.host}${e.url}`);if("GET"===e.method){if(o.pathname===q)return t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(G)),!0;if(!T)return t.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),t.end($(q,G)),!0;if(o.pathname===N&&"text/event-stream"===e.headers.accept)return J(e,t,C),!0}return!1}});function W(){i.exit(0)}K.on("close",()=>{M.close(C),J.close()});let z=await Promise.all(d.map(S)),A=h(z[0]||{},z[1]||{});d.forEach(function(t){o(t,async function(){let[o,r]=await Promise.all(d.map(S)),n=h(o||{},r||{}),l=f(A,n);1===Object.keys(l).length&&"proxy"in l?(m(s(`代理更新中...`,"yellow"),!0),m(s(`代理更新完成...`,"green"),!0),_.proxy=n.proxy,A.proxy=n.proxy,A=n):(A=n,a(s(`检测到工程配置${s(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),e(D?`netstat -ano | findstr :${y}`:`lsof -i :${y} -t`,(e,t)=>{if(e){a(s(`查找端口 ${y} 时发生错误: ${e.message}`,"red")),a(s("请尝试手动重启程序","yellow"));return}let o=t.trim().replace(/\r\n/g,"\n").split("\n").filter(Boolean),r=D?o[0]?.split(/\s+/).pop()?.trim():o[0]?.trim();if(!r){a(s(`未找到占用端口 ${y} 的进程, 请尝试手动重启程序`,"yellow"));return}try{i.kill(Number(r),"SIGHUP")}catch(e){a(s(`终止进程 ${r} 时发生错误: ${e.message}`,"red"))}}))})});let D="win32"===i.platform;i.on("SIGHUP",function(){K.close(C),function(){let e=t(i.argv[0],i.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",W)}()}),i.on("exit",function(){K.close(C)}),g(W);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(exports,{camelCase:function(){return d},dashesCamelCase:function(){return h},getFilter:function(){return i},getPreRequester:function(){return u},isDataUrl:function(){return l},isUrlRequestable:function(){return n},normalizeSourceMapForRuntime:function(){return f},requestify:function(){return s},resolveRequests:function(){return o},urlToRequest:function(){return a}});const e=require("node:path"),t=require("node:url"),r=/^[A-Z]:[/\\]|^\\\\/i;function a(e,t){let a;if(""===e)return"";let o=/^[^?]*~/;if(r.test(e))a=e;else if(void 0!==t&&!1!==t&&e.startsWith("/"))switch(typeof t){case"string":a=o.test(t)?t.replace(/([^~/])$/,"$1/")+e.slice(1):t+e;break;case"boolean":a=e;break;default:throw Error(`Unexpected parameters to loader-utils 'urlToRequest': url = ${e}, root = ${t}.`)}else a=/^\.\.?\//.test(e)?e:`./${e}`;return o.test(a)&&(a=a.replace(o,"")),a}async function o(e,t,r){return e(t,r[0]).then(e=>e).catch(a=>{let[,...s]=r;if(0===s.length)throw a;return o(e,t,s)})}function s(e,r){return/^file:/i.test(e)?(0,t.fileURLToPath)(e):/^[a-z][a-z0-9+.-]*:/i.test(e)?e:"/"===e.charAt(0)?a(e,r):a(e)}function n(e){return!(e.startsWith("//")||/^(https?:)?\/\//.test(e))&&(!!(/^file:/i.test(e)||/^[a-z][a-z0-9+.-]*:/i.test(e))||!e.startsWith("#"))}function l(e){return!!/^data:/i.test(e)}function u({loaders:e,loaderIndex:t}){let r=Object.create(null);return a=>{if(r[a])return r[a];if(!1===a)r[a]="";else{let o=e.slice(t,t+1+("number"!=typeof a?0:a)).map(e=>e.request).join("!");r[a]=`-!${o}!`}return r[a]}}function i(e,t){return(...r)=>"function"!=typeof e||e(...r,t)}const c=/^[a-z]:[/\\]|^\\\\/i,p=/^[a-z0-9+\-.]+:/i;function f(t,r){let a=t?t.toJSON():null;return a&&(delete a.file,a.sourceRoot="",a.sources=a.sources?.map(t=>{var a;if(t.startsWith("<")||"path-relative"!=("/"===t[0]?"/"===t[1]?"scheme-relative":"path-absolute":c.test(t)?"path-absolute":p.test(t)?"absolute":"path-relative"))return t;let o=(0,e.dirname)(r.resourcePath),s=(0,e.resolve)(o,t),n=(a=(0,e.relative)(r.rootContext,s),"\\"===e.sep?a.replace(/\\/g,"/"):a);return`
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(exports,{camelCase:function(){return d},dashesCamelCase:function(){return h},getFilter:function(){return i},getPreRequester:function(){return u},isDataUrl:function(){return l},isUrlRequestable:function(){return n},normalizeSourceMapForRuntime:function(){return f},requestify:function(){return s},resolveRequests:function(){return o},urlToRequest:function(){return a}});const e=require("node:path"),t=require("node:url"),r=/^[A-Z]:[/\\]|^\\\\/i;function a(e,t){let a;if(""===e)return"";let o=/^[^?]*~/;if(r.test(e))a=e;else if(void 0!==t&&!1!==t&&e.startsWith("/"))switch(typeof t){case"string":a=o.test(t)?t.replace(/([^~/])$/,"$1/")+e.slice(1):t+e;break;case"boolean":a=e;break;default:throw Error(`Unexpected parameters to loader-utils 'urlToRequest': url = ${e}, root = ${t}.`)}else a=/^\.\.?\//.test(e)?e:`./${e}`;return o.test(a)&&(a=a.replace(o,"")),a}async function o(e,t,r){return e(t,r[0]).then(e=>e).catch(a=>{let[,...s]=r;if(0===s.length)throw a;return o(e,t,s)})}function s(e,r){return/^file:/i.test(e)?(0,t.fileURLToPath)(e):/^[a-z][a-z0-9+.-]*:/i.test(e)?e:"/"===e.charAt(0)?a(e,r):a(e)}function n(e){return!(e.startsWith("//")||/^(https?:)?\/\//.test(e))&&(!!(/^file:/i.test(e)||/^[a-z][a-z0-9+.-]*:/i.test(e))||!e.startsWith("#"))}function l(e){return!!/^data:/i.test(e)}function u({loaders:e,loaderIndex:t}){let r=Object.create(null);return a=>{if(r[a])return r[a];if(!1===a)r[a]="";else{let o=e.slice(t,t+1+("number"!=typeof a?0:a)).map(e=>e.request).join("!");r[a]=`-!${o}!`}return r[a]}}function i(e,t){return(...r)=>"function"!=typeof e||e(...r,t)}const c=/^[a-z]:[/\\]|^\\\\/i,p=/^[a-z0-9+\-.]+:/i;function f(t,r){let a=t?t.toJSON():null;return a&&(delete a.file,a.sourceRoot="",a.sources=a.sources?.map(t=>{var a;if(t.startsWith("<")||"path-relative"!=("/"===t[0]?"/"===t[1]?"scheme-relative":"path-absolute":c.test(t)?"path-absolute":p.test(t)?"absolute":"path-relative"))return t;let o=(0,e.dirname)(r.resourcePath),s=(0,e.resolve)(o,t),n=(a=(0,e.relative)(r.rootContext,s),"\\"===e.sep?a.replace(/\\/g,"/"):a);return`moneko://${n}`})),JSON.stringify(a)}function h(e){return e.replace(/-+(\w)/g,(e,t)=>t.toUpperCase())}const C=(e,t)=>{let r=!1,a=!1,o=!1;for(let s=0;s<e.length;s++){let n=e[s];r&&/[\p{Lu}]/u.test(n)?(e=`${e.slice(0,s)}-${e.slice(s)}`,r=!1,o=a,a=!0,s++):a&&o&&/[\p{Ll}]/u.test(n)?(e=`${e.slice(0,s-1)}-${e.slice(s-1)}`,o=a,a=!1,r=!0):(r=n.toLocaleLowerCase(t)===n&&n.toLocaleUpperCase(t)!==n,o=a,a=n.toLocaleUpperCase(t)===n&&n.toLocaleLowerCase(t)!==n)}return e},L=e=>e.replace(/^[\p{Lu}](?![\p{Lu}])/gu,e=>e.toLowerCase()),g=(e,t)=>e.replace(/[_.\- ]+([\p{Alpha}\p{N}_]|$)/gu,(e,r)=>r.toLocaleUpperCase(t.locale)).replace(/\d+([\p{Alpha}\p{N}_]|$)/gu,e=>e.toLocaleUpperCase(t.locale)),d=(e,t)=>{if(!("string"==typeof e||Array.isArray(e)))throw TypeError("Expected the input to be `string | string[]`");return(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},0===(e=Array.isArray(e)?e.map(e=>e.trim()).filter(e=>e.length).join("-"):e.trim()).length)?"":1===e.length?t.pascalCase?e.toLocaleUpperCase(t.locale):e.toLocaleLowerCase(t.locale):(e!==e.toLocaleLowerCase(t.locale)&&(e=C(e,t.locale)),e=e.replace(/^[_.\- ]+/,""),e=t.preserveConsecutiveUppercase?L(e):e.toLocaleLowerCase(),t.pascalCase&&(e=e.charAt(0).toLocaleUpperCase(t.locale)+e.slice(1)),g(e,t))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{compression as e}from"@moneko/utils";export default class{constructor(e){this.name="compression-plugin";let{test:
|
|
1
|
+
import{compression as e}from"@moneko/utils";export default class{constructor(e){this.name="compression-plugin";let{test:s,algorithm:t="brotli"}=e||{};this.options={test:s,algorithm:t,filename:`[path][base].${"brotli"===t?"br":"gz"}`}}runCompressionAlgorithm(s){return Buffer.from(e(Buffer.isBuffer(s)?Array.from(s):s,this.options.algorithm))}async compress(e,s,t){let o=s.getCache(this.name),{RawSource:i}=e.webpack.sources;await Promise.all(Object.keys(t).map(async t=>{let r;let a="gzip"===this.options.algorithm?"gzipped":`${this.options.algorithm}ed`,{info:m,source:p}=s.getAsset(t);if(m.compressed||!e.webpack.ModuleFilenameHelpers.matchObject.bind(void 0,this.options)(t)||m.related&&m.related[a])return!1;let l=o.getItemCache(JSON.stringify(`${t}${this.options.algorithm}`),o.getLazyHashedEtag(p)),n=await l.getPromise()||{};if(!n.source){if("function"==typeof p.buffer)r=p.buffer();else{let e=p.source();r=Buffer.isBuffer(e)?e:Buffer.from(e)}if(!n.compressed&&r)try{n.compressed=this.runCompressionAlgorithm(r)}catch(e){s.errors.push(e);return}n.compressed&&(n.source=new i(n.compressed)),await l.storePromise(n)}let c=s.getPath(this.options.filename,{filename:t}),f={compressed:!0};m.immutable&&/(\[name]|\[base]|\[file])/.test(this.options.filename)&&(f.immutable=!0),s.updateAsset(t,p,{related:{[a]:c}}),s.emitAsset(c,n.source,f)}))}apply(e){let s=this.constructor.name;e.hooks.thisCompilation.tap(s,t=>{t.hooks.processAssets.tapPromise({name:s,stage:e.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER,additionalAssets:!0},s=>this.compress(e,t,s))})}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Buffer as s}from"node:buffer";import{transform as e}from"lightningcss";import i from"webpack";let t=new TextEncoder,o=i.sources.RawSource,n=i.sources.SourceMapSource,a=i.ModuleFilenameHelpers.matchObject,r="lightning-css-minify",m=/\.(c|le|sc|sa)ss(?:\?.*)?$/i;export class LightningCssMinifyPlugin{constructor(s={}){let{implementation:i,...t}=s;if(i&&"function"!=typeof i.transform)throw TypeError(`[LightningCssMinifyPlugin]: implementation.transform must be an 'lightningcss' transform function. Received ${typeof i.transform}`);this.transform=i?.transform??e,this.options=t}apply(s){let e=JSON.stringify({name:r,version:"0.0.1",options:this.options});s.hooks.compilation.tap(r,s=>{s.hooks.chunkHash.tap(r,(s,i)=>i.update(e)),s.hooks.processAssets.tapPromise({name:r,stage:i.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,additionalAssets:!0},async()=>await this.transformAssets(s)),s.hooks.statsPrinter.tap(r,s=>{s.hooks.print.for("asset.info.minimized").tap(r,(s,{green:e,formatFlag:i})=>s?e(i("minimized")):void 0)})})}async transformAssets(e){let{options:{devtool:i}}=e.compiler,{include:
|
|
1
|
+
import{Buffer as s}from"node:buffer";import{transform as e}from"lightningcss";import i from"webpack";let t=new TextEncoder,o=i.sources.RawSource,n=i.sources.SourceMapSource,a=i.ModuleFilenameHelpers.matchObject,r="lightning-css-minify",m=/\.(c|le|sc|sa)ss(?:\?.*)?$/i;export class LightningCssMinifyPlugin{constructor(s={}){let{implementation:i,...t}=s;if(i&&"function"!=typeof i.transform)throw TypeError(`[LightningCssMinifyPlugin]: implementation.transform must be an 'lightningcss' transform function. Received ${typeof i.transform}`);this.transform=i?.transform??e,this.options=t}apply(s){let e=JSON.stringify({name:r,version:"0.0.1",options:this.options});s.hooks.compilation.tap(r,s=>{s.hooks.chunkHash.tap(r,(s,i)=>i.update(e)),s.hooks.processAssets.tapPromise({name:r,stage:i.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,additionalAssets:!0},async()=>await this.transformAssets(s)),s.hooks.statsPrinter.tap(r,s=>{s.hooks.print.for("asset.info.minimized").tap(r,(s,{green:e,formatFlag:i})=>s?e(i("minimized")):void 0)})})}async transformAssets(e){let{options:{devtool:i}}=e.compiler,{include:c,exclude:p,test:f,sourceMap:l=void 0===this.options.sourceMap?!!(i&&i.includes("source-map")):this.options.sourceMap,...u}=this.options,h=e.getCache(r),d=e.getAssets().filter(s=>!s.info.minimized&&(f||m).test(s.name)&&a({include:c,exclude:p},s.name));await Promise.all(d.map(async i=>{let a;let r=h.getItemCache(JSON.stringify(i.name),h.getLazyHashedEtag(i.source)),m=await r.getPromise();if(m&&m.minimized){e.updateAsset(i.name,m.source,{...i.info,minimized:!0});return}let c=i.source.source(),p="string"==typeof c?t.encode(c):c,f=this.transform({filename:i.name,code:p,minify:!0,sourceMap:l,...u}),d=s.from(f.code),g={source:a=l?new n(d,i.name,f.map||"",c,f.map||"",!0):new o(d),minimized:!0};await r.storePromise(g),e.updateAsset(i.name,a,{...i.info,minimized:!0})}))}}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type JsMinifyOptions, minify } from '@swc/core';
|
|
2
2
|
import webpack, { type Compilation, type Compiler, type sources, WebpackError } from 'webpack';
|
|
3
|
+
declare const SourceMapSource: typeof sources.SourceMapSource;
|
|
3
4
|
interface CacheItem {
|
|
4
|
-
source: sources.
|
|
5
|
+
source: sources.SourceMapSource;
|
|
5
6
|
minimized: boolean;
|
|
6
7
|
}
|
|
7
8
|
declare class SwcMinifyPlugin {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{minify as e}from"@swc/core";import s from"webpack";export default class{constructor(e){this.name="SwcMinifyPlugin",this.options={format:{comments:!1},ecma:2015,compress:{drop_console:!0,drop_debugger:!0,global_defs:{"@alert":"console.log"},pure_funcs:["console.log","console.warn","console.error","console.info"],ecma:2015,toplevel:!1,module:!1,ie8:!1,keep_classnames:void 0,keep_fnames:!1,top_retain:[],keep_infinity:!0},mangle:!0,...e}}apply(
|
|
1
|
+
import{minify as e}from"@swc/core";import s from"webpack";let o=s.sources.SourceMapSource;export default class{constructor(e){this.name="SwcMinifyPlugin",this.options={format:{comments:!1},ecma:2015,compress:{drop_console:!0,drop_debugger:!0,global_defs:{"@alert":"console.log"},pure_funcs:["console.log","console.warn","console.error","console.info"],ecma:2015,toplevel:!1,module:!1,ie8:!1,keep_classnames:void 0,keep_fnames:!1,top_retain:[],keep_infinity:!0},mangle:!0,sourceMap:!0,...e}}apply(t){t.hooks.compilation.tap(this.name,t=>{t.hooks.processAssets.tapAsync({name:this.name,stage:s.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,additionalAssets:!0},async(s,a)=>{let i=t.getCache(this.name),n=Object.keys(s).filter(e=>e.endsWith(".js")&&!e.endsWith(".min.js"));try{await Promise.all(n.map(async s=>{let a=t.getAsset(s);if(!a||a.info.minimized)return;let n=i.getItemCache(JSON.stringify(a.name),i.getLazyHashedEtag(a.source)),r=await n.getPromise();if(r&&r.minimized){t.updateAsset(a.name,r.source,{...a.info,minimized:!0});return}let c=a.source.sourceAndMap();try{let s=await e(c.source.toString().replace(/\r\n/g,"\n"),this.options),i={sources:[a.name]};s.map&&((i=JSON.parse(s.map)).sources=[a.name],delete i.sourcesContent);let r={source:new o(s.code,a.name,i||"",c.source,c.map||"",!0),minimized:!0};await n.storePromise(r),t.updateAsset(a.name,r.source,{...a.info,minimized:!0})}catch(e){t.errors.push(e)}})),a()}catch(e){a(e)}})})}}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import webpack, { type WebpackPluginInstance } from 'webpack';
|
|
2
|
+
import CompressionPlugin, { type CompressionPluginOptions } from './plugin/compression.mjs';
|
|
3
|
+
import { CopyPlugin } from './plugin/copy.mjs';
|
|
4
|
+
import { HtmlMeta, HtmlPlugin } from './plugin/html-plugin.mjs';
|
|
5
|
+
import moduleFederation from './plugin/module-federation.mjs';
|
|
6
|
+
import { VirtualModuleWebpackPlugin } from './plugin/virtual-module.mjs';
|
|
7
|
+
import { CONFIG } from './config.mjs';
|
|
8
|
+
import { packageJson } from './process-env.mjs';
|
|
9
|
+
declare const compression: Partial<CompressionPluginOptions>;
|
|
10
|
+
declare const plugins: WebpackPluginInstance[];
|
|
11
|
+
export default plugins;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"webpack";import t from"./plugin/compression.mjs";import{CopyPlugin as o}from"./plugin/copy.mjs";import{HtmlPlugin as i}from"./plugin/html-plugin.mjs";import r from"./plugin/module-federation.mjs";import{VirtualModuleWebpackPlugin as p}from"./plugin/virtual-module.mjs";import{CONFIG as l}from"./config.mjs";import{packageJson as n}from"./process-env.mjs";let s="object"==typeof l.compression?l.compression:{},a=[...r,new p(l.virtualModule),new o(l.copy),new e.DefinePlugin({"process.env":JSON.stringify(l.env)}),new e.IgnorePlugin({resourceRegExp:/\/(__(tests|mocks)__|test|spec|e2e)\//}),...l.plugins,l.compression&&new t({algorithm:l.devServer.https?"brotli":"gzip",test:/\.(js|css|html|svg|ttf|woff|woff2|png|jpg|jpeg)$/,...s})].filter(Boolean);if(l.htmlPluginOption){let e={charset:"UTF-8","X-UA-Compatible":{"http-equiv":"X-UA-Compatible",content:"IE=edge,Chrome=1"},HandheldFriendly:"true",MobileOptimized:"320","screen-orientation":"portrait","x5-orientation":"portrait",browsermode:"application","x5-page-mode":"app","msapplication-tap-highlight":"no","mobile-web-app-capable":"yes",renderer:"webkit",description:n.description,keywords:Array.isArray(n.keywords)?n.keywords.toString():"","http-equiv":"refresh",viewport:"width=device-width, initial-scale=1"};l.seo&&(e.relCanonical={rel:"canonical",href:`https://${l.seo.domain}${l.basename}`}),l.htmlPluginOption.meta&&Object.assign(e,l.htmlPluginOption.meta),a.push(new i({...l.htmlPluginOption,meta:e}))}if(l.fixBrowserRouter){let e=l.basename.split("/").filter(Boolean).length,t=`${Array(e).fill("..").join("/")+(e?"/":"")}404.html`,o=l.fixBrowserRouter.pathSegmentsToKeep??e;a.push(new i({filename:l.fixBrowserRouter.path??t,inject:!1,templateContent:()=>`<html lang="en"><head><title>Redirect</title><script>const pathKeep = ${o};const l = window.location;l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + l.pathname.split('/').slice(0, 1 + pathKeep).join('/') + '/?/' + l.pathname.slice(1).split('/').slice(pathKeep).join('/').replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash);</script></head><body></body></html>`}))}l.sourceMap&&a.push(new e.SourceMapDevToolPlugin(l.sourceMap));export default a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parentPort as e}from"node:worker_threads";import{transform as o}from"@moneko/eslint/babel-core";import{BabelPluginReactCompiler as r}from"@moneko/eslint/react-compiler";import s from"../commom/log.mjs";e?.on("message",async({sourceCode:m,resourcePath:
|
|
1
|
+
import{parentPort as e}from"node:worker_threads";import{transform as o}from"@moneko/eslint/babel-core";import{BabelPluginReactCompiler as r}from"@moneko/eslint/react-compiler";import s from"../commom/log.mjs";e?.on("message",async({sourceCode:m,resourcePath:i,...n})=>{o(m,{sourceFileName:i,filename:i,sourceMaps:"inline",plugins:[[r,n]],cloneInputAst:!1,ast:!1,configFile:!1,babelrc:!1},(o,r)=>{if(o){s(o),e?.postMessage([o,m]);return}if(null===r){e?.postMessage([Error(`Failed to transform "${i}"`),m]);return}e?.postMessage([null,r.code??void 0,r.map??void 0])})});
|
package/package.json
CHANGED