@moneko/core 3.36.3-beta.0 → 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.
@@ -1 +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{info:a,source:m}=s.getAsset(t),p="gzip"===this.options.algorithm?"gzipped":`${this.options.algorithm}ed`;if(a.compressed||!e.webpack.ModuleFilenameHelpers.matchObject.bind(void 0,this.options)(t)||a.related&&a.related[p])return!1;let n=o.getItemCache(JSON.stringify({name:t,algorithm:this.options.algorithm}),o.getLazyHashedEtag(m)),l=await n.getPromise();if(!l.source){if("function"==typeof m.buffer)r=m.buffer();else{let e=m.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 f=s.getPath(this.options.filename,{filename:t}),c={compressed:!0};a.immutable&&"string"==typeof this.options.filename&&/(\[name]|\[base]|\[file])/.test(this.options.filename)&&(c.immutable=!0),s.updateAsset(t,m,{related:{[p]:f}}),s.emitAsset(f,l.source,c)}))}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
+ 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))})}}
@@ -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
  }
@@ -1 +1 @@
1
- import{resolve as e}from"node:path";import{loadFileRaw as s,scanFolderSync as t}from"@moneko/utils";import i from"webpack";let o="CopyPlugin",l=i.sources.RawSource;export class CopyPlugin{constructor(s){this.cacheFiles=[],this.baseFiles=new Set(s.files?.map(s=>e(s))||[]),this.dirs=new Set(s.dirs||[])}getFiles(){let e=new Set(this.baseFiles);for(let s of this.dirs)t(s,["\\.*"]).forEach(s=>e.add(s));let s={deleted:[],files:[...e]};for(let t of new Set(this.cacheFiles))e.has(t)||s.deleted.push(t);return this.cacheFiles=s.files,s}apply(e){e.hooks.thisCompilation.tap({name:o,stage:e.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS},e=>{e.hooks.processAssets.tapPromise(o,async()=>{let t=this.getFiles();(await Promise.all(t.files.map(e=>s(e)))).forEach((s,i)=>{null!==s&&e.emitAsset(t.files[i],new l(Buffer.from(s)))}),t.deleted.forEach(s=>{e.deleteAsset(s)})})})}}
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 t}from"lightningcss";import i from"webpack";let o=new TextEncoder,e=i.sources.RawSource,n=i.sources.SourceMapSource,r=i.ModuleFilenameHelpers.matchObject,a="lightning-css-minify",m=/\.(c|le|sc|sa)ss(?:\?.*)?$/i;export class LightningCssMinifyPlugin{constructor(s={}){let{implementation:i,...o}=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??t,this.options=o}apply(s){let t=JSON.stringify({name:a,version:"0.0.1",options:this.options});s.hooks.compilation.tap(a,s=>{s.hooks.chunkHash.tap(a,(s,i)=>i.update(t)),s.hooks.processAssets.tapPromise({name:a,stage:i.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,additionalAssets:!0},async()=>await this.transformAssets(s)),s.hooks.statsPrinter.tap(a,s=>{s.hooks.print.for("asset.info.minimized").tap(a,(s,{green:t,formatFlag:i})=>s?t(i("minimized")):void 0)})})}async transformAssets(t){let{options:{devtool:i}}=t.compiler,{include:a,exclude:p,test:c,sourceMap:f=void 0===this.options.sourceMap?!!(i&&i.includes("source-map")):this.options.sourceMap,...l}=this.options,h=t.getAssets().filter(s=>!s.info.minimized&&(c||m).test(s.name)&&r({include:a,exclude:p},s.name));await Promise.all(h.map(async i=>{let r;let a=i.source.source(),m="string"==typeof a?o.encode(a):a,p=this.transform({filename:i.name,code:m,minify:!0,sourceMap:f,...l}),c=s.from(p.code);r=f?new n(c,i.name,p.map||"",a,p.map||"",!0):new e(c),t.updateAsset(i.name,r,{...i.info,minimized:!0})}))}}
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 o 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(s){s.hooks.compilation.tap(this.name,s=>{s.hooks.processAssets.tapAsync({name:this.name,stage:o.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,additionalAssets:!0},async(t,a)=>{let n=Object.keys(t).filter(e=>e.endsWith(".js")&&!e.endsWith(".min.js"));try{await Promise.all(n.map(async t=>{let a=s.getAsset(t);if(a){let n=a.source.source().toString().replace(/\r\n/g,"\n"),{code:i}=await e(n,this.options);s.updateAsset(t,new o.sources.RawSource(i))}})),a()}catch(e){a(e)}})})}}
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.36.3-beta.0",
3
+ "version": "3.37.0",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",
@@ -18,10 +18,10 @@
18
18
  "dependencies": {
19
19
  "@fastify/http-proxy": "9.5.0",
20
20
  "@moneko/convert": "1.0.0",
21
- "@moneko/eslint": "1.2.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.2.1",
24
+ "@moneko/stylelint": "1.3.0",
25
25
  "@moneko/transform-imports": "0.6.1",
26
26
  "@moneko/utils": "0.2.1",
27
27
  "@swc/core": "1.6.13",
@@ -39,7 +39,7 @@
39
39
  "style-loader": "4.0.0",
40
40
  "swc-loader": "0.2.6",
41
41
  "typescript": "5.8.3",
42
- "webpack": "5.98.0",
42
+ "webpack": "5.99.1",
43
43
  "webpack-hot-middleware": "2.26.1",
44
44
  "webpack-merge": "6.0.1",
45
45
  "webpack-virtual-modules": "0.6.2"
@@ -50,8 +50,8 @@
50
50
  "@types/stylis": "4.2.7",
51
51
  "@types/webpack-bundle-analyzer": "4.7.0",
52
52
  "@types/webpack-hot-middleware": "2.25.9",
53
- "babel-plugin-react-compiler": "19.0.0-beta-e993439-20250328",
54
- "sass": "1.86.2",
53
+ "babel-plugin-react-compiler": "19.0.0-beta-e993439-20250405",
54
+ "sass": "1.86.3",
55
55
  "sass-loader": "16.0.5",
56
56
  "solid-refresh": "0.7.5",
57
57
  "stylis": "4.3.6",