@moneko/core 4.5.8-beta.2 → 4.6.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 CHANGED
@@ -1 +1 @@
1
- import{extname as e,join as t,resolve as s}from"node:path";import o from"./commom/has-pkg.mjs";import a,{config_files as n,CUSTOMCONFIG as i}from"./commom/paths.mjs";import*as r from"./commom/rule.mjs";import{OverrideResolverPlugin as l}from"./plugin/override-resolve.mjs";import{isObject as m,resolveProgram as c}from"./utils/index.mjs";import{CONFIG as p}from"./config.mjs";import u from"./plugins.config.mjs";import{app_schema as h,CACHE_NAME as d,isDev as f,isLibrary as g,packageJson as y,projectNameCamelCase as b}from"./process-env.mjs";export const outputConfig={path:c(g?"docs":"dist"),filename:e=>e.filename?.includes(".worker")?"worker/[name].js":"js/[name].[contenthash].bundle.js",chunkFilename:"js/[contenthash].chunk.js",cssFilename:"style/[contenthash].css",cssChunkFilename:"style/[contenthash].chunk.css",assetModuleFilename:t=>{let s=e(t.filename||"").substring(1);return`assets/${s}/[hash][ext]`},library:{name:`${b}`,type:"umd",umdNamedDefine:!0},globalObject:"self",chunkLoadingGlobal:`webpackJsonp_${y.name}`,pathinfo:f,clean:!0,publicPath:p.publicPath,asyncChunks:!0,charset:!0,iife:!0,crossOriginLoading:"use-credentials",enabledWasmLoadingTypes:["fetch"],uniqueName:`${b}`};let j={main:[o(t(p.alias["@"],"service-worker")),`${h}:entry`].filter(Boolean)},v=[t(a.corePath,"./polyfills/public-path.mjs")];if(f&&p.refresh&&p.env.injectRemoteReactRefresh&&v.push(t(a.corePath,"./polyfills/inject-react-refresh.mjs")),p.polyfill&&v.push(t(a.corePath,"./polyfills/replace-children.mjs")),p.entry&&("string"==typeof p.entry?j={...j,main:[p.entry]}:Object.keys(p.entry)&&(j=Object.assign(j,p.entry))),"string"==typeof j.main?j.main=[...v,j.main]:Array.isArray(j.main)&&(j.main=[...v,...j.main]),p.output){if("string"==typeof p.output)outputConfig.path=p.output;else if(Object.keys(p.output)){let e=p.output,t={...outputConfig.library};Object.assign(outputConfig,e),"object"==typeof p.output&&e.library&&(outputConfig.library=Object.assign(t,e.library))}}let C={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:a.webpackCachePath,memoryCacheUnaffected:!0,name:d,version:`${y.version}`,buildDependencies:{config:n},maxMemoryGenerations:1};!1===p.cache?C=!1:m(p.cache)&&(C=Object.assign(C,p.cache));let k={},P={imports:!0,entries:!0,test:e=>{let s=e.nameForCondition();return!!(s&&(/^[a-z][a-z0-9]*:.+$/.test(s)||s?.startsWith(t(a.programPath,"src"))||s?.startsWith(t(a.programPath,"site"))||s?.startsWith(a.componentsPath)))}};p.lazyCompilation&&f&&"true"!==process.env.IS_BUILD?m(p.lazyCompilation)?Object.assign(k,P,p.lazyCompilation):Object.assign(k,P):k=!1;export const commonConfig={name:"client",target:"web",devtool:p.devtool,entry:j,mode:p.mode??"production",cache:C,snapshot:{immutablePaths:[a.pnpmNodeModules,a.denoNodeModules,r.node_modules],managedPaths:[a.pnpmNodeModules,a.denoNodeModules,r.node_modules],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}},stats:"errors-only",infrastructureLogging:{level:"error"},externalsPresets:p.externalsPresets,plugins:u,node:{global:!1,__filename:!1,__dirname:!1},experiments:{asyncWebAssembly:!0,cacheUnaffected:!0,lazyCompilation:k,buildHttp:m(p.buildHttp)?{allowedUris:[],lockfileLocation:s(a.httpCachePath,"http.lock"),cacheLocation:s(a.httpCachePath,"data"),upgrade:!0,...p.buildHttp}:p.buildHttp,backCompat:!0,futureDefaults:!0,css:!0,outputModule:!1,deferImport:!0},resolve:{extensions:[".mts",".mjs",".ts",".tsx",".js",".jsx",".json",".wasm"],alias:p.alias,modules:[a.nodeModules,a.pnpmNodeModules,a.denoNodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:p.resolvePlugins,preferAbsolute:!0,cache:!0,fallback:{}},externals:p.externals,output:outputConfig,recordsPath:p.recordsPath};p.overrideResolve&&commonConfig.resolve.plugins.push(new l(Object.assign({original:p.alias["@"],override:i&&c(i)},p.overrideResolve)));
1
+ import{extname as e,join as t,resolve as s}from"node:path";import o from"./commom/has-pkg.mjs";import a,{config_files as n,CUSTOMCONFIG as i}from"./commom/paths.mjs";import*as r from"./commom/rule.mjs";import{OverrideResolverPlugin as l}from"./plugin/override-resolve.mjs";import{isObject as m,resolveProgram as c}from"./utils/index.mjs";import{CONFIG as p}from"./config.mjs";import u from"./plugins.config.mjs";import{app_schema as d,CACHE_NAME as h,isDev as f,isLibrary as g,packageJson as y,projectNameCamelCase as b}from"./process-env.mjs";export const outputConfig={path:c(g?"docs":"dist"),filename:e=>e.filename?.includes(".worker")?"worker/[name].js":"js/[name].[contenthash].min.js",chunkFilename:"js/[contenthash].js",cssFilename:"style/[contenthash].css",cssChunkFilename:"style/[contenthash].css",assetModuleFilename:t=>{let s=e(t.filename||"").substring(1);return`assets/${s}/[hash][ext]`},library:{name:`${b}`,type:"umd",umdNamedDefine:!0},globalObject:"self",chunkLoadingGlobal:`webpackJsonp_${y.name}`,pathinfo:f,clean:!0,publicPath:p.publicPath,asyncChunks:!0,charset:!0,iife:!0,crossOriginLoading:"use-credentials",enabledWasmLoadingTypes:["fetch"],uniqueName:`${b}`};let j={main:[o(t(p.alias["@"],"service-worker")),`${d}:entry`].filter(Boolean)},v=[t(a.corePath,"./polyfills/public-path.mjs")];if(f&&p.refresh&&p.env.injectRemoteReactRefresh&&v.push(t(a.corePath,"./polyfills/inject-react-refresh.mjs")),p.polyfill&&v.push(t(a.corePath,"./polyfills/replace-children.mjs")),p.entry&&("string"==typeof p.entry?j={...j,main:[p.entry]}:Object.keys(p.entry)&&(j=Object.assign(j,p.entry))),"string"==typeof j.main?j.main=[...v,j.main]:Array.isArray(j.main)&&(j.main=[...v,...j.main]),p.output){if("string"==typeof p.output)outputConfig.path=p.output;else if(Object.keys(p.output)){let e=p.output,t={...outputConfig.library};Object.assign(outputConfig,e),"object"==typeof p.output&&e.library&&(outputConfig.library=Object.assign(t,e.library))}}let C={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:a.webpackCachePath,memoryCacheUnaffected:!0,name:h,version:`${y.version}`,buildDependencies:{config:n},maxMemoryGenerations:1};!1===p.cache?C=!1:m(p.cache)&&(C=Object.assign(C,p.cache));let P={},k={imports:!0,entries:!0,test:e=>{let s=e.nameForCondition();return!!(s&&(/^[a-z][a-z0-9]*:.+$/.test(s)||s?.startsWith(t(a.programPath,"src"))||s?.startsWith(t(a.programPath,"site"))||s?.startsWith(a.componentsPath)))}};p.lazyCompilation&&f&&"true"!==process.env.IS_BUILD?m(p.lazyCompilation)?Object.assign(P,k,p.lazyCompilation):Object.assign(P,k):P=!1;export const commonConfig={name:"client",target:"web",devtool:p.devtool,entry:j,mode:p.mode??"production",cache:C,snapshot:{immutablePaths:[a.pnpmNodeModules,a.denoNodeModules,r.node_modules],managedPaths:[a.pnpmNodeModules,a.denoNodeModules,r.node_modules],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}},stats:"errors-only",infrastructureLogging:{level:"error"},externalsPresets:p.externalsPresets,plugins:u,node:{global:!1,__filename:!1,__dirname:!1},experiments:{asyncWebAssembly:!0,cacheUnaffected:!0,lazyCompilation:P,buildHttp:m(p.buildHttp)?{allowedUris:[],lockfileLocation:s(a.httpCachePath,"http.lock"),cacheLocation:s(a.httpCachePath,"data"),upgrade:!0,...p.buildHttp}:p.buildHttp,backCompat:!0,futureDefaults:!0,css:!0,outputModule:!1,deferImport:!0},resolve:{extensions:[".mts",".mjs",".ts",".tsx",".js",".jsx",".json",".wasm"],alias:p.alias,modules:[a.nodeModules,a.pnpmNodeModules,a.denoNodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:p.resolvePlugins,preferAbsolute:!0,cache:!0,fallback:{}},externals:p.externals,output:outputConfig,recordsPath:p.recordsPath};p.overrideResolve&&commonConfig.resolve.plugins.push(new l(Object.assign({original:p.alias["@"],override:i&&c(i)},p.overrideResolve)));
@@ -1 +1 @@
1
- import{existsSync as t,readFileSync as e}from"node:fs";import{basename as s,resolve as i,sep as n}from"node:path";import o from"webpack";import{join as a}from"../commom/posix.mjs";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(h){h.hooks.compilation.tap(this.name,l=>{l.hooks.processAssets.tap({name:this.name,stage:o.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL},()=>{let r;if(this.options.favicon){let r=i(h.context,this.options.favicon);if(t(r)){let t=s(this.options.favicon),i=e(r);l.emitAsset(t,new o.sources.RawSource(i),{javascriptModule:!1});let h=this.getPublicPath(l);this.faviconPath=a(h,t).replaceAll(n,"/")}else l.warnings.push(new o.WebpackError(`Favicon file ${r} does not exist`))}if(r=this.options.templateContent?this.options.templateContent(this.options):this.options.template?e(i(h.context,this.options.template),{encoding:"utf-8"}):this.generateDefaultTemplate(),this.options.inject){let t=this.getAssets(l);r=this.injectAssets(r,t,this.options.inject)}let c="function"==typeof this.options.filename?this.options.filename("index"):this.options.filename||"index.html";l.emitAsset(c,new o.sources.RawSource(r),{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=["import-scripts","require","async-node"],i=this.getPublicPath(t);for(let o of t.entrypoints.values())for(let t of o.chunks){let o=t.getEntryOptions(),h=o?.chunkLoading;if(!(o?.asyncChunks||h&&s.includes(h)))for(let s of t.files)s.endsWith(".js")?e.js.push(a(i,s).replaceAll(n,"/")):s.endsWith(".css")&&e.css.push(a(i,s).replaceAll(n,"/"))}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,sep as n}from"node:path";import o from"webpack";import{join as a}from"../commom/posix.mjs";export class HtmlPlugin{constructor(t={}){this.AddEntry=/(?:.*\/)?main\.[a-zA-Z0-9]+\.min\.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(h){h.hooks.compilation.tap(this.name,l=>{l.hooks.processAssets.tap({name:this.name,stage:o.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL},()=>{let r;if(this.options.favicon){let r=i(h.context,this.options.favicon);if(t(r)){let t=s(this.options.favicon),i=e(r);l.emitAsset(t,new o.sources.RawSource(i),{javascriptModule:!1});let h=this.getPublicPath(l);this.faviconPath=a(h,t).replaceAll(n,"/")}else l.warnings.push(new o.WebpackError(`Favicon file ${r} does not exist`))}if(r=this.options.templateContent?this.options.templateContent(this.options):this.options.template?e(i(h.context,this.options.template),{encoding:"utf-8"}):this.generateDefaultTemplate(),this.options.inject){let t=this.getAssets(l);r=this.injectAssets(r,t,this.options.inject)}let c="function"==typeof this.options.filename?this.options.filename("index"):this.options.filename||"index.html";l.emitAsset(c,new o.sources.RawSource(r),{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=["import-scripts","require","async-node"],i=this.getPublicPath(t);for(let o of t.entrypoints.values())for(let t of o.chunks){let o=t.getEntryOptions(),h=o?.chunkLoading;if(!(o?.asyncChunks||h&&s.includes(h)))for(let s of t.files)s.endsWith(".js")?e.js.push(a(i,s).replaceAll(n,"/")):s.endsWith(".css")&&e.css.push(a(i,s).replaceAll(n,"/"))}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": "4.5.8-beta.2",
3
+ "version": "4.6.0",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",