@moneko/core 3.27.5 → 3.27.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/build.mjs +1 -1
- package/lib/common.d.mts +1 -1
- package/lib/dev.d.mts +0 -2
- package/lib/dev.mjs +1 -1
- package/lib/loader/lightning-css/loader.cjs +1 -1
- package/lib/loader/lightning-css/runtime/get-url.cjs +1 -1
- package/lib/loader/lightning-css/runtime/get-url.d.cts +3 -1
- package/lib/plugin/html-plugin.mjs +1 -1
- package/package.json +2 -2
- package/typings/global.d.ts +2 -2
package/lib/build.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{relative as o}from"node:path";import{analyzeBundleSize as
|
|
1
|
+
import{relative as o}from"node:path";import{analyzeBundleSize as r,completedInfo as m,ink as i,println as t,progressBar as e}from"@moneko/utils";import n from"webpack";import{merge as s}from"webpack-merge";import a from"./build/common.mjs";import p from"./commom/paths.mjs";import l from"./plugin/done.mjs";import{empty as u}from"./utils/index.mjs";import c from"./utils/seo.mjs";import{CONFIG as g}from"./config.mjs";import f from"./module.config.mjs";let d=s(a,{module:f(!1),plugins:[]});if(g.done&&d.plugins.push(new l({done:g.done})),g.bar){let o=g.bar,r=o.name||"Build";d.plugins.push(new n.ProgressPlugin({handler(m,i,...t){e(m||0,1,{msg:t.length?`[${i}] ${t.join(" ")}`:"",name:r,barColor:o.barColor,nameColor:o.nameColor,barBgColor:o.barBgColor,msgColor:o.msgColor}),1===m&&process.stdout.write("\r\x1b[2K")}}))}let h=n(d);async function w(){let e=await new Promise((o,r)=>{h.run((m,i)=>{m&&r(m),i?o(i):r(Error("编译过程中没有生成统计信息"))})});(e.hasErrors()||e.hasWarnings())&&function(o){let{warnings:r,errors:m}=o.compilation;r.forEach(o=>{t(i(o.message,"178"))}),m.forEach(o=>{t(i(o.message,"red"))})}(e),await new Promise(n=>{e.compilation.compiler.cache.shutdown(s=>{s&&t(i(s.toString(),"red")),r(e.compilation.outputOptions.path,["\\.js$"]),m(~~((e.endTime-e.startTime)/10)/100,o(p.programPath,e.compilation.outputOptions.path)),n()})}),g.seo&&c()}process.on("exit",u),await w();
|
package/lib/common.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { extname, join, resolve } from 'node:path';
|
|
2
2
|
import type { Configuration, FileCacheOptions } from 'webpack';
|
|
3
3
|
import paths, { config_files, CUSTOMCONFIG } from './commom/paths.mjs';
|
|
4
|
-
import OverrideResolverPlugin from './plugin/override-resolve.mjs';
|
|
4
|
+
import OverrideResolverPlugin, { type OverrideResolverOption } from './plugin/override-resolve.mjs';
|
|
5
5
|
import { isObject, node_modules, resolveProgram } from './utils/index.mjs';
|
|
6
6
|
import { exampleModuleName } from './vm/example.mjs';
|
|
7
7
|
import app from './vm/info.mjs';
|
package/lib/dev.d.mts
CHANGED
|
@@ -34,8 +34,6 @@ declare const hmrPath: string;
|
|
|
34
34
|
declare const clientParams: ClientOptions;
|
|
35
35
|
declare const hotParams: string;
|
|
36
36
|
declare const path: string | undefined;
|
|
37
|
-
declare const bar: ConfigType['bar'];
|
|
38
|
-
declare const bar_name: string;
|
|
39
37
|
declare const clientOption: webpack.Configuration;
|
|
40
38
|
declare const compilers: webpack.Compiler;
|
|
41
39
|
interface FastifyOptions {
|
package/lib/dev.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
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"@fastify/compress";import{fastifyMiddie as s}from"@fastify/middie";import{ink as l,loadFile as n,print as a,println as m,progressBar as p}from"@moneko/utils";import c from"fastify";import d from"webpack";import u from"webpack-dev-middleware";import h from"webpack-hot-middleware";import{merge as f}from"webpack-merge";import{diffObject as g}from"./commom/diff-object.mjs";import w from"./commom/has-pkg.mjs";import y,{config_files as x}from"./commom/paths.mjs";import v from"./commom/rule.mjs";import C from"./commom/sigint-exit.mjs";import{devLog as k,PORT as $}from"./dev/config.mjs";import b from"./dev/mock.mjs";import{setupProxy as j}from"./dev/proxy.mjs";import P from"./options/reslove.mjs";import S from"./plugin/stylelint.mjs";import{empty as A,resolveProgram as E}from"./utils/index.mjs";import{commonConfig as T}from"./common.mjs";import{CONFIG as I,getConfig as M,PUBLICPATH as _}from"./config.mjs";import R from"./module.config.mjs";import{isLibrary as B,isReact as H,refresh as O}from"./process-env.mjs";let q=I.eslint&&w("eslint-webpack-plugin")&&(await import("eslint-webpack-plugin")).default,z=["js","jsx","ts","tsx","json","html","vue"],U=z.join(","),D=`${_.endsWith("/")?"":"/"}__hmr__`,G=new URLSearchParams({name:"client",path:D,dynamicPublicPath:!0,timeout:2e3,reload:!O,quiet:!0,noInfo:!0,overlay:!0,autoConnect:!0}).toString(),L=T.output.path,W=f(T,{entry:{main:[`${P.hotMiddlewareClient}?${G}`]},output:{path:L},module:R(!1),optimization:{minimize:!1,concatenateModules:!1,removeAvailableModules:!1,removeEmptyChunks:!0,providedExports:!0,usedExports:!1,sideEffects:!1,splitChunks:{chunks:"all",minChunks:1,minSize:30720,maxSize:0,maxAsyncRequests:60,maxInitialRequests:50,hidePathInfo:!1,cacheGroups:{vendors:{test:v.node_modules,priority:-10,reuseExistingChunk:!0},default:{minChunks:1,priority:-20,reuseExistingChunk:!0}}}},plugins:[new d.HotModuleReplacementPlugin,new d.WatchIgnorePlugin({paths:[/node_modules\/(?!(@app|@moneko)).+/,/\.d\.ts$/]})]});if(W.plugins||(W.plugins=[]),H){let e=(await import("@pmmmwh/react-refresh-webpack-plugin")).default;W.plugins.push(new e)}if(q&&W.plugins.push(new q({fix:!0,threads:!0,files:[`${I.alias["@"]}/**/*.{${U}}`,B&&`${I.alias["@pkg"]}/**/*.{${U}}`].filter(Boolean),extensions:z,exclude:["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],cache:!0,cacheLocation:`${y.lintCachePath}/.eslintcache`,lintDirtyModulesOnly:!0,overrideConfigFile:E("eslint.config.mjs"),configType:"flat"})),I.stylelint){let e="css,scss,sass,less,ts,tsx,js,jsx";W.plugins.push(new S({fix:!0,files:[r(y.programPath,`${I.alias["@"]}/**/*.{${e}}`).replace(/\\/g,"/"),B&&r(y.programPath,`${I.alias["@pkg"]}/**/*.{${e}}`).replace(/\\/g,"/")].filter(Boolean),cache:!0,cacheLocation:`${y.lintCachePath}/.stylelintcache`}))}if(I.bar){let e=I.bar,t=e.name||"Build";W.plugins.push(new d.ProgressPlugin({handler(o,r,...i){p(o||0,1,{msg:i.length?`[${r}] ${i.join(" ")}`:"",name:t,barColor:e.barColor,nameColor:e.nameColor,barBgColor:e.barBgColor,msgColor:e.msgColor}),1===o&&process.stdout.write("\r\x1b[2K")}}))}let F=d(W);F.hooks.done.tap("client-log",e=>{k(null,e)});let N={};if(I.devServer.https){let[e,t]=await Promise.all([n(I.devServer.https.key),n(I.devServer.https.cert)]);e||(m(l(`法加载私钥。请检查路径和文件是否存在,并确保路径正确:${I.devServer.https.key}`,"red")),process.exit(1)),t||(m(l(`无法加载证书。请检查路径和文件是否存在,并确保路径正确:${I.devServer.https.cert}`,"red")),process.exit(1)),N.http2=!0,N.https={key:e,cert:t}}let K=u(F,{writeToDisk:!1,index:"index.html",headers:e=>({"Access-Control-Allow-Credentials":"true","Access-Control-Allow-Headers":"DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization","Access-Control-Allow-Methods":"GET, POST, OPTIONS, DELETE, PATCH, PUT",...I.devServer.headers,"Access-Control-Allow-Origin":e.headers.origin||"*","Cache-Control":"no-store, no-cache, must-revalidate, proxy-revalidate",Pragma:"no-cache",Expires:"0"}),serverSideRender:!1,lastModified:!0,publicPath:W.output?.publicPath,cacheControl:!1,cacheImmutable:!1}),X=h(F,{log:!1,path:D,heartbeat:2e3}),J=c({logger:!1,...N});await J.register(s),J.use(K),J.use(D,X),b(J,{directory:y.mockPath}),j(J,I.proxy);let Q=`${W.output.path}/index.html`;function V(){process.exit(0)}J.get("*",async(e,t)=>{if(e.headers.accept?.includes("text/html")){let e=K.context.outputFileSystem,o=e?.readFileSync?.(Q);if(!t.sent){t.type("text/html").send(o);return}}else if(e.url?.endsWith(D)&&"text/event-stream"===e.headers.accept){e.raw.url=D,X(e.raw,t.raw,A);return}}),J.addHook("onClose",()=>{K.close(A),J.server.close(A)}),await J.register(i,{global:!0}),J.listen({port:$});let Y=await Promise.all(x.map(M)),Z=f(Y[0]||{},Y[1]||{});x.forEach(function(t){o(t,async function(){let[o,r]=await Promise.all(x.map(M)),i=f(o||{},r||{}),s=g(Z,i);1===Object.keys(s).length&&"proxy"in s?(a(l(`代理更新中...`,"yellow"),!0),await j(J,i.proxy),a(l(`代理更新完成...`,"green"),!0),I.proxy=i.proxy,Z.proxy=i.proxy,Z=i):(Z=i,m(l(`检测到工程配置${l(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),e("win32"===process.platform?`netstat -ano | findstr :${$}`:`lsof -i :${$} -t`,(e,t)=>{if(e){m(l(`查找端口 ${$} 时发生错误: ${e.message}`,"red")),m(l("请尝试手动重启程序","yellow"));return}let o=t.trim().split("\n").filter(Boolean),r=ee?o[0]?.split(/\s+/).pop()?.trim():o[0]?.trim();if(!r){m(l(`未找到占用端口 ${$} 的进程, 请尝试手动重启程序`,"yellow"));return}try{process.kill(Number(r),"SIGHUP")}catch(e){m(l(`终止进程 ${r} 时发生错误: ${e.message}`,"red"))}}))})});let ee="win32"===process.platform;process.on("SIGHUP",function(){J.close(A),function(){let e=t(process.argv[0],process.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",V)}()}),process.on("exit",function(){J.close(A)}),C(V);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return u}});const t=require("lightningcss"),r=(e=require("../../commom/log.mjs"))&&e.__esModule?e:{default:e},
|
|
1
|
+
"use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return u}});const t=require("lightningcss"),r=(e=require("../../commom/log.mjs"))&&e.__esModule?e:{default:e},s=require("./codegen.cjs"),i=require("./utils.cjs");function o(e,t){return JSON.stringify(e.utils.contextify(e.context||e.rootContext,t))}const l=new TextEncoder,n={Declaration:{custom(e){if("content"===e.name&&1===e.value.length){let t=e.value[0];if("token"===t.type&&"string"===t.value.type)return[{property:e.name,raw:JSON.stringify(t.value.value.replace(/[\u4e00-\u9faF]/g,function(e){return`\\${e.charCodeAt(0).toString(16)}`}))}]}}}};async function u(e,u){let _=this.async();this.cacheable&&this.cacheable();let{implementation:a,visitor:p,rem:c,...f}=this.getOptions(),m=!!f.modules?.auto?.(this.resourcePath);if(m&&void 0===f.modules.namedExport&&(f.modules.namedExport=!0),a&&"function"!=typeof a.transform){_(TypeError(`[lightning-loader]: implementation.transform must be an 'lightningcss' transform function. Received ${typeof a.transform}`));return}let d=[],h=[],R=[],S=[],g=[];f.modules?.exportOnlyLocals!==!0&&h.unshift({type:"api_import",importName:"___CSS_LOADER_API_IMPORT___",url:o(this,require.resolve("./runtime/api.cjs"))});let y=a?.transform?a.transform:t.transform,L=new Map,O=new Map,E=new Map,v=function(e,t,r,s,o,l){let n=new Map,u=!1,_=new Map,a=new Map,p=-1,c=-1;return{Rule:{import(s){let o;if(e.importFilter&&!e.importFilter(s.value.url,s.value.media))return s;let u=s.value.url;c++,l.set(c,u),u=`__MO_LIGHTNINGCSS_LOADER_IMPORT_URL_REPLACE_${c}__`;let _=s.value.media.mediaQueries.length?JSON.stringify(s.value.media.mediaQueries):void 0,a=(0,i.isUrlRequestable)(u);if(a){let e=u.split("!");e.length>1&&(u=e.pop(),o=e.join("!"))}if(!a)return t.push({url:u,media:_}),{type:"ignored",value:""};let p=o?`${o}!${u}`:u,f=n.get(p);if(!f){f=`___CSS_LOADER_AT_RULE_IMPORT_${n.size}___`,n.set(p,f);let t=e.urlHandler(p);r.push({type:"rule_import",importName:f,url:t})}return t.push({importName:f,media:_}),{type:"ignored",value:""}}},Url:t=>(function(t){let l,n=t.url;if(!e.urlFilter(n)||(0,i.isDataUrl)(n))return t;p++,o.set(p,n);let[,c,f]=(n=`__MO_LIGHTNINGCSS_LOADER_URL_REPLACE_${p}__`).split(/(\?)?#/,3),m=n.split("!");m.length>1&&(n=m.pop(),l=m.join("!"));let d=c?"?":"";d+=f?`#${f}`:"",u||(r.push({type:"get_url_import",importName:"___CSS_LOADER_GET_URL_IMPORT___",url:JSON.stringify(require.resolve("./runtime/get-url.cjs")),index:-1}),u=!0);let h=l?`${l}!${n}`:n,R=_.get(h);R||(R=`___CSS_LOADER_URL_IMPORT_${_.size}___`,_.set(h,R),r.push({type:"url",importName:R,url:JSON.stringify(h),index:p}));let S=JSON.stringify({newUrl:h,hash:d,needQuotes:!1}),g=a.get(S);return g||(g=`___CSS_LOADER_URL_REPLACEMENT_${a.size}___`,a.set(S,g),s.push({replacementName:g,importName:R,hash:d,needQuotes:!1})),{loc:t.loc,url:g}})(t)}}({urlHandler:e=>o(this,(0,i.getPreRequester)(this)(f.importLoaders??0)+e),urlFilter:(0,i.getFilter)(f.url,this.resourcePath),importFilter:(0,i.getFilter)(f.import,this.resourcePath),context:this.context},S,h,g,L,E),C=function({apis:e,imports:t,replacements:r,replacedUrls:s,urlHandler:i}){let o=-1,l=-1;return{Declaration:{composes(n){if("unparsed"===n.property)return;let u=n.value.from;if(u?.type!=="file")return;let _=u.value;if(!_)return;o++,s.set(o,_),_=`__MO_LIGHTNINGCSS_LOADER_ICSS_URL_REPLACE_${o}__`;let a=`___CSS_LOADER_ICSS_IMPORT_${t.length}___`;t.push({type:"icss_import",importName:a,icss:!0,url:i(_),index:o}),e.push({importName:a,dedupe:!0,index:o});let p=[];for(let e of n.value.names){l++;let t=`___CSS_LOADER_ICSS_IMPORT_${o}_REPLACEMENT_${l}___`;r.push({replacementName:t,importName:a,localName:e}),p.push(t)}return{property:"composes",value:{loc:n.value.loc,names:p,from:u}}}}}}({apis:S,imports:R,replacements:g,replacedUrls:O,urlHandler:e=>o(this,(0,i.getPreRequester)(this)(f.importLoaders)+e)});try{c&&!n.Length&&(n.Length=function(e){if("px"===e.unit)return{unit:"rem",value:e.value/16}});let{code:t,map:r,exports:o}=y({filename:this.resourcePath,code:l.encode(e),minify:!0,visitor:{...n,...v,...C,...p},cssModules:!!m&&{pattern:f.modules.localIdentName},sourceMap:this.sourceMap,inputSourceMap:this.sourceMap&&u?JSON.stringify(u):void 0,analyzeDependencies:!1,drafts:{customMedia:!0},include:1,errorRecovery:!1,unusedSymbols:[],...f}),a=t.toString();if(o){for(let e in o)if(Object.prototype.hasOwnProperty.call(o,e)){let t=o[e],r=t.name;for(let e of t.composes)r+=` ${e.name}`;d.push({name:e,value:r})}f.modules.getJSON?.({resourcePath:this.resourcePath,exports:d})}if(0!==L.size){let e=this.getResolve({conditionNames:["asset"],mainFields:["asset"],mainFiles:[],extensions:[]});for(let[t,r]of L.entries()){let[s]=r.split(/(\?)?#/,3),o=(0,i.requestify)(s,this.rootContext),l=await (0,i.resolveRequests)(e,this.context,[...new Set([o,r])]);for(let e of h)e.url=e.url.replace(`__MO_LIGHTNINGCSS_LOADER_URL_REPLACE_${t}__`,l??r)}}if(0!==E.size){let e=this.getResolve({conditionNames:["style"],extensions:[".css"],mainFields:["css","style","main","..."],mainFiles:["index","..."],restrictions:[/\.css$/i]});for(let[t,r]of E.entries()){let[s]=r.split(/(\?)?#/,3),o=(0,i.requestify)(s,this.rootContext),l=await (0,i.resolveRequests)(e,this.context,[...new Set([o,r])]);for(let e of h)e.url=e.url.replace(`__MO_LIGHTNINGCSS_LOADER_IMPORT_URL_REPLACE_${t}__`,l??r)}}if(0!==O.size){let e=this.getResolve({conditionNames:["style"],extensions:[],mainFields:["css","style","main","..."],mainFiles:["index","..."]});for(let[t,r]of O.entries()){let[s]=r.split(/(\?)?#/,3),o=(0,i.requestify)(s,this.rootContext),l=await (0,i.resolveRequests)(e,this.context,[...new Set([r,o])]);for(let e of R)e.url=e.url.replace(`__MO_LIGHTNINGCSS_LOADER_ICSS_URL_REPLACE_${t}__`,l??r)}}h.push(...R);let M=(0,s.getImportCode)(h,f),N=(0,s.getModuleCode)({css:a,map:r},S,g,f,this),x=(0,s.getExportCode)(d,g,f),P=`${M}${N}${x}`;_(null,P,r&&JSON.parse(r.toString()))}catch(e){_(e),(0,r.default)(e)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";module.exports=function(e,
|
|
1
|
+
"use strict";module.exports=function(e,a){return(a||(a={}),"string"!=typeof(e=e&&e.__esModule?e.default:e))?"Buffer"===e.type&&e.data?`data:${function(e){let a=(function(e,a=0){return e.slice(a,16).map(e=>e.toString(16).padStart(2,"0")).join("")})(e,0).toLowerCase();for(let[e,f]of Object.entries({"0001000000":"font/ttf","4f54544f":"font/otf","774f4646":"font/woff","774f4632":"font/woff2","89504e470d0a1a0a":"image/png",ffd8ffe0:"image/jpeg",ffd8ffdb:"image/jpeg",ffd8ffee:"image/jpeg",ffd8ffe000104a4649460001:"image/jpeg","ffd8ffe1????457869660000":"image/jpeg","0000000c4a584c200d0a870a":"image/jxl","474946383761":"image/gif","474946383961":"image/gif","49492a00":"image/tif","49492b00":"image/tif","4d4d002a":"image/tiff","4d4d002b":"image/tiff","52494646????????57454250":"image/webp","424d":"image/bmp","00000100":"image/x-icon","69636e73":"image/x-icns","6674797068656963":"image/heic","667479706d":"image/heic",ff4fff51:"image/jp2","0000000c6a5020200d0a870a":"image/jp2","667479704d534e56":"video/mp4","6674797069736f6d":"video/mp4","1a45dfa3":"video/webm","52494646????????41564920":"video/avi","000001ba":"video/mpeg","000001b3":"video/mpeg","464c56":"video/x-flv",494433:"audio/mpeg","4f676753":"audio/ogg","52494646????????57415645":"audio/wav","664c6143":"audio/flac","4d546864":"audio/midi","3026b2758e66cf11a6d900aa0062ce6c":"application/x-ms-asf"}))if(a.startsWith(e))return f;return"unknown"}(e.data)};base64,${btoa(Array.from(e.data,e=>String.fromCharCode(e)).join(""))}`:e:(/^['"].*['"]$/.test(e)&&(e=e.slice(1,-1)),a.hash&&(e+=a.hash),/["'() \t\n]/.test(e)||a.needQuotes)?'"'.concat(e.replace(/"/g,'\\"').replace(/\n/g,"\\n"),'"'):e};
|
|
@@ -4,4 +4,6 @@ type Url = {
|
|
|
4
4
|
type?: string;
|
|
5
5
|
data?: number[];
|
|
6
6
|
};
|
|
7
|
-
declare function
|
|
7
|
+
declare function uint8ArrayToBase64(numberArray: number[]);
|
|
8
|
+
declare function numberArrayToHex(buffer: number[], start?: number);
|
|
9
|
+
declare function getMimeType(buffer: number[]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as t,readFileSync as e}from"node:fs";import{basename as s,resolve as i}from"node:path";import
|
|
1
|
+
import{existsSync as t,readFileSync as e}from"node:fs";import{basename as s,resolve as i}from"node:path";import o from"webpack";export class HtmlPlugin{constructor(t={}){this.AddEntry=/main\.bundle\.js$/,this.faviconPath="",this.name="HtmlPlugin",this.cachedMetaTags=null,this.cachedCustomTags=null,this.options={title:"WebApp",filename:"index.html",inject:"head",...t}}apply(n){n.hooks.compilation.tap(this.name,a=>{a.hooks.processAssets.tap({name:this.name,stage:o.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL},()=>{let h;if(this.options.favicon){let h=i(n.context,this.options.favicon);if(t(h)){let t=s(this.options.favicon),i=e(h);a.emitAsset(t,new o.sources.RawSource(i),{javascriptModule:!1}),this.faviconPath=(a.outputOptions.publicPath||"")+t}else a.warnings.push(new o.WebpackError(`Favicon file ${h} does not exist`))}if(h=this.options.templateContent?this.options.templateContent(this.options):this.options.template?e(i(n.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 o.sources.RawSource(h),{javascriptModule:!1})})})}generateDefaultTemplate(){let t=this.generateMetaTags(),e=this.generateCustomTags();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}">${e.head}</head><body><div id="root"></div>${e.body}</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:o="",inject:n=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}>${o}</${i}>`;"head"===n?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=t.outputOptions.publicPath||"";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(""):"",o=e.js.length?e.js.map(t=>`<script defer ${this.AddEntry.test(t)?'entry="true" ':""}src="${t}"></script>`).join(""):"",n=this.generateCustomTags(),a=t.split("</head>");if(2===a.length){let[t,e]=a,h=e.split("</body>");return"head"===s?`${t}${i}${o}${n.head}</head>${h[0]}${n.body}</body>${h[1]||""}`:`${t}${n.head}</head>${h[0]}${i}${o}${n.body}</body>${h[1]||""}`}return t}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.27.
|
|
3
|
+
"version": "3.27.6",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
50
50
|
"@types/webpack-hot-middleware": "2.25.9",
|
|
51
51
|
"eslint-config-neko": "3.0.3",
|
|
52
|
-
"sass": "1.83.
|
|
52
|
+
"sass": "1.83.1",
|
|
53
53
|
"sass-loader": "16.0.4",
|
|
54
54
|
"solid-refresh": "0.7.5",
|
|
55
55
|
"stylis": "4.3.4",
|
package/typings/global.d.ts
CHANGED
|
@@ -20,9 +20,9 @@ import type {
|
|
|
20
20
|
OverrideResolverOption,
|
|
21
21
|
ProxyConfig,
|
|
22
22
|
VirtualModulePluginOption,
|
|
23
|
-
} from '../lib/index';
|
|
23
|
+
} from '../lib/index.mjs';
|
|
24
24
|
import type { CopyPluginOption } from '../lib/plugin/copy.mjs';
|
|
25
|
-
import type { DonePluginOption } from '../lib/plugin/done';
|
|
25
|
+
import type { DonePluginOption } from '../lib/plugin/done.mjs';
|
|
26
26
|
|
|
27
27
|
import type { BundleAnalyzerOption } from './bundle-analyzer.d';
|
|
28
28
|
|