@moneko/core 3.36.3 → 3.37.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/build/common.mjs +1 -1
- package/lib/common.mjs +1 -1
- package/lib/module.config.mjs +2 -2
- package/lib/plugin/compression.d.mts +17 -0
- package/lib/plugin/compression.mjs +1 -0
- package/lib/plugin/copy.d.mts +5 -1
- package/lib/plugin/copy.mjs +1 -1
- package/lib/plugin/lightningcss-plugin.d.mts +5 -0
- package/lib/plugin/lightningcss-plugin.mjs +1 -1
- package/lib/plugin/swc-minify-plugin.d.mts +5 -1
- package/lib/plugin/swc-minify-plugin.mjs +1 -1
- package/lib/plugin/virtual-module.d.mts +2 -2
- package/lib/plugins.config.d.mts +1 -1
- package/lib/plugins.config.mjs +1 -1
- package/package.json +7 -8
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
|
|
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 m}from"../config.mjs";import{LightningCssMinifyPlugin as r}from"../plugin/lightningcss-plugin.mjs";import s from"../plugin/swc-minify-plugin.mjs";import{getLightningCssTargets as l}from"../polyfills/targets.mjs";let o=[];m.minifier&&(o.push(new s(m.minifier)),o.push(new r({targets:l()})));let p={maxAssetSize:256e3,maxEntrypointSize:256e3,assetFilter:e=>!e.endsWith(".map")&&!e.endsWith("ce28377f3a428346.js"),...m.performance},a=n(t,{performance:m.performance&&p,plugins:[new e({filename:"style/[contenthash].css",chunkFilename:"style/[contenthash].css",ignoreOrder:!0})],optimization:{splitChunks:m.splitChunk,runtimeChunk:m.runtimeChunk,chunkIds:"deterministic",moduleIds:"deterministic",concatenateModules:!0,emitOnErrors:!1,removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,minimize:!0,minimizer:o}});if(m.splitChunk&&a.plugins?.push(new i.optimize.MinChunkSizePlugin({minChunkSize:51200})),m.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",...m.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 n,CUSTOMCONFIG as a}from"./commom/paths.mjs";import i from"./commom/require.mjs";import 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 h,PUBLICPATH as f}from"./config.mjs";import d from"./plugins.config.mjs";import{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/[
|
|
1
|
+
import{extname as e,join as t,resolve as o}from"node:path";import s,{config_files as n,CUSTOMCONFIG as a}from"./commom/paths.mjs";import i from"./commom/require.mjs";import 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 h,PUBLICPATH as f}from"./config.mjs";import d from"./plugins.config.mjs";import{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:!0,publicPath:f,asyncChunks:!0,charset:!0,iife:!0,crossOriginLoading:"anonymous",enabledWasmLoadingTypes:["fetch"],hotUpdateChunkFilename:"[id].[fullhash].hot.js",hotUpdateMainFilename:"[runtime].[fullhash].hot.json"};let v={main:[m("@app/entry")]};if(h.polyfill&&v.main.unshift(t(s.corePath,"./polyfills/replace-children.mjs")),g&&h.refresh&&h.env.injectRemoteReactRefresh&&v.main.unshift(i.resolve("@moneko/react/lib/injectRemoteReactRefresh.js")),h.entry&&("string"==typeof h.entry?v={main:[h.entry]}:Object.keys(h.entry)&&(v=Object.assign(v,h.entry))),"string"==typeof v.main&&(v.main=[v.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 C={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:s.webpackCachePath,memoryCacheUnaffected:!0,name:`.${[a,y].filter(Boolean).join("-")}`,version:`${j.version}`,buildDependencies:{config:n}};!1===h.cache?C=!1:l(h.cache)&&(C=Object.assign(C,h.cache));export const commonConfig={name:"client",target:"web",devtool:h.devtool,entry:v,mode:g?"development":"production",stats:"errors-only",cache:C,snapshot:{immutablePaths:[/node_modules\/(?!(@app|@moneko)\/)/],managedPaths:[/^@app\/.+/,/^@moneko\/.+/],buildDependencies:{timestamp:!0,hash:!0}},infrastructureLogging:{level:"error"},externalsPresets:h.externalsPresets,plugins:d,node:{global:!1,__filename:!1,__dirname:!1},experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:h.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(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};h.overrideResolve&&commonConfig.resolve.plugins.push(new r(Object.assign({original:h.alias["@"],override:a&&p(a)},h.overrideResolve)));
|
package/lib/module.config.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let e;import{join as s,sep as o}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
|
|
2
|
-
`)}:void 0},importLoaders:2}},O={loader:d.lessLoader,options:{sourceMap:!!P.sourceMap,lessOptions:{modifyVars:c,javascriptEnabled:!0}}},b=new Map;function C(e){if(b.has(e))return b.get(e);try{let s;let t=
|
|
1
|
+
let e;import{join as s,sep as o}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 d from"./options/reslove.mjs";import p 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 y from"./utils/svg-to-data-uri.mjs";import{comment as g,getCommentPath as v}from"./vm/docs.mjs";import x from"./vm/generate-doc.mjs";import{outputConfig as w}from"./common.mjs";import{CONFIG as P}from"./config.mjs";import{FRAMEWORK as L,isDev as k,isLibrary as M}from"./process-env.mjs";let _={loader:s(r.corePath,"/loader/lightning-css/loader.cjs"),options:{sourceMap:!!P.sourceMap,targets:u(),rem:!!P.rem,esModule:!0,modules:{auto(e){if(e){if(e.endsWith(".css")&&!e.endsWith("module.css"))return!1;for(let s=0,o=I.length;s<o;s++)if(e.includes(I[s]))return m.css_module.test(e)}return m.node_modules_css_module.test(e)},localIdentName:"[hash]_[local]",namedExport:!0,exportLocalsConvention:"dashesOnly",exportOnlyLocals:!1,getJSON:P.cssModuleDefinition?function(e){q.setData(`${e.resourcePath}.d.ts`,`${e.exports.map(({name:e,value:s})=>`export const ${j(e)}: '${s}';`).join("\n")}
|
|
2
|
+
`)}:void 0},importLoaders:2}},O={loader:d.lessLoader,options:{sourceMap:!!P.sourceMap,lessOptions:{modifyVars:c,javascriptEnabled:!0}}},b=new Map;function C(e){if(b.has(e))return b.get(e);try{let s;let t=i.resolve(e).split(o),r=t.lastIndexOf("node_modules");return s=-1!==r?t.slice(0,r).join(o):t.join(o),b.set(e,[s]),[s]}catch{try{let s=i.resolve(`${e}${o}package.json`).replace(`${o}package.json`,"");b.set(e,[s])}catch{b.set(e,[f(e),f(`.pnpm/${e}`)])}return b.get(e)}}let I=[...P.cssModules,`@moneko/${L}`,"neko-ui"].map(C).flat(),$=["components","example","mock","site","src","server"].map(h);function B(e){return new Promise(s=>{s([...$,r.corePath,...P.rulesInclude?.[e]?.map(C).flat()||[]])})}a&&$.push(h(a)),P.overrideResolve&&P.overrideResolve.override&&$.push(P.overrideResolve.override);let J=await Promise.all([B("css"),B("js"),B("media"),B("wasm"),B("font")]),W=J[0],R=J[1],N=J[2],S=J[3],z=J[4];d.sassLoader&&(e={loader:d.sassLoader,options:{implementation:await import("sass"),sassOptions:{}}});let D=M&&k&&{test:m.tsdoc,include:P.alias["@pkg"],exclude:[/node_modules\/(?!(@app|@moneko)).+/,m.__tests__],enforce:"pre",loader:s(r.corePath,"/loader/ts-doc.cjs"),options:{comment:g,generateDoc:x,getCommentPath:v}},E=w.library?.type==="umd"&&!1===P.htmlPluginOption,Q=[{resourceQuery:/raw/i,type:"asset/source"},{resourceQuery:/url/i,type:"asset/resource",generator:{filename(e){let s=e.filename;return s&&s.toLocaleLowerCase().endsWith("wasm?url")?"wasm/[hash][ext]":"assets/[hash][ext]"}}},{test:m.wasm,type:"webassembly/async",include:S},{test:m.txt,type:"asset/source"},{test:m.image,type:"asset",dependency:{not:["url"]},parser:{dataUrlCondition:E?()=>!0:{maxSize:4096}},generator:{filename:e=>e.filename?.toLocaleLowerCase().endsWith(".svg")?"assets/svg/[hash][ext]":"assets/images/[hash][ext]",dataUrl:(e,s)=>s.filename.toLocaleLowerCase().endsWith(".svg")?y(e.toString()):e},include:N},{test:m.video,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/video/[hash][ext]"},include:N},{test:m.font,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/fonts/[hash][ext]"},include:z}],U=P.prefixJsLoader.filter(Boolean)||[];switch(L){case"react":P.reactCompiler&&U.unshift({loader:s(r.corePath,"/loader/react-compiler.cjs"),options:P.reactCompiler});break;case"solid":P.refresh=!1}P.cssInJs&&"object"==typeof P.cssInJs.minify&&U.unshift({loader:s(r.corePath,"/loader/css-in-js-minify.cjs"),options:Object.assign({moduleName:"@moneko/css",allowFuncs:["css","injectGlobal"]},P.cssInJs.minify)});let q=new n({});q.on("change",(e,s)=>{t(e,s)});export default(o=>{let t={loader:d.swcLoader,options:p(o)};return{parser:{javascript:{commonjsMagicComments:!0,dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,importMeta:!0,importMetaContext:!0}},noParse:P.noParse,rules:[!1!==P.htmlPluginOption&&D,{oneOf:[...Q,{test:m.js,use:[...U,t].filter(Boolean),include:R},{test:m.css,use:[l,_],include:W},e&&{test:m.scss,use:[l,_,e],include:W},{test:m.less,use:[l,_,O],include:W},{test:m.markdown,use:[...U,{loader:s(r.corePath,"/loader/mdx.cjs"),options:P.mdx}].filter(Boolean),exclude:[/node_modules\/(?!(@app|@moneko)).+/]}].filter(Boolean)},...P.moduleRules].filter(Boolean)}});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { compression } from '@moneko/utils';
|
|
2
|
+
import { type AssetInfo, type Compilation, type Compiler, type sources, type WebpackError } from 'webpack';
|
|
3
|
+
type Source = sources.Source;
|
|
4
|
+
interface CompressionPluginOptions {
|
|
5
|
+
test: RegExp;
|
|
6
|
+
algorithm: 'gzip' | 'deflate' | 'brotliCompress';
|
|
7
|
+
filename: string;
|
|
8
|
+
}
|
|
9
|
+
declare class CompressionPlugin {
|
|
10
|
+
private name: string;
|
|
11
|
+
private options: CompressionPluginOptions;
|
|
12
|
+
constructor(options: CompressionPluginOptions);
|
|
13
|
+
private runCompressionAlgorithm(input: Buffer): Buffer;
|
|
14
|
+
async compress(compiler: Compiler, compilation: Compilation, assets: Record<string, Source>);
|
|
15
|
+
apply(compiler: Compiler);
|
|
16
|
+
}
|
|
17
|
+
export default CompressionPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{compression as e}from"@moneko/utils";export default class{constructor(e){this.name="compression-plugin";let{test:s,algorithm:t="gzip",filename:o="[path][base].gz"}=e||{};this.options={test:s,algorithm:t,filename:o}}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 n=o.getItemCache(JSON.stringify({name:t,algorithm:this.options.algorithm}),o.getLazyHashedEtag(p)),l=await n.getPromise()||{};if(!l.source){if("function"==typeof p.buffer)r=p.buffer();else{let e=p.source();r=Buffer.isBuffer(e)?e:Buffer.from(e)}if(!l.compressed&&r)try{l.compressed=this.runCompressionAlgorithm(r)}catch(e){s.errors.push(e);return}l.compressed&&(l.source=new i(l.compressed)),await n.storePromise(l)}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,l.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))})}}
|
package/lib/plugin/copy.d.mts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { statSync } from 'node:fs';
|
|
1
2
|
import { resolve } from 'node:path';
|
|
2
3
|
import { loadFileRaw, scanFolderSync } from '@moneko/utils';
|
|
3
|
-
import webpack, { type Compiler } from 'webpack';
|
|
4
|
+
import webpack, { type Compiler, type sources } from 'webpack';
|
|
5
|
+
import log from '../commom/log.mjs';
|
|
4
6
|
export interface CopyPluginOption {
|
|
5
7
|
files?: string[];
|
|
6
8
|
dirs?: string[];
|
|
@@ -11,7 +13,9 @@ export declare class CopyPlugin {
|
|
|
11
13
|
private readonly baseFiles: Set<string>;
|
|
12
14
|
private readonly dirs: Set<string>;
|
|
13
15
|
private cacheFiles: string[];
|
|
16
|
+
private fileTimestamps: Map<string, number>;
|
|
14
17
|
constructor(option: CopyPluginOption);
|
|
15
18
|
private getFiles();
|
|
19
|
+
private hasFileChanged(filePath: string): boolean;
|
|
16
20
|
apply(compiler: Compiler);
|
|
17
21
|
}
|
package/lib/plugin/copy.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{statSync as e}from"node:fs";import{resolve as t}from"node:path";import{loadFileRaw as s,scanFolderSync as i}from"@moneko/utils";import a from"webpack";import l from"../commom/log.mjs";let o="CopyPlugin",m=a.sources.RawSource;export class CopyPlugin{constructor(e){this.cacheFiles=[],this.fileTimestamps=new Map,this.baseFiles=new Set(e.files?.map(e=>t(e))||[]),this.dirs=new Set(e.dirs||[])}getFiles(){let e=new Set(this.baseFiles);for(let t of this.dirs)i(t,["\\.*"]).forEach(t=>e.add(t));let t={deleted:[],files:[...e]};for(let s of new Set(this.cacheFiles))e.has(s)||t.deleted.push(s);return this.cacheFiles=t.files,t}hasFileChanged(t){try{let s=e(t).mtimeMs,i=this.fileTimestamps.get(t)||0;return this.fileTimestamps.set(t,s),s>i}catch(e){return l(e),!0}}apply(e){e.hooks.thisCompilation.tap({name:o,stage:e.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS},e=>{let t=e.getCache(o);e.hooks.processAssets.tapPromise(o,async()=>{let i=this.getFiles();await Promise.all(i.files.map(async i=>{let a=this.hasFileChanged(i),l=t.getItemCache(i,null),o=await l.getPromise();if(o&&!a){e.emitAsset(i,o.source);return}let r=await s(i);if(null!==r){let t=new m(Buffer.from(r));await l.storePromise({source:t,timestamp:this.fileTimestamps.get(i)}),e.emitAsset(i,t)}})),i.deleted.forEach(t=>{e.deleteAsset(t),this.fileTimestamps.delete(t)})})})}}
|
|
@@ -17,6 +17,11 @@ interface MinifyPluginOpts {
|
|
|
17
17
|
exclude?: Filter | Filter[];
|
|
18
18
|
targets?: Targets;
|
|
19
19
|
}
|
|
20
|
+
interface CacheItem {
|
|
21
|
+
source: sources.Source;
|
|
22
|
+
map?: string | object | Buffer;
|
|
23
|
+
minimized: boolean;
|
|
24
|
+
}
|
|
20
25
|
export declare class LightningCssMinifyPlugin {
|
|
21
26
|
private readonly options: Omit<MinifyPluginOpts, 'implementation'>;
|
|
22
27
|
private readonly transform: Implementation['transform'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Buffer as s}from"node:buffer";import{transform as
|
|
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:p,exclude:c,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:p,exclude:c},s.name));await Promise.all(d.map(async i=>{let a;let r=h.getItemCache(JSON.stringify({name:i.name,sourceMap:l,transformOptions:u}),h.getLazyHashedEtag(i.source)),m=await r.getPromise();if(m&&m.minimized){e.updateAsset(i.name,m.source,{...i.info,minimized:!0});return}let p=i.source.source(),c="string"==typeof p?t.encode(p):p,f=this.transform({filename:i.name,code:c,minify:!0,sourceMap:l,...u}),d=s.from(f.code),g={source:a=l?new n(d,i.name,f.map||"",p,f.map||"",!0):new o(d),map:f.map||void 0,minimized:!0};await r.storePromise(g),e.updateAsset(i.name,a,{...i.info,minimized:!0})}))}}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { type JsMinifyOptions, minify } from '@swc/core';
|
|
2
|
-
import webpack, { type Compiler } from 'webpack';
|
|
2
|
+
import webpack, { type Compilation, type Compiler, type sources, type WebpackError } from 'webpack';
|
|
3
|
+
interface CacheItem {
|
|
4
|
+
source: sources.RawSource;
|
|
5
|
+
minimized: boolean;
|
|
6
|
+
}
|
|
3
7
|
declare class SwcMinifyPlugin {
|
|
4
8
|
private name: string;
|
|
5
9
|
private options: JsMinifyOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{minify as e}from"@swc/core";import
|
|
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(o){o.hooks.compilation.tap(this.name,o=>{o.hooks.processAssets.tapAsync({name:this.name,stage:s.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,additionalAssets:!0},async(t,i)=>{let r=o.getCache(this.name),n=Object.keys(t).filter(e=>e.endsWith(".js")&&!e.endsWith(".min.js"));try{await Promise.all(n.map(async t=>{let i;let n=o.getAsset(t);if(!n||n.info.minimized)return;let a=r.getItemCache(JSON.stringify(this.options),r.getLazyHashedEtag(n.source)),c=await a.getPromise();if(c&&c.minimized){o.updateAsset(t,c.source,{minimized:!0});return}if("function"==typeof n.source.buffer)i=n.source.buffer();else{let e=n.source.source();i=Buffer.isBuffer(e)?e:Buffer.from(e)}try{let{code:r}=await e(i.toString().replace(/\r\n/g,"\n"),this.options),n={source:new s.sources.RawSource(r),minimized:!0};await a.storePromise(n),o.updateAsset(t,n.source,{minimized:!0})}catch(e){o.errors.push(e)}})),i()}catch(e){i(e)}})})}}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Compiler } from 'webpack';
|
|
1
|
+
import type { Compiler, WebpackPluginInstance } from 'webpack';
|
|
2
2
|
import VirtualModulesPlugin from 'webpack-virtual-modules';
|
|
3
3
|
import parseModuleMeta from '../commom/parse-module-meta.mjs';
|
|
4
4
|
import paths from '../commom/paths.mjs';
|
|
@@ -14,7 +14,7 @@ export interface VirtualModulePluginOption {
|
|
|
14
14
|
[key: string]: string | object;
|
|
15
15
|
}
|
|
16
16
|
declare const PLUGIN_NAME: string;
|
|
17
|
-
export declare class VirtualModuleWebpackPlugin {
|
|
17
|
+
export declare class VirtualModuleWebpackPlugin implements WebpackPluginInstance {
|
|
18
18
|
private virtualModules: VirtualModulesPlugin;
|
|
19
19
|
private options: Record<string, string>;
|
|
20
20
|
private init: boolean;
|
package/lib/plugins.config.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import CompressionPlugin from 'compression-webpack-plugin';
|
|
2
1
|
import webpack, { type WebpackPluginInstance } from 'webpack';
|
|
2
|
+
import CompressionPlugin from './plugin/compression.mjs';
|
|
3
3
|
import { CopyPlugin } from './plugin/copy.mjs';
|
|
4
4
|
import { HtmlMeta, HtmlPlugin } from './plugin/html-plugin.mjs';
|
|
5
5
|
import moduleFederation from './plugin/module-federation.mjs';
|
package/lib/plugins.config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"
|
|
1
|
+
import e from"webpack";import t from"./plugin/compression.mjs";import{CopyPlugin as i}from"./plugin/copy.mjs";import{HtmlPlugin as o}from"./plugin/html-plugin.mjs";import r from"./plugin/module-federation.mjs";import{VirtualModuleWebpackPlugin as l}from"./plugin/virtual-module.mjs";import{CONFIG as n}from"./config.mjs";import{isDev as p,packageJson as a}from"./process-env.mjs";let s=[...r,new l(n.virtualModule),new i(n.copy),new e.DefinePlugin({"process.env":JSON.stringify(n.env)}),new e.IgnorePlugin({resourceRegExp:/\/(__(tests|mocks)__|test|spec|e2e)\//}),...n.plugins,p&&new t({filename:"[path][base].gz",algorithm:"gzip",test:/\.(js|css|html|svg)$/})].filter(Boolean);if(n.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:a.description,keywords:Array.isArray(a.keywords)?a.keywords.toString():"","http-equiv":"refresh",viewport:"width=device-width, initial-scale=1"};n.seo&&(e.relCanonical={rel:"canonical",href:`https://${n.seo.domain}${n.basename}`}),n.htmlPluginOption.meta&&Object.assign(e,n.htmlPluginOption.meta),s.push(new o({...n.htmlPluginOption,meta:e}))}if(n.fixBrowserRouter){let e=n.basename.split("/").filter(Boolean).length,t=`${Array(e).fill("..").join("/")+(e?"/":"")}404.html`,i=n.fixBrowserRouter.pathSegmentsToKeep??e;s.push(new o({filename:n.fixBrowserRouter.path??t,inject:!1,templateContent:()=>`<html lang="en"><head><title>Redirect</title><script>const pathKeep = ${i};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>`}))}n.sourceMap&&s.push(new e.SourceMapDevToolPlugin(n.sourceMap));export default s;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.37.0",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -18,16 +18,15 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@fastify/http-proxy": "9.5.0",
|
|
20
20
|
"@moneko/convert": "1.0.0",
|
|
21
|
-
"@moneko/eslint": "1.
|
|
21
|
+
"@moneko/eslint": "1.3.0",
|
|
22
22
|
"@moneko/mdx": "0.1.44",
|
|
23
23
|
"@moneko/raw-import": "0.0.3",
|
|
24
|
-
"@moneko/stylelint": "1.
|
|
24
|
+
"@moneko/stylelint": "1.3.0",
|
|
25
25
|
"@moneko/transform-imports": "0.6.1",
|
|
26
|
-
"@moneko/utils": "0.1
|
|
26
|
+
"@moneko/utils": "0.2.1",
|
|
27
27
|
"@swc/core": "1.6.13",
|
|
28
28
|
"browserslist": "4.24.4",
|
|
29
29
|
"chokidar": "4.0.3",
|
|
30
|
-
"compression-webpack-plugin": "11.1.0",
|
|
31
30
|
"core-js": "3.41.0",
|
|
32
31
|
"core-js-compat": "3.41.0",
|
|
33
32
|
"fastify": "4.29.0",
|
|
@@ -40,7 +39,7 @@
|
|
|
40
39
|
"style-loader": "4.0.0",
|
|
41
40
|
"swc-loader": "0.2.6",
|
|
42
41
|
"typescript": "5.8.3",
|
|
43
|
-
"webpack": "5.
|
|
42
|
+
"webpack": "5.99.1",
|
|
44
43
|
"webpack-hot-middleware": "2.26.1",
|
|
45
44
|
"webpack-merge": "6.0.1",
|
|
46
45
|
"webpack-virtual-modules": "0.6.2"
|
|
@@ -51,8 +50,8 @@
|
|
|
51
50
|
"@types/stylis": "4.2.7",
|
|
52
51
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
53
52
|
"@types/webpack-hot-middleware": "2.25.9",
|
|
54
|
-
"babel-plugin-react-compiler": "19.0.0-beta-e993439-
|
|
55
|
-
"sass": "1.86.
|
|
53
|
+
"babel-plugin-react-compiler": "19.0.0-beta-e993439-20250405",
|
|
54
|
+
"sass": "1.86.3",
|
|
56
55
|
"sass-loader": "16.0.5",
|
|
57
56
|
"solid-refresh": "0.7.5",
|
|
58
57
|
"stylis": "4.3.6",
|