@moneko/core 3.55.5 → 3.55.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{fileURLToPath as e}from"node:url";import{Worker as s}from"node:worker_threads";export class CompressionPlugin{constructor(t){this.name="CompressionPlugin";let{test:o,algorithm:r="brotli"}=t||{};this.options={test:o,algorithm:r,filename:`[path][base].${"brotli"===r?"br":"gz"}`},this.worker=new s(e(new URL("../worker/compression.mjs",import.meta.url))),this.worker.setMaxListeners(0)}async runCompressionAlgorithm(e,s){return new Promise(t=>{this.worker.postMessage({input:e,filename:s,algorithm:this.options.algorithm}),this.worker.addListener("message",e=>{e[0]===s&&t(Buffer.from(e[1]))})})}async compress(e,s,t){this.worker.removeAllListeners("message");let o=s.getCache(this.name),{RawSource:r}=e.webpack.sources;await Promise.allSettled(Object.keys(t).map(async t=>{let i,a="gzip"===this.options.algorithm?"gzipped":`${this.options.algorithm}ed`,{info:m,source:n}=s.getAsset(t);if(m.compressed||!e.webpack.ModuleFilenameHelpers.matchObject.bind(void 0,this.options)(t)||m.related&&m.related[a])return!1;let p=o.getItemCache(JSON.stringify(`${t}${this.options.algorithm}`),o.getLazyHashedEtag(n)),l=await p.getPromise()||{};if(!l.source){if("function"==typeof n.buffer)i=n.buffer();else{let e=n.source();i=Buffer.isBuffer(e)?e:Buffer.from(e)}if(!l.compressed&&i)try{l.compressed=await this.runCompressionAlgorithm(i,t)}catch(e){s.errors.push(e);return}l.compressed&&(l.source=new r(l.compressed)),await p.storePromise(l)}let h=s.getPath(this.options.filename,{filename:t}),c={compressed:!0};m.immutable&&/(\[name]|\[base]|\[file])/.test(this.options.filename)&&(c.immutable=!0),s.updateAsset(t,n,{related:{[a]:h}}),s.emitAsset(h,l.source,c)}))}apply(e){let s=this.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))}),"development"!==e.options.mode&&e.hooks.done.tap(this.name,()=>{this.worker.terminate()})}}
|
package/lib/plugin/eslint.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fileURLToPath as
|
|
1
|
+
import{fileURLToPath as e}from"node:url";import{Worker as t}from"node:worker_threads";import s from"webpack";class o extends s.WebpackError{constructor(e){super(`[ESLint] ${e}`),this.name="ESLintError",this.stack=""}}export class ESLintPlugin{constructor(s={files:[]}){this.name="ESLintPlugin",this.options=s,this.worker=new t(e(new URL("../worker/eslint.mjs",import.meta.url))),this.worker.setMaxListeners(0)}apply(e){e.hooks.thisCompilation.tap(this.name,t=>{let s=e.modifiedFiles||new Set;t.hooks.finishModules.tap(this.name,e=>{let o=this.options;if(this.options?.lintDirtyModulesOnly){let t=[];for(let o of e){let e=o.resource;s.has(e)&&t.push(e)}o.files=t}let r=e=>{this.report(t,e)};this.worker.off("message",r),this.worker.postMessage({options:o}),this.worker.on("message",r)})}),"development"!==e.options.mode&&e.hooks.done.tap(this.name,()=>{this.worker.terminate()})}report(e,t){t?.length&&e&&(t[0]?.length&&e.warnings.push(new o(t[0])),t[1]?.length&&e.errors.push(new o(t[1])))}}
|
package/lib/plugin/stylelint.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fileURLToPath as t}from"node:url";import{Worker as e}from"node:worker_threads";import r from"webpack";class s extends r.WebpackError{constructor(t){super(`[Stylelint] ${t}`),this.name="StylelintError",this.stack=""}}export class StylelintPlugin{constructor(r={files:[]}){this.name="StylelintPlugin",this.options=r,this.worker=new e(t(new URL("../worker/stylelint.mjs",import.meta.url))),this.worker.setMaxListeners(0)}apply(t){t.hooks.thisCompilation.tap(this.name,t=>{this.worker.postMessage({options:this.options}),this.worker.
|
|
1
|
+
import{fileURLToPath as t}from"node:url";import{Worker as e}from"node:worker_threads";import r from"webpack";class s extends r.WebpackError{constructor(t){super(`[Stylelint] ${t}`),this.name="StylelintError",this.stack=""}}export class StylelintPlugin{constructor(r={files:[]}){this.name="StylelintPlugin",this.options=r,this.worker=new e(t(new URL("../worker/stylelint.mjs",import.meta.url))),this.worker.setMaxListeners(0)}apply(t){t.hooks.thisCompilation.tap(this.name,t=>{let e=e=>{this.report(e,t)};this.worker.off("message",e),this.worker.postMessage({options:this.options}),this.worker.on("message",e)}),"development"!==t.options.mode&&t.hooks.done.tap(this.name,()=>{this.worker.terminate()})}report(t,e){t?.length&&e&&(t[0]?.length&&e.warnings.push(new s(t[0])),t[1]?.length&&e.errors.push(new s(t[1])))}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isUint8Array as e}from"node:util/types";import{parentPort as r}from"node:worker_threads";import{compression as o}from"@moneko/utils";r?.setMaxListeners(0),r?.on("message",async({input:s,filename:t,algorithm:m})=>{let f=o(Buffer.isBuffer(s)||e(s)?Array.from(s):s,m);r?.postMessage([t,f])});
|