@moneko/core 3.57.5 → 3.57.6

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 CHANGED
@@ -1 +1 @@
1
- import{extname as e,join as t,resolve as o}from"node:path";import{argv as s}from"node:process";import a,{config_files as i,CUSTOMCONFIG as n,TMP_DIR as r}from"./commom/paths.mjs";import{OverrideResolverPlugin as l}from"./plugin/override-resolve.mjs";import{isObject as m,md5 as c,node_modules as p,resolveProgram as u}from"./utils/index.mjs";import{exampleModuleName as h}from"./vm/example.mjs";import d from"./vm/info.mjs";import{CONFIG 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:u(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:!0,publicPath:f.publicPath,asyncChunks:!0,charset:!0,iife:!0,crossOriginLoading:"use-credentials",enabledWasmLoadingTypes:["fetch"],uniqueName:`${d.projectName}`};let P={main:[p("@app/entry")]},x=[t(a.corePath,"./polyfills/public-path.mjs")];if(y&&f.refresh&&f.env.injectRemoteReactRefresh&&x.push(t(a.corePath,"./polyfills/inject-react-refresh.mjs")),f.polyfill&&x.push(t(a.corePath,"./polyfills/replace-children.mjs")),f.entry&&("string"==typeof f.entry?P={...P,main:[f.entry]}:Object.keys(f.entry)&&(P=Object.assign(P,f.entry))),"string"==typeof P.main?P.main=[...x,P.main]:Array.isArray(P.main)&&(P.main=[...x,...P.main]),f.output){if("string"==typeof f.output)outputConfig.path=f.output;else if(Object.keys(f.output)){let e=f.output,t={...outputConfig.library};Object.assign(outputConfig,e),"object"==typeof f.output&&e.library&&(outputConfig.library=Object.assign(t,e.library))}}let k={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:a.webpackCachePath,memoryCacheUnaffected:!y,name:c(`${n}-${v}-${s[2]}`),version:`${C.version}`,buildDependencies:{config:i},maxMemoryGenerations:1};!1===f.cache?k=!1:m(f.cache)&&(k=Object.assign(k,f.cache)),b&&(void 0===f.cache||f.cache&&!f.cache.cacheDirectory)&&(k.cacheDirectory=o(r,C.name));let M={},O={imports:!0,entries:!0,test:e=>{let t=e.nameForCondition();return!!(t&&(t.startsWith(p(h))||t.startsWith(p("@app/comment"))||t.startsWith(a.pagesPath)||t.startsWith(a.componentsPath)))}};f.lazyCompilation&&y&&"true"!==process.env.IS_BUILD?m(f.lazyCompilation)?Object.assign(M,O,f.lazyCompilation):Object.assign(M,O):M=!1;export const commonConfig={name:"client",target:"web",devtool:f.devtool,entry:P,mode:f.mode??"production",stats:"errors-only",cache:k,snapshot:{immutablePaths:[a.pnpmNodeModules,a.denoNodeModules,/node_modules\/(?!(@app)\/)/],managedPaths:[a.pnpmNodeModules,a.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:f.externalsPresets,plugins:g,node:{global:!1,__filename:!1,__dirname:!1},experiments:{asyncWebAssembly:!0,cacheUnaffected:!y,lazyCompilation:M,buildHttp:m(f.buildHttp)?{allowedUris:[],lockfileLocation:o(a.httpCachePath,"http.lock"),cacheLocation:o(a.httpCachePath,"data"),upgrade:!0,...f.buildHttp}:f.buildHttp,backCompat:!0,futureDefaults:!0,css:!1,outputModule:!1},resolve:{extensions:[".mts",".mjs",".ts",".tsx",".js",".jsx",".json",".wasm"],alias:f.alias,modules:[a.nodeModules,a.pnpmNodeModules,a.denoNodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:f.resolvePlugins,preferAbsolute:!0,cache:!0,fallback:{}},externals:f.externals,output:outputConfig,recordsPath:f.recordsPath?t(a.programPath,f.recordsPath):t(a.webpackCachePath,"records.json")};f.overrideResolve&&commonConfig.resolve.plugins.push(new l(Object.assign({original:f.alias["@"],override:n&&u(n)},f.overrideResolve)));
1
+ import{extname as e,join as t,resolve as o}from"node:path";import{argv as s}from"node:process";import a,{config_files as n,CUSTOMCONFIG as i,TMP_DIR as r}from"./commom/paths.mjs";import{OverrideResolverPlugin as l}from"./plugin/override-resolve.mjs";import{isObject as m,md5 as c,node_modules as p,resolveProgram as u}from"./utils/index.mjs";import{exampleModuleName as d}from"./vm/example.mjs";import h from"./vm/info.mjs";import{CONFIG 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:u(j?"docs":"dist"),filename:e=>e.filename?.includes(".worker")?"worker/[name].js":"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:`${h.projectName}`,type:"umd",umdNamedDefine:!0},globalObject:"self",chunkLoadingGlobal:`webpackJsonp_${C.name}`,pathinfo:y,clean:!0,publicPath:f.publicPath,asyncChunks:!0,charset:!0,iife:!0,crossOriginLoading:"use-credentials",enabledWasmLoadingTypes:["fetch"],uniqueName:`${h.projectName}`};let P={main:[p("@app/entry")]},x=[t(a.corePath,"./polyfills/public-path.mjs")];if(y&&f.refresh&&f.env.injectRemoteReactRefresh&&x.push(t(a.corePath,"./polyfills/inject-react-refresh.mjs")),f.polyfill&&x.push(t(a.corePath,"./polyfills/replace-children.mjs")),f.entry&&("string"==typeof f.entry?P={...P,main:[f.entry]}:Object.keys(f.entry)&&(P=Object.assign(P,f.entry))),"string"==typeof P.main?P.main=[...x,P.main]:Array.isArray(P.main)&&(P.main=[...x,...P.main]),f.output){if("string"==typeof f.output)outputConfig.path=f.output;else if(Object.keys(f.output)){let e=f.output,t={...outputConfig.library};Object.assign(outputConfig,e),"object"==typeof f.output&&e.library&&(outputConfig.library=Object.assign(t,e.library))}}let k={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:a.webpackCachePath,memoryCacheUnaffected:!y,name:c(`${i}-${v}-${s[2]}`),version:`${C.version}`,buildDependencies:{config:n},maxMemoryGenerations:1};!1===f.cache?k=!1:m(f.cache)&&(k=Object.assign(k,f.cache)),b&&(void 0===f.cache||f.cache&&!f.cache.cacheDirectory)&&(k.cacheDirectory=o(r,C.name));let M={},w={imports:!0,entries:!0,test:e=>{let t=e.nameForCondition();return!!(t&&(t.startsWith(p(d))||t.startsWith(p("@app/comment"))||t.startsWith(a.pagesPath)||t.startsWith(a.componentsPath)))}};f.lazyCompilation&&y&&"true"!==process.env.IS_BUILD?m(f.lazyCompilation)?Object.assign(M,w,f.lazyCompilation):Object.assign(M,w):M=!1;export const commonConfig={name:"client",target:"web",devtool:f.devtool,entry:P,mode:f.mode??"production",stats:"errors-only",cache:k,snapshot:{immutablePaths:[a.pnpmNodeModules,a.denoNodeModules,/node_modules\/(?!(@app)\/)/],managedPaths:[a.pnpmNodeModules,a.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:f.externalsPresets,plugins:g,node:{global:!1,__filename:!1,__dirname:!1},experiments:{asyncWebAssembly:!0,cacheUnaffected:!y,lazyCompilation:M,buildHttp:m(f.buildHttp)?{allowedUris:[],lockfileLocation:o(a.httpCachePath,"http.lock"),cacheLocation:o(a.httpCachePath,"data"),upgrade:!0,...f.buildHttp}:f.buildHttp,backCompat:!0,futureDefaults:!0,css:!1,outputModule:!1},resolve:{extensions:[".mts",".mjs",".ts",".tsx",".js",".jsx",".json",".wasm"],alias:f.alias,modules:[a.nodeModules,a.pnpmNodeModules,a.denoNodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:f.resolvePlugins,preferAbsolute:!0,cache:!0,fallback:{}},externals:f.externals,output:outputConfig,recordsPath:f.recordsPath?t(a.programPath,f.recordsPath):t(a.webpackCachePath,"records.json")};f.overrideResolve&&commonConfig.resolve.plugins.push(new l(Object.assign({original:f.alias["@"],override:i&&u(i)},f.overrideResolve)));
@@ -1 +1 @@
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){if("string"==typeof this.options.publicPath)return this.options.publicPath;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
+ 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){if("string"==typeof this.options.publicPath)return this.options.publicPath;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 r="function"==typeof this.options.filename?this.options.filename("index"):this.options.filename||"index.html";a.emitAsset(r,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(" "),r=`<${i} ${h}>${n}</${i}>`;"head"===o?e.push(r):s.push(r)}),t.head=e.join(""),t.body=s.join(""),this.cachedCustomTags=t,t}getAssets(t){let e={js:[],css:[]},s=["import-scripts","require","async-node"],i=this.getPublicPath(t);for(let n of t.entrypoints.values())for(let t of n.chunks){let n=t.getEntryOptions()?.chunkLoading;if(!(n&&s.includes(n)))for(let s of t.files)s.endsWith(".js")?e.js.push(i+s):s.endsWith(".css")&&e.css.push(i+s)}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}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.57.5",
3
+ "version": "3.57.6",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",
@@ -139,7 +139,7 @@ export declare type ConfigType = {
139
139
  * }
140
140
  * ```
141
141
  **/
142
- entry?: Record<string, string> | string;
142
+ entry?: Configuration['entry'] & { main?: string[] };
143
143
  /** 压缩配置 */
144
144
  minifier: SwcMinifyOptions | false;
145
145
  /** 环境变量, 可通过 process.env 获取 */