@moneko/core 3.27.1 → 3.27.2

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/dev.d.mts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { exec, spawn } from 'node:child_process';
2
2
  import { watchFile } from 'node:fs';
3
3
  import type { IncomingMessage } from 'node:http';
4
+ import { relative } from 'node:path';
4
5
  import compress from '@fastify/compress';
5
6
  import { fastifyMiddie } from '@fastify/middie';
6
7
  import { ink, loadFile, print, println, progressBar } from '@moneko/utils';
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 r from"@fastify/compress";import{fastifyMiddie as s}from"@fastify/middie";import{ink as i,loadFile as l,print as n,println as a,progressBar as m}from"@moneko/utils";import p from"fastify";import c from"webpack";import d from"webpack-dev-middleware";import u from"webpack-hot-middleware";import{merge as h}from"webpack-merge";import{diffObject as f}from"./commom/diff-object.mjs";import g from"./commom/has-pkg.mjs";import w,{config_files as y}from"./commom/paths.mjs";import x from"./commom/rule.mjs";import v from"./commom/sigint-exit.mjs";import{devLog as C,PORT as k}from"./dev/config.mjs";import $ from"./dev/mock.mjs";import{setupProxy as b}from"./dev/proxy.mjs";import j from"./options/reslove.mjs";import P from"./plugin/stylelint.mjs";import{empty as S,resolveProgram as A}from"./utils/index.mjs";import{commonConfig as E}from"./common.mjs";import{CONFIG as T,getConfig as I,PUBLICPATH as M}from"./config.mjs";import _ from"./module.config.mjs";import{isLibrary as R,isReact as B,refresh as H}from"./process-env.mjs";let O=T.eslint&&g("eslint-webpack-plugin")&&(await import("eslint-webpack-plugin")).default,q=["js","jsx","ts","tsx","json","html","vue"],z=q.join(","),U=`${M.endsWith("/")?"":"/"}__hmr__`,D=new URLSearchParams({name:"client",path:U,dynamicPublicPath:!0,timeout:2e3,reload:!H,quiet:!0,noInfo:!0,overlay:!0,autoConnect:!0}).toString(),G=E.output.path,L=T.bar,W=L.name||"Build",F=h(E,{entry:{main:[`${j.hotMiddlewareClient}?${D}`]},output:{path:G},module:_(!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:x.node_modules,priority:-10,reuseExistingChunk:!0},default:{minChunks:1,priority:-20,reuseExistingChunk:!0}}}},plugins:[new c.HotModuleReplacementPlugin,new c.WatchIgnorePlugin({paths:[/node_modules\/(?!(@app|@moneko)).+/,/\.d\.ts$/]})]});if(F.plugins||(F.plugins=[]),B){let e=(await import("@pmmmwh/react-refresh-webpack-plugin")).default;F.plugins.push(new e)}if(O&&F.plugins.push(new O({fix:!0,threads:!0,files:[`${T.alias["@"]}/**/*.{${z}}`,R&&`${T.alias["@pkg"]}/**/*.{${z}}`].filter(Boolean),extensions:q,exclude:["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],cache:!0,cacheLocation:`${w.lintCachePath}/.eslintcache`,lintDirtyModulesOnly:!0,overrideConfigFile:A("eslint.config.mjs"),configType:"flat"})),T.stylelint){let e="css,scss,sass,less,ts,tsx,js,jsx";F.plugins.push(new P({fix:!0,files:[`${T.alias["@"]}/**/*.{${e}}`,R&&`${T.alias["@pkg"]}/**/*.{${e}}`].filter(Boolean),cache:!0,cacheLocation:`${w.lintCachePath}/.stylelintcache`}))}T.bar&&F.plugins.push(new c.ProgressPlugin({handler(e,t,...o){m(e||0,1,{msg:o.length?`[${t}] ${o.join(" ")}`:"",name:W,barColor:L.barColor,nameColor:L.nameColor,barBgColor:L.barBgColor,msgColor:L.msgColor}),1===e&&process.stdout.write("\r\x1b[2K")}}));let N=c(F);N.hooks.done.tap("client-log",e=>{C(null,e)});let K={};if(T.devServer.https){let[e,t]=await Promise.all([l(T.devServer.https.key),l(T.devServer.https.cert)]);e||(a(i(`法加载私钥。请检查路径和文件是否存在,并确保路径正确:${T.devServer.https.key}`,"red")),process.exit(1)),t||(a(i(`无法加载证书。请检查路径和文件是否存在,并确保路径正确:${T.devServer.https.cert}`,"red")),process.exit(1)),K.http2=!0,K.https={key:e,cert:t}}let X=d(N,{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",...T.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:F.output?.publicPath,cacheControl:!1,cacheImmutable:!1}),J=u(N,{log:!1,path:U,heartbeat:2e3}),Q=p({logger:!1,...K});await Q.register(s),Q.use(X),Q.use(U,J),$(Q,{directory:w.mockPath}),b(Q,T.proxy);let V=`${F.output.path}/index.html`;function Y(){process.exit(0)}Q.get("*",async(e,t)=>{if(e.headers.accept?.includes("text/html")){let e=X.context.outputFileSystem,o=e?.readFileSync?.(V);if(!t.sent){t.type("text/html").send(o);return}}else if(e.url?.endsWith(U)&&"text/event-stream"===e.headers.accept){e.raw.url=U,J(e.raw,t.raw,S);return}}),Q.addHook("onClose",()=>{X.close(S),Q.server.close(S)}),await Q.register(r,{global:!0}),Q.listen({port:k});let Z=await Promise.all(y.map(I)),ee=h(Z[0]||{},Z[1]||{});y.forEach(function(t){o(t,async function(){let[o,r]=await Promise.all(y.map(I)),s=h(o||{},r||{}),l=f(ee,s);1===Object.keys(l).length&&"proxy"in l?(n(i(`代理更新中...`,"yellow"),!0),await b(Q,s.proxy),n(i(`代理更新完成...`,"green"),!0),T.proxy=s.proxy,ee.proxy=s.proxy,ee=s):(ee=s,a(i(`检测到工程配置${i(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),e("win32"===process.platform?`netstat -ano | findstr :${k}`:`lsof -i :${k} -t`,(e,t)=>{if(e){a(i(`查找端口 ${k} 时发生错误: ${e.message}`,"red")),a(i("请尝试手动重启程序","yellow"));return}let o=t.trim().split("\n").filter(Boolean),r=et?o[0]?.split(/\s+/).pop()?.trim():o[0]?.trim();if(!r){a(i(`未找到占用端口 ${k} 的进程, 请尝试手动重启程序`,"yellow"));return}try{process.kill(Number(r),"SIGHUP")}catch(e){a(i(`终止进程 ${r} 时发生错误: ${e.message}`,"red"))}}))})});let et="win32"===process.platform;process.on("SIGHUP",function(){Q.close(S),function(){let e=t(process.argv[0],process.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",Y)}()}),process.on("exit",function(){Q.close(S)}),v(Y);
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 s from"@fastify/compress";import{fastifyMiddie as i}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=I.bar,F=W.name||"Build",N=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(N.plugins||(N.plugins=[]),H){let e=(await import("@pmmmwh/react-refresh-webpack-plugin")).default;N.plugins.push(new e)}if(q&&N.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";N.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`}))}I.bar&&N.plugins.push(new d.ProgressPlugin({handler(e,t,...o){p(e||0,1,{msg:o.length?`[${t}] ${o.join(" ")}`:"",name:F,barColor:W.barColor,nameColor:W.nameColor,barBgColor:W.barBgColor,msgColor:W.msgColor}),1===e&&process.stdout.write("\r\x1b[2K")}}));let K=d(N);K.hooks.done.tap("client-log",e=>{k(null,e)});let X={};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)),X.http2=!0,X.https={key:e,cert:t}}let J=u(K,{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:N.output?.publicPath,cacheControl:!1,cacheImmutable:!1}),Q=h(K,{log:!1,path:D,heartbeat:2e3}),V=c({logger:!1,...X});await V.register(i),V.use(J),V.use(D,Q),b(V,{directory:y.mockPath}),j(V,I.proxy);let Y=`${N.output.path}/index.html`;function Z(){process.exit(0)}V.get("*",async(e,t)=>{if(e.headers.accept?.includes("text/html")){let e=J.context.outputFileSystem,o=e?.readFileSync?.(Y);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,Q(e.raw,t.raw,A);return}}),V.addHook("onClose",()=>{J.close(A),V.server.close(A)}),await V.register(s,{global:!0}),V.listen({port:$});let ee=await Promise.all(x.map(M)),et=f(ee[0]||{},ee[1]||{});x.forEach(function(t){o(t,async function(){let[o,r]=await Promise.all(x.map(M)),s=f(o||{},r||{}),i=g(et,s);1===Object.keys(i).length&&"proxy"in i?(a(l(`代理更新中...`,"yellow"),!0),await j(V,s.proxy),a(l(`代理更新完成...`,"green"),!0),I.proxy=s.proxy,et.proxy=s.proxy,et=s):(et=s,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=eo?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 eo="win32"===process.platform;process.on("SIGHUP",function(){V.close(A),function(){let e=t(process.argv[0],process.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",Z)}()}),process.on("exit",function(){V.close(A)}),C(Z);
@@ -1 +1 @@
1
- "use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return o}});const t=require("@swc/core"),i=require("stylis"),a=(e=require("../commom/log.mjs"))&&e.__esModule?e:{default:e};function r(e,t){let a=!1;return"Identifier"===e.tag.type&&t.includes(e.tag?.value)&&(e.template.quasis.forEach(e=>{let t=(0,i.serialize)((0,i.compile)(e.raw),(0,i.middleware)([i.stringify]));e.raw=t,e.cooked=t}),a=!0),a}function l(e,t){let i=!1;return e.properties.forEach(e=>{"KeyValueProperty"===e.type&&"TaggedTemplateExpression"===e.value.type&&"Identifier"===e.value.tag.type&&t.includes(e.value.tag.value)&&r(e.value,t)&&(i=!0)}),i}async function o(e){let i=this.async(),{moduleName:o="@moneko/css",allowFuncs:n=["css","injectGlobal"]}=this.getOptions()||{};this.cacheable&&this.cacheable();try{let a=!1,s=await (0,t.parse)(e,{syntax:"ecmascript"}),p=[];if(s.body.forEach(e=>{!function e(t){"ImportDeclaration"===t.type&&t.source.value===o&&t.specifiers.forEach(e=>{"ImportSpecifier"===e.type&&(e.imported&&n.includes(e.imported.value)?p.push(e.local.value):n.includes(e.local.value)&&p.push(e.local.value))}),"ObjectExpression"===t.type&&l(t,p)&&(a=!0),"TaggedTemplateExpression"===t.type&&r(t,p)&&(a=!0),"VariableDeclaration"===t.type&&t.declarations.forEach(e=>{let t;t=!1,"VariableDeclarator"===e.type&&("Identifier"===e.id.type&&e.init?.type==="Identifier"&&p.includes(e.init.value)&&p.push(e.id.value),e.init?.type==="TaggedTemplateExpression"?r(e.init,p)&&(t=!0):e.init?.type==="ObjectExpression"&&l(e.init,p)&&(t=!0)),t&&(a=!0)}),"ExpressionStatement"===t.type&&e(t.expression),"ExportDeclaration"===t.type&&e(t.declaration),"ExportDefaultExpression"===t.type&&e(t.expression),"ReturnStatement"===t.type&&t.argument&&e(t.argument),"FunctionDeclaration"===t.type&&t.body&&t.body.stmts.forEach(t=>{e(t)})}(e)}),a){let e=await (0,t.print)(s);i(null,e?.code||void 0,e?.map||void 0)}else i(null,e,void 0)}catch(e){i(e),(0,a.default)(e)}}
1
+ "use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return c}});const t=require("@swc/core"),r=require("stylis"),l=(e=require("../commom/log.mjs"))&&e.__esModule?e:{default:e};function a(e){let t=e.quasis.map(e=>e.raw);return t.reduce((e,r,l)=>(e.push(r),l!==t.length-1&&e.push(`xxx${l}:xxx`),e),[]).join("").trim()}async function c(e){let c=this.async(),{moduleName:n="@moneko/css",allowFuncs:i=["css","injectGlobal"]}=this.getOptions()||{};this.cacheable&&this.cacheable();try{let l=await (0,t.parse)(e,{syntax:"ecmascript"}),s=[];l.body.forEach(e=>{"ImportDeclaration"===e.type&&e.source.value===n&&e.specifiers.forEach(e=>{"ImportSpecifier"===e.type&&(e.imported&&i.includes(e.imported.value)?s.push(e.local.value):i.includes(e.local.value)&&s.push(e.local.value))})}),l.body.forEach(function t(l){if(l&&"object"==typeof l){if("TaggedTemplateExpression"===l.type&&"Identifier"===l.tag.type&&s.includes(l.tag.value)){let t=a(l.template),c=function(e,t){let l=a(e.template),c=function e(t){return"string"==typeof t?t:t.map(t=>{switch(t.type){case"import":case"decl":return t.value;case"comm":return"/"===t.props&&t.value.includes("@")?t.value:"";case"rule":return`${t.value.replace(/&\f/g,"&")}{${e(t.children)}}`;default:return`${t.value}{${e(t.children)}}`}}).join("")}((0,r.compile)(l)),n=function(e){let t;let r=/xxx(\d+):xxx/gm,l=[];for(;null!==(t=r.exec(e));)l.push({value:t[0],p1:parseInt(t[1],10),index:t.index});return l}(c);if(0===n.length)return c;let i=c,s=0;return n.forEach(r=>{let l=e.template.expressions[r.p1],a=`xxx${r.p1}:xxx`,c=i.indexOf(a,s);if(-1!==c&&"span"in l){let e=t.slice(l.span.start,l.span.end);i=i.slice(0,c)+e+i.slice(c+a.length),s=c+e.length}}),i}(l,e);e=e.replace(t,c)}for(let e in l)if(Object.prototype.hasOwnProperty.call(l,e)){let r=l[e];Array.isArray(r)?r.forEach(e=>t(e)):r&&"object"==typeof r&&t(r)}}}),c(null,e)}catch(e){c(e),(0,l.default)(e)}}
@@ -1,5 +1,5 @@
1
- import { type Expression, type ModuleItem, type ObjectExpression, parse, print, type TaggedTemplateExpression, type VariableDeclarator } from '@swc/core';
2
- import { compile, middleware, serialize, stringify } from 'stylis';
1
+ import { type Expression, type Import, type ModuleItem, parse, type TaggedTemplateExpression, type TemplateLiteral } from '@swc/core';
2
+ import { compile, type Element } from 'stylis';
3
3
  import type { LoaderContext } from 'webpack';
4
4
  import log from '../commom/log.mjs';
5
5
  export interface CssInJsMinifyOption {
@@ -7,7 +7,8 @@ export interface CssInJsMinifyOption {
7
7
  moduleName?: string;
8
8
  allowFuncs?: string[];
9
9
  }
10
- declare function parseTaggedTemplateExpression(declaration: TaggedTemplateExpression, names: string[]);
11
- declare function parseDeclaration(declaration: VariableDeclarator, names: string[]);
12
- declare function parseObjectExpression(expression: ObjectExpression, names: string[]);
10
+ declare function stringifyTree(elements: Element[] | string);
11
+ declare function createRawStringFromTemplateLiteral(quasi: TemplateLiteral);
12
+ declare function getDynamicMatches(str: string);
13
+ declare function minify(node: TaggedTemplateExpression, sourceCode: string);
13
14
  export default async function cssInJsMinifyLoader(this: LoaderContext<CssInJsMinifyOption>, sourceCode: string);
@@ -18,6 +18,6 @@ declare class StylelintPlugin {
18
18
  files: []
19
19
  });
20
20
  apply(compiler: Compiler): void;
21
- private report(linter: LinterResult, compilation: Compilation);
21
+ private report(linter?: LinterResult, compilation?: Compilation);
22
22
  }
23
23
  export default StylelintPlugin;
@@ -1 +1 @@
1
- import{fileURLToPath as r}from"node:url";import{stylelint as t}from"@moneko/stylelint";import e from"webpack";import{Worker as s}from"worker_threads";class n extends e.WebpackError{constructor(r){super(`[Stylelint] ${r.replace(/[^\r\n]*(\r?\n)*$/,"")}`),this.name="StylelintError",this.stack=""}}export default class{constructor(t={files:[]}){this.name="StylelintPlugin",this.options=t,this.worker=new s(r(new URL("./worker/stylelint.mjs",import.meta.url)))}apply(r){r.hooks.thisCompilation.tap(this.name,r=>{this.worker.postMessage({options:this.options}),this.worker.once("message",t=>{let e=JSON.parse(t);this.report(e,r)})}),r.hooks.shutdown.tap(this.name,()=>{this.worker.terminate()})}report(r,e){let s=[],o=[];r.results.forEach(r=>{if(!r.ignored&&(r.errored||r.parseErrors.length||r.invalidOptionWarnings.length||r.deprecations.length)){let t=[],e=[];r.warnings.forEach(r=>{"error"===r.severity?t.push(r):"warning"===r.severity&&e.push(r)}),t.length>0&&s.push({...r,warnings:t}),e.length>0&&o.push({...r,warnings:e})}}),t.formatters.string.then(t=>{o.length&&e.warnings.push(new n(t(o,r))),s.length&&e.errors.push(new n(t(s,r)))})}}
1
+ import{fileURLToPath as r}from"node:url";import{stylelint as t}from"@moneko/stylelint";import e from"webpack";import{Worker as s}from"worker_threads";class n extends e.WebpackError{constructor(r){super(`[Stylelint] ${r.replace(/[^\r\n]*(\r?\n)*$/,"")}`),this.name="StylelintError",this.stack=""}}export default class{constructor(t={files:[]}){this.name="StylelintPlugin",this.options=t,this.worker=new s(r(new URL("./worker/stylelint.mjs",import.meta.url)))}apply(r){r.hooks.thisCompilation.tap(this.name,r=>{this.worker.postMessage({options:this.options}),this.worker.once("message",t=>{this.report(t.linter,r)})}),r.hooks.shutdown.tap(this.name,()=>{this.worker.terminate()})}report(r,e){if(!r||!e)return;let s=[],o=[];r.results.forEach(r=>{if(!r.ignored&&(r.errored||r.parseErrors.length||r.invalidOptionWarnings.length||r.deprecations.length)){let t=[],e=[];r.warnings.forEach(r=>{"error"===r.severity?t.push(r):"warning"===r.severity&&e.push(r)}),t.length>0&&s.push({...r,warnings:t}),e.length>0&&o.push({...r,warnings:e})}}),t.formatters.string.then(t=>{o.length&&e.warnings.push(new n(t(o,r))),s.length&&e.errors.push(new n(t(s,r)))})}}
@@ -1 +1 @@
1
- import{stylelint as e}from"@moneko/stylelint";import{parentPort as t}from"worker_threads";if(!t)throw Error("This file must be run as a worker");t.on("message",async({options:i})=>{try{let a=await e.lint({cache:i.cache,cacheLocation:i.cacheLocation,fix:i.fix,files:i.files,quietDeprecationWarnings:i.quietDeprecationWarnings,quiet:i.quiet});delete a.output,t.postMessage(JSON.stringify(a))}catch(e){t.postMessage(e)}});
1
+ import{stylelint as e}from"@moneko/stylelint";import{parentPort as t}from"worker_threads";if(!t)throw Error("This file must be run as a worker");t.on("message",async({options:i})=>{try{let a=await e.lint({cache:i.cache,cacheLocation:i.cacheLocation,fix:i.fix,files:i.files.map(e=>e.replace(/\\/g,"/")),quietDeprecationWarnings:i.quietDeprecationWarnings,quiet:i.quiet});delete a.output,t.postMessage({linter:a})}catch(e){t.postMessage(e)}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.27.1",
3
+ "version": "3.27.2",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",
@@ -19,7 +19,7 @@
19
19
  "@fastify/http-proxy": "9.5.0",
20
20
  "@fastify/middie": "8.3.3",
21
21
  "@moneko/mdx": "0.1.42",
22
- "@moneko/stylelint": "1.0.1",
22
+ "@moneko/stylelint": "1.0.2",
23
23
  "@moneko/transform-imports": "0.6.1",
24
24
  "@moneko/utils": "0.1.22",
25
25
  "@swc/core": "1.6.13",