@moneko/core 4.1.0 → 4.1.1
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-dev.mjs +2 -2
- package/lib/build.mjs +2 -2
- package/lib/dev.mjs +1 -1
- package/lib/loader/css-in-js-minify.cjs +1 -1
- package/lib/loader/react-compiler.cjs +1 -1
- package/lib/loader/solid.cjs +1 -1
- package/lib/plugin/compression.mjs +1 -1
- package/lib/plugin/eslint.mjs +1 -1
- package/lib/plugin/stylelint.mjs +1 -1
- package/package.json +1 -1
package/lib/build-dev.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{relative as o}from"node:path";import r from"node:process";import{analyzeBundleSize as e,completedInfo as t,ink as m,println as i,progressBar as
|
|
2
|
-
`):(
|
|
1
|
+
import{relative as o}from"node:path";import r from"node:process";import{analyzeBundleSize as e,completedInfo as t,ink as m,println as i,progressBar as a}from"@moneko/utils";import n from"webpack";import s from"./commom/log.mjs";import l from"./commom/paths.mjs";import{CONFIG as p}from"./config.mjs";import{createDevelopmentConfiguration as c}from"./create-development-configuration.mjs";let g=await c({});if(p.bar){let o=p.bar,e=o.name||"Build";g.plugins.push(new n.ProgressPlugin({handler(t,m,...i){let n=i.length?`[${m}] ${i.join(" ")}`:" ";o.quiet?r.stdout.write(`${n}
|
|
2
|
+
`):(a(t||0,1,{msg:n,name:e,barColor:o.barColor,nameColor:o.nameColor,barBgColor:o.barBgColor,msgColor:o.msgColor}),1===t&&r.stdout.write("\r\x1b[2K"))}}))}let u=n(g);async function d(){let r=await new Promise((o,r)=>{u?.run((e,t)=>{e&&r(e),t?o(t):r(Error("编译过程中没有生成统计信息"))})});(r.hasErrors()||r.hasWarnings())&&function(o){let{warnings:r,errors:e}=o.compilation,t=[];r.forEach(o=>{o.message.includes("Conflicting order between css ./node_modules/")&&o.message.includes("monaco-editor")?t.push(o.message):i(m(o.message,"178"))}),t.length&&s(t.join("\n")),e.forEach(o=>{i(m(o.message,"red"))})}(r),await new Promise(a=>{r.compilation.compiler.cache.shutdown(n=>{n&&i(m(n.toString(),"red")),e(r.compilation.outputOptions.path,["\\.js$"]),t(~~((r.endTime-r.startTime)/10)/100,o(l.programPath,r.compilation.outputOptions.path)),a()})})}await d();
|
package/lib/build.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{relative as o}from"node:path";import r from"node:process";import{analyzeBundleSize as m,completedInfo as e,ink as
|
|
2
|
-
`):(s(e||0,1,{msg:n,name:m,barColor:o.barColor,nameColor:o.nameColor,barBgColor:o.barBgColor,msgColor:o.msgColor}),1===e&&r.stdout.write("\r\x1b[2K"))}}))}let
|
|
1
|
+
import{relative as o}from"node:path";import r from"node:process";import{analyzeBundleSize as m,completedInfo as e,ink as t,println as i,progressBar as s}from"@moneko/utils";import n from"webpack";import{merge as a}from"webpack-merge";import l from"./build/common.mjs";import p from"./commom/log.mjs";import u from"./commom/paths.mjs";import{DonePlugin as g}from"./plugin/done.mjs";import c from"./utils/seo.mjs";import{CONFIG as d}from"./config.mjs";import f from"./module.config.mjs";let h=a(l,{module:f(!1),plugins:[]});if(d.done&&h.plugins.push(new g({done:d.done})),d.bar){let o=d.bar,m=o.name||"Build";h.plugins.push(new n.ProgressPlugin({handler(e,t,...i){let n=i.length?`[${t}] ${i.join(" ")}`:" ";o.quiet?r.stdout.write(`${n}
|
|
2
|
+
`):(s(e||0,1,{msg:n,name:m,barColor:o.barColor,nameColor:o.nameColor,barBgColor:o.barBgColor,msgColor:o.msgColor}),1===e&&r.stdout.write("\r\x1b[2K"))}}))}let w=n(h);if(!w)throw Error("无法创建编译器");async function b(){let r=await new Promise((o,r)=>{w?.run((m,e)=>{m&&r(m),e?o(e):r(Error("编译过程中没有生成统计信息"))})});(r.hasErrors()||r.hasWarnings())&&function(o){let{warnings:r,errors:m}=o.compilation,e=[];r.forEach(o=>{o.message.includes("Conflicting order between css ./node_modules/")&&o.message.includes("monaco-editor")?e.push(o.message):i(t(o.message,"178"))}),e.length&&p(e.join("\n")),m.forEach(o=>{i(t(o.message,"red"))})}(r),await new Promise(s=>{r.compilation.compiler.cache.shutdown(n=>{n&&i(t(n.toString(),"red")),m(r.compilation.outputOptions.path,["\\.js$"]),e(~~((r.endTime-r.startTime)/10)/100,o(u.programPath,r.compilation.outputOptions.path)),s()})}),d.seo&&c()}await b();
|
package/lib/dev.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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 i from"node:process";import{URL as s}from"node:url";import{ink as n,print as a,println as m,progressBar as l}from"@moneko/utils";import p from"webpack";import c from"webpack-hot-middleware";import{merge as f}from"webpack-merge";import{diffObject as h}from"./commom/diff-object.mjs";import d,{config_files as u}from"./commom/paths.mjs";import g from"./commom/rule.mjs";import w from"./commom/sigint-exit.mjs";import{devLog as y,PORT as $}from"./dev/config.mjs";import j from"./dev/generate-progress-html.mjs";import v from"./dev/server.mjs";import b from"./options/reslove.mjs";import{ESLintPlugin as x}from"./plugin/eslint.mjs";import{StylelintPlugin as C}from"./plugin/stylelint.mjs";import{empty as _}from"./utils/index.mjs";import{CONFIG as P,getConfig as S}from"./config.mjs";import{createDevelopmentConfiguration as k}from"./create-development-configuration.mjs";import{outputFileSystem as E}from"./file-system.mjs";import{isLibrary as B,refresh as H}from"./process-env.mjs";let I=!1,O="/____progress____",T={percentage:0,info:""},q="/__hmr__",G=new URLSearchParams({name:"client",path:q.substring(1),dynamicPublicPath:!0,timeout:2e3,reload:!H,quiet:!0,noInfo:!0,overlay:!1,autoConnect:!0}).toString(),L=await k({watchOptions:{stdin:!0,aggregateTimeout:300,ignored:g.node_modules},entry:{main:[`${b.hotMiddlewareClient}?${G}`]},plugins:[new p.WatchIgnorePlugin({paths:[g.node_modules,/\.d\.ts$/]}),new p.ProgressPlugin({handler(e,t,...o){let r=o.length?`[${t}] ${o.join(" ")}`:" ";I||(T.info=r,T.percentage=e,I=1===e);let s=P.bar;if(s){let t=s.name||"Build";s.quiet?i.stdout.write(`${r}
|
|
2
|
-
`):(l(e||0,1,{msg:r,name:t,barColor:s.barColor,nameColor:s.nameColor,barBgColor:s.barBgColor,msgColor:s.msgColor}),1===e&&i.stdout.write("\r\x1b[2K"))}}})]});function U(e){let t=e.join(","),o=[r(d.programPath,`${P.alias["@"]}/**/*.{${t}}`).replace(/\\/g,"/")];return B&&o.push(r(d.programPath,`${P.alias["@pkg"]}/**/*.{${t}}`).replace(/\\/g,"/")),o}P.eslint&&L.plugins.push(new x({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.eslintcache`,cacheStrategy:"metadata",files:U(["js","jsx","ts","tsx","json","html","vue"]),...P.eslint})),P.stylelint&&L.plugins.push(new C({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.stylelintcache`,files:U(["css","scss","sass","less","ts","tsx","js","jsx"]),...P.stylelint}));let F=p(L);if(!F)throw Error("无法创建编译器");F.outputFileSystem=E;let N=F.watch(F.options.watchOptions,y);if(!N)throw Error("无法创建监视器");F.hooks.done.tap("client-log",e=>{y(null,e)});let R=`${P.basename}/${q}`.replace(/\/+/g,"/"),J=c(F,{log:!1,path:R,heartbeat:2e3}),K=await v({port:$,root_dir:F.options.output.path,fileSystem:F.outputFileSystem,headers:P.devServer.headers,https:P.devServer.https,host:P.devServer.host,open:P.devServer.open,basename:P.basename,onRequest(e,t){if(!t.writableEnded){if("GET"===e.method){let o=new s(`${P.devServer.https?"https":"http"}://${e.headers.host}${e.url}`);if(o.pathname===O)return t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(T)),!0;if(!I)return t.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),t.end(j(O,T)),!0;if(o.pathname===R&&"text/event-stream"===e.headers.accept)return J(e,t,_),!0}return!1}}});function M(){i.exit(0)}K.on("close",()=>{N.close(_),J.close()});let W=await Promise.all(u.map(S)),z=f(W[0]||{},W[1]||{});u.forEach(function(t){o(t,async function(){var o;let[r,s]=await Promise.all(u.map(S)),l=f(r||{},s||{}),p=h(z,l);1===Object.keys(p).length&&"proxy"in p?(a(n(`代理更新中...`,"yellow"),!0),a(n(`代理更新完成...`,"green"),!0),P.proxy=l.proxy,z.proxy=l.proxy,z=l):(z=l,m(n(`检测到工程配置${n(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),o=$,e(A?`netstat -ano | findstr :${o}`:`lsof -i :${o} -t`,(e,t)=>{if(e){m(n(`查找端口 ${o} 时发生错误: ${e.message}`,"red")),m(n("请尝试手动重启程序","yellow"));return}let r=t.trim().replace(/\r\n/g,"\n").split("\n").filter(Boolean),s=A?r[0]?.split(/\s+/).pop()?.trim():r[0]?.trim();if(!s)return void m(n(`未找到占用端口 ${o} 的进程, 请尝试手动重启程序`,"yellow"));try{i.kill(Number(s),"SIGHUP")}catch(e){m(n(`终止进程 ${s} 时发生错误: ${e.message}`,"red"))}}))})});let A="win32"===i.platform;i.on("SIGHUP",function(){let e;K.close(
|
|
2
|
+
`):(l(e||0,1,{msg:r,name:t,barColor:s.barColor,nameColor:s.nameColor,barBgColor:s.barBgColor,msgColor:s.msgColor}),1===e&&i.stdout.write("\r\x1b[2K"))}}})]});function U(e){let t=e.join(","),o=[r(d.programPath,`${P.alias["@"]}/**/*.{${t}}`).replace(/\\/g,"/")];return B&&o.push(r(d.programPath,`${P.alias["@pkg"]}/**/*.{${t}}`).replace(/\\/g,"/")),o}P.eslint&&L.plugins.push(new x({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.eslintcache`,cacheStrategy:"metadata",files:U(["js","jsx","ts","tsx","json","html","vue"]),...P.eslint})),P.stylelint&&L.plugins.push(new C({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.stylelintcache`,files:U(["css","scss","sass","less","ts","tsx","js","jsx"]),...P.stylelint}));let F=p(L);if(!F)throw Error("无法创建编译器");F.outputFileSystem=E;let N=F.watch(F.options.watchOptions,y);if(!N)throw Error("无法创建监视器");F.hooks.done.tap("client-log",e=>{y(null,e)});let R=`${P.basename}/${q}`.replace(/\/+/g,"/"),J=c(F,{log:!1,path:R,heartbeat:2e3}),K=await v({port:$,root_dir:F.options.output.path,fileSystem:F.outputFileSystem,headers:P.devServer.headers,https:P.devServer.https,host:P.devServer.host,open:P.devServer.open,basename:P.basename,onRequest(e,t){if(!t.writableEnded){if("GET"===e.method){let o=new s(`${P.devServer.https?"https":"http"}://${e.headers.host}${e.url}`);if(o.pathname===O)return t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(T)),!0;if(!I)return t.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),t.end(j(O,T)),!0;if(o.pathname===R&&"text/event-stream"===e.headers.accept)return J(e,t,_),!0}return!1}}});function M(){i.exit(0)}K.on("close",()=>{N.close(_),J.close()});let W=await Promise.all(u.map(S)),z=f(W[0]||{},W[1]||{});u.forEach(function(t){o(t,async function(){var o;let[r,s]=await Promise.all(u.map(S)),l=f(r||{},s||{}),p=h(z,l);1===Object.keys(p).length&&"proxy"in p?(a(n(`代理更新中...`,"yellow"),!0),a(n(`代理更新完成...`,"green"),!0),P.proxy=l.proxy,z.proxy=l.proxy,z=l):(z=l,m(n(`检测到工程配置${n(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),o=$,e(A?`netstat -ano | findstr :${o}`:`lsof -i :${o} -t`,(e,t)=>{if(e){m(n(`查找端口 ${o} 时发生错误: ${e.message}`,"red")),m(n("请尝试手动重启程序","yellow"));return}let r=t.trim().replace(/\r\n/g,"\n").split("\n").filter(Boolean),s=A?r[0]?.split(/\s+/).pop()?.trim():r[0]?.trim();if(!s)return void m(n(`未找到占用端口 ${o} 的进程, 请尝试手动重启程序`,"yellow"));try{i.kill(Number(s),"SIGHUP")}catch(e){m(n(`终止进程 ${s} 时发生错误: ${e.message}`,"red"))}}))})});let A="win32"===i.platform;i.on("SIGHUP",function(){let e;K.close(),(e=t(i.argv[0],i.argv.slice(1),{detached:!1,stdio:"inherit"})).unref(),e.on("close",M)}),i.on("exit",function(){K.close()}),w(M);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return t}});let e=require("node:path"),s=new(require("node:worker_threads")).Worker((0,e.join)(__dirname,"../worker/css-in-js-minify.mjs"));async function t(e){
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return t}});let e=require("node:path"),s=new(require("node:worker_threads")).Worker((0,e.join)(__dirname,"../worker/css-in-js-minify.mjs"));async function t(e){(this._compiler?.options.mode!=="development"||"true"===process.env.IS_BUILD)&&this._compiler?.hooks.done.tap("css-in-js-minify-loader",()=>{s.terminate()}),this.cacheable&&this.cacheable();let t=this.async(),r=this.getOptions(),i=this.resourcePath;s.postMessage({options:r,code:e,filename:i}),s.addListener("message",function e(r){i===r[0]&&(t(r[1],r[2]),s.removeListener("message",e))})}s.setMaxListeners(0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=exports,t={get custom(){return i},get default(){return a}};for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(t,r).get});let s=require("node:path"),o=new(require("node:worker_threads")).Worker((0,s.join)(__dirname,"../worker/react-compiler.mjs"));function n(e,t){let r=this.resourcePath,s=this.getOptions();if(r.endsWith(".d.ts")||r.endsWith(".json")||!("annotation"===s.compilationMode?e.includes("use memo")||e.includes("use forget"):e.includes("react")||r.endsWith(".tsx")||r.endsWith(".jsx")))return e;let n=this.async();
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=exports,t={get custom(){return i},get default(){return a}};for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(t,r).get});let s=require("node:path"),o=new(require("node:worker_threads")).Worker((0,s.join)(__dirname,"../worker/react-compiler.mjs"));function n(e,t){(this._compiler?.options.mode!=="development"||"true"===process.env.IS_BUILD)&&this._compiler?.hooks.done.tap("react-compiler-loader",()=>{o.terminate()});let r=this.resourcePath,s=this.getOptions();if(r.endsWith(".d.ts")||r.endsWith(".json")||!("annotation"===s.compilationMode?e.includes("use memo")||e.includes("use forget"):e.includes("react")||r.endsWith(".tsx")||r.endsWith(".jsx")))return e;let n=this.async();this.cacheable&&this.cacheable(),o.postMessage({sourceCode:e,filename:r,inputSourceMap:t,options:s}),o.addListener("message",function e(t){r===t[0]&&(n(t[1],t[2],t[3]),o.removeListener("message",e))})}function i(e,t){return n.bind(this,e,t)}o.setMaxListeners(0);let a=n;
|
package/lib/loader/solid.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=exports,t={get custom(){return n},get default(){return a}};for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(t,r).get});let s=require("node:path"),o=new(require("node:worker_threads")).Worker((0,s.join)(__dirname,"../worker/solid.mjs"));async function i(e,t){
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=exports,t={get custom(){return n},get default(){return a}};for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(t,r).get});let s=require("node:path"),o=new(require("node:worker_threads")).Worker((0,s.join)(__dirname,"../worker/solid.mjs"));async function i(e,t){(this._compiler?.options.mode!=="development"||"true"===process.env.IS_BUILD)&&this._compiler?.hooks.done.tap("solid-loader",()=>{o.terminate()}),this.cacheable&&this.cacheable();let r=this.async(),s=this.getOptions(),i=this.resourcePath;o.postMessage({...s,sourceCode:e,filename:i,inputSourceMap:t}),o.addListener("message",function e(t){i===t[0]&&(r(t[1],t[2],t[3]),o.removeListener("message",e))})}function n(e,t){return i.bind(this,e,t)}o.setMaxListeners(0);let a=i;
|
|
@@ -1 +1 @@
|
|
|
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))})
|
|
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;("development"!==e.options.mode||"true"===process.env.IS_BUILD)&&e.hooks.done.tap(this.name,()=>{this.worker.terminate()}),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/eslint.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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,o=e=>{this.report(t,e)};this.worker.on("message",o),t.hooks.finishModules.tap(this.name,e=>{let t=this.options;if(this.options?.lintDirtyModulesOnly){let o=[];for(let t of e){let e=t.resource;s.has(e)&&o.push(e)}t.files=o}this.worker.postMessage({options:t})})})
|
|
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){("development"!==e.options.mode||"true"===process.env.IS_BUILD)&&e.hooks.done.tap(this.name,()=>{this.worker.terminate()}),e.hooks.thisCompilation.tap(this.name,t=>{let s=e.modifiedFiles||new Set,o=e=>{this.report(t,e)};this.worker.on("message",o),t.hooks.finishModules.tap(this.name,e=>{let t=this.options;if(this.options?.lintDirtyModulesOnly){let o=[];for(let t of e){let e=t.resource;s.has(e)&&o.push(e)}t.files=o}this.worker.postMessage({options:t})})})}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=>{let e=e=>{this.report(e,t)};this.worker.postMessage({options:this.options}),this.worker.on("message",e)})
|
|
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){("development"!==t.options.mode||"true"===process.env.IS_BUILD)&&t.hooks.done.tap(this.name,()=>{this.worker.terminate()}),t.hooks.thisCompilation.tap(this.name,t=>{let e=e=>{this.report(e,t)};this.worker.postMessage({options:this.options}),this.worker.on("message",e)})}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])))}}
|