@visulima/rollup-plugin-css 1.0.0-alpha.29 → 1.0.0-alpha.30

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/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## @visulima/rollup-plugin-css [1.0.0-alpha.30](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-css@1.0.0-alpha.29...@visulima/rollup-plugin-css@1.0.0-alpha.30) (2026-04-18)
2
+
3
+ ### Features
4
+
5
+ * **css:** extend stylus, fix lightningcss modules, add dts coverage ([302f01f](https://github.com/visulima/packem/commit/302f01f087a2a4e91e22a6da75bd280410923aa6))
6
+
7
+
8
+ ### Dependencies
9
+
10
+ * **@visulima/packem-share:** upgraded to 1.0.0-alpha.31
11
+
1
12
  ## @visulima/rollup-plugin-css [1.0.0-alpha.29](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-css@1.0.0-alpha.28...@visulima/rollup-plugin-css@1.0.0-alpha.29) (2026-04-16)
2
13
 
3
14
  ### Miscellaneous Chores
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Plugin } from 'rollup';
2
- import { S as StyleOptions } from './packem_shared/types-15b79qIg.js';
3
- export { A as AutoModules, E as ExtractedData, I as InjectOptions, a as InternalStyleOptions, L as LightningCSSOptions, P as PostCSSConfigLoaderOptions, b as PostCSSOptions } from './packem_shared/types-15b79qIg.js';
2
+ import { S as StyleOptions } from './packem_shared/types-B7InbTq8.js';
3
+ export { A as AutoModules, E as ExtractedData, I as InjectOptions, a as InternalStyleOptions, L as LightningCSSOptions, P as PostCSSConfigLoaderOptions, b as PostCSSOptions } from './packem_shared/types-B7InbTq8.js';
4
4
  import { Environment } from '@visulima/packem-share/types';
5
5
  import 'cssnano';
6
6
  import 'lightningcss';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{default as e}from"./packem_shared/cssModulesTypesPlugin-CjGroK2y.js";import{default as u}from"./packem_shared/rollupCssPlugin-BdsDsdTA.js";export{e as cssModulesTypesPlugin,u as rollupCssPlugin};
1
+ import{default as e}from"./packem_shared/cssModulesTypesPlugin-CjGroK2y.js";import{default as u}from"./packem_shared/rollupCssPlugin-BxRedPmA.js";export{e as cssModulesTypesPlugin,u as rollupCssPlugin};
@@ -1,4 +1,4 @@
1
- import { c as Loader, d as LESSLoaderOptions } from '../../packem_shared/types-15b79qIg.js';
1
+ import { c as Loader, d as LESSLoaderOptions } from '../../packem_shared/types-B7InbTq8.js';
2
2
  import 'cssnano';
3
3
  import 'lightningcss';
4
4
  import 'postcss';
@@ -1,4 +1,4 @@
1
- import { c as Loader, L as LightningCSSOptions } from '../packem_shared/types-15b79qIg.js';
1
+ import { c as Loader, L as LightningCSSOptions } from '../packem_shared/types-B7InbTq8.js';
2
2
  import 'cssnano';
3
3
  import 'lightningcss';
4
4
  import 'postcss';
@@ -1,3 +1,3 @@
1
- import{transform as r,browserslistToTargets as a}from"lightningcss";import{n as o}from"../packem_shared/ensure-auto-modules-BU3xWEjl.js";const l={name:"lightningCSS",async process({code:t,map:i}){let s=!1;typeof this.options.modules=="boolean"?s=this.options.modules:typeof this.options.modules=="object"&&(s=o(this.options.modules.include,this.id)),this.autoModules&&this.options.modules===void 0&&(s=o(this.autoModules,this.id));const e=r({...this.options,code:Buffer.from(t),cssModules:this.options.modules??s,filename:this.id,inputSourceMap:i,minify:!1,sourceMap:!this.sourceMap,targets:a(this.browserTargets)});return e.warnings.length>0&&this.logger.warn({message:`warnings when transforming css:
2
- ${e.warnings.map(n=>n.message).join(`
3
- `)}`}),{code:e.code.toString(),map:e.map?JSON.parse(Buffer.from(e.map).toString()):void 0,moduleSideEffects:s||typeof this.inject=="object"&&this.inject.treeshakeable?!1:"no-treeshake"}},test:/\.css$/i};export{l as default};
1
+ var p=Object.defineProperty;var d=(i,e)=>p(i,"name",{value:e,configurable:!0});import{transform as l,browserslistToTargets as u}from"lightningcss";import{g as f}from"../packem_shared/generate-js-exports-BhS4eLrN.js";import{n as m}from"../packem_shared/ensure-auto-modules-BU3xWEjl.js";var h=Object.defineProperty,g=d((i,e)=>h(i,"name",{value:e,configurable:!0}),"a");const x=g(i=>{const e={},r=Object.entries(i).sort(([s],[t])=>s<t?-1:s>t?1:0);for(const[s,t]of r){const n=[t.name];for(const a of t.composes)(a.type==="local"||a.type==="global")&&n.push(a.name);e[s]=n.join(" ")}return e},"normalizeModulesExports"),j={name:"lightningcss",async process({code:i,map:e}){let r=!1;typeof this.options.modules=="boolean"?r=this.options.modules:typeof this.options.modules=="object"&&(r=m(this.options.modules.include,this.id)),this.autoModules&&this.options.modules===void 0&&(r=m(this.autoModules,this.id));const s=l({...this.options,code:Buffer.from(i),cssModules:this.options.modules??r,filename:this.id,inputSourceMap:e,minify:!1,sourceMap:!!this.sourceMap,targets:u(this.browserTargets)});s.warnings.length>0&&this.logger.warn({message:`warnings when transforming css:
2
+ ${s.warnings.map(c=>c.message).join(`
3
+ `)}`});const t=s.code.toString(),n=s.map?Buffer.from(s.map).toString():void 0,a=s.exports?x(s.exports):{},o=f({css:t,cwd:this.cwd,dts:this.dts,emit:this.emit,extract:this.extract,icssDependencies:[],id:this.id,inject:this.inject,inline:this.inline,logger:this.logger,map:n,modulesExports:a,namedExports:this.namedExports,supportModules:r});return this.extract?{code:o.code,extracted:{css:t,id:this.id,map:n},map:o.map,meta:o.meta,moduleSideEffects:o.moduleSideEffects}:{code:o.code,map:o.map,meta:o.meta,moduleSideEffects:o.moduleSideEffects}},test:/\.css$/i};export{j as default};
@@ -1,4 +1,4 @@
1
- import { c as Loader, a as InternalStyleOptions } from '../../packem_shared/types-15b79qIg.js';
1
+ import { c as Loader, a as InternalStyleOptions } from '../../packem_shared/types-B7InbTq8.js';
2
2
  import 'cssnano';
3
3
  import 'lightningcss';
4
4
  import 'postcss';
@@ -1,5 +1,5 @@
1
- import { c as Loader, e as SassLoaderOptions } from '../../packem_shared/types-15b79qIg.js';
2
- export { f as SassLoaderContext } from '../../packem_shared/types-15b79qIg.js';
1
+ import { c as Loader, e as SassLoaderOptions } from '../../packem_shared/types-B7InbTq8.js';
2
+ export { f as SassLoaderContext } from '../../packem_shared/types-B7InbTq8.js';
3
3
  import 'cssnano';
4
4
  import 'lightningcss';
5
5
  import 'postcss';
@@ -1,4 +1,4 @@
1
- import { c as Loader } from '../packem_shared/types-15b79qIg.js';
1
+ import { c as Loader } from '../packem_shared/types-B7InbTq8.js';
2
2
  import 'cssnano';
3
3
  import 'lightningcss';
4
4
  import 'postcss';
@@ -1,4 +1,5 @@
1
- import { c as Loader, g as StylusLoaderOptions } from '../../packem_shared/types-15b79qIg.js';
1
+ import { c as Loader, g as StylusLoaderOptions } from '../../packem_shared/types-B7InbTq8.js';
2
+ export { h as StylusDefinition, i as StylusLoaderContext, j as StylusPlugin } from '../../packem_shared/types-B7InbTq8.js';
2
3
  import 'cssnano';
3
4
  import 'lightningcss';
4
5
  import 'postcss';
@@ -1 +1,2 @@
1
- var h=Object.defineProperty;var p=(e,t)=>h(e,"name",{value:t,configurable:!0});import{existsSync as y}from"node:fs";import{readFileSync as w}from"@visulima/fs";import{normalize as n,dirname as P,join as m}from"@visulima/path";import S from"stylus";import{m as b}from"../../packem_shared/sourcemap-CB6ochh0.js";var v=Object.defineProperty,u=p((e,t)=>v(e,"name",{value:t,configurable:!0}),"a");const C=u(async(e,t)=>{if(!(!e.sources||e.sourcesContent))return await Promise.all(e.sources.map(async r=>{const o=n(m(t,r));if(y(o))return w(o)}).filter(Boolean))},"populateSourcemapContent"),F={name:"stylus",async process({code:e,map:t}){const r={...this.options},o=n(P(this.id)),i=[o,m(o,"node_modules"),m(this.cwd,"node_modules")];r.paths&&i.push(...r.paths);const s=S(e,r).set("filename",this.id).set("paths",i).set("sourcemap",{basePath:o,comment:!1});e=await u(async()=>await new Promise((a,l)=>{s.render((c,f)=>c?l(c):a(f))}),"render")();const d=s.deps();for(const a of d)this.deps.add(n(a));return s.sourcemap&&(s.sourcemap.sourcesContent=await C(s.sourcemap,o)),{code:e,map:b(s.sourcemap).toString()??t}},test:/\.(styl|stylus)$/i};export{F as default};
1
+ var E=Object.defineProperty;var v=(t,e)=>E(t,"name",{value:e,configurable:!0});import{existsSync as F}from"node:fs";import{readFileSync as _}from"@visulima/fs";import{normalize as d,dirname as D,join as y}from"@visulima/path";import O from"stylus";import P from"../../packem_shared/loadModule-D20jQQNu.js";import{m as R}from"../../packem_shared/sourcemap-CB6ochh0.js";var k=Object.defineProperty,p=v((t,e)=>k(t,"name",{value:e,configurable:!0}),"l");const z=p(async(t,e)=>{if(!(!t.sources||t.sourcesContent))return await Promise.all(t.sources.map(async n=>{const s=d(y(e,n));if(F(s))return _(s)}).filter(Boolean))},"populateSourcemapContent"),B=p(async(t,e,n)=>{if(typeof t=="function")return t;if(typeof t=="string"){const s=await P(t,e,n);if(typeof s!="function")throw new Error(`The Stylus implementation "${t}" is not a function.`);return s}return O},"resolveImplementation"),I=p((t,e)=>{if(!e)return;const n=Array.isArray(e)?e:Object.entries(e);for(const s of n){const[r,a,c]=s;t.define(r,a,c)}},"applyDefinitions"),L=p(async(t,e,n,s)=>{if(!(!e||e.length===0))for(const r of e){if(typeof r=="function"){t.use(r);continue}const a=await P(r,n,s);if(typeof a!="function")throw new Error(`Failed to load "${r}" Stylus plugin. Are you sure it's installed and exports a function?`);const c=a();t.use(typeof c=="function"?c:a)}},"applyPlugins"),K={name:"stylus",async process({code:t,map:e}){const{additionalData:n,define:s,disableCache:r,hoistAtrules:a,implementation:c,import:h,include:w,includeCSS:b,lineNumbers:C,use:$,...m}=this.options,u=d(D(this.id)),f=this.cwd??process.cwd(),g=[u,y(u,"node_modules"),y(f,"node_modules")];m.paths&&g.push(...m.paths);let l=t;if(n!==void 0){const i={environment:this.environment,resourcePath:this.id,rootContext:f};l=typeof n=="function"?await n(l,i):`${n}
2
+ ${l}`}const o=(await B(c,f,this.logger))(l,m).set("filename",this.id).set("paths",g).set("sourcemap",{basePath:u,comment:!1});if(b&&o.set("include css",!0),a&&o.set("hoist atrules",!0),C&&o.set("linenos",!0),r&&o.set("cache",!1),w)for(const i of w)o.include(i);if(h)for(const i of h)o.import(i);await L(o,$,f,this.logger),I(o,s);const A=await new Promise((i,j)=>{o.render((S,x)=>S?j(S):i(x))});for(const i of o.deps())this.deps.add(d(i));return o.sourcemap&&(o.sourcemap.sourcesContent=await z(o.sourcemap,u)),{code:A,map:R(o.sourcemap).toString()??e}},test:/\.(styl|stylus)$/i};export{K as default};
@@ -1,4 +1,4 @@
1
- import { c as Loader } from '../packem_shared/types-15b79qIg.js';
1
+ import { c as Loader } from '../packem_shared/types-B7InbTq8.js';
2
2
  import 'cssnano';
3
3
  import 'lightningcss';
4
4
  import 'postcss';
@@ -1,5 +1,5 @@
1
1
  import { Options } from 'cssnano';
2
- import { M as Minifier } from '../packem_shared/types-15b79qIg.js';
2
+ import { M as Minifier } from '../packem_shared/types-B7InbTq8.js';
3
3
  import 'lightningcss';
4
4
  import 'postcss';
5
5
  import 'postcss-load-config';
@@ -1,4 +1,4 @@
1
- import { M as Minifier, a as InternalStyleOptions } from '../packem_shared/types-15b79qIg.js';
1
+ import { M as Minifier, a as InternalStyleOptions } from '../packem_shared/types-B7InbTq8.js';
2
2
  import 'cssnano';
3
3
  import 'lightningcss';
4
4
  import 'postcss';
@@ -0,0 +1,3 @@
1
+ var Y=Object.defineProperty;var N=(e,s)=>Y(e,"name",{value:s,configurable:!0});import{createFilter as ee}from"@rollup/pluginutils";import{createRollupLogger as se}from"@visulima/packem-share/utils";import{dirname as L,normalize as M,isAbsolute as te,relative as U,resolve as oe,parse as T,join as _,basename as V}from"@visulima/path";import{isRelative as ie}from"@visulima/path/utils";import re from"p-queue";import ne from"./concat-WcWAYbOc.js";import{inferSourceMapOption as ae,inferModeOption as ce,inferHandlerOption as W,inferOption as G,ensurePCSSOption as R,ensurePCSSPlugins as le}from"./inferModeOption-9h3Eq6JH.js";import{m as q}from"./sourcemap-CB6ochh0.js";var de=Object.defineProperty,ue=N((e,s)=>de(e,"name",{value:s,configurable:!0}),"r");const J=ue((e,s)=>{if(!s)return!1;if(typeof s=="function")return s(e);if(typeof s.test=="function")return s.test(e);throw new Error("Invalid condition type")},"matchFile");var pe=Object.defineProperty,fe=N((e,s)=>pe(e,"name",{value:s,configurable:!0}),"a");const me=4,ge=process.env.UV_THREADPOOL_SIZE?Number.parseInt(process.env.UV_THREADPOOL_SIZE,10):me;class he{static{N(this,"g")}static{fe(this,"LoaderManager")}test;loaders=new Map;options;workQueue;logger;constructor({extensions:s,loaders:c,logger:y,options:O}){this.test=S=>s.some(f=>S.toLowerCase().endsWith(f)),c.length>0&&this.add(...c),this.options=O,this.logger=y}add(...s){for(const c of s)this.loaders.has(c.name)||this.loaders.set(c.name,c)}isSupported(s){if(this.test(s))return!0;for(const[,c]of this.loaders)if(J(s,c.test))return!0;return!1}async process(s,c){this.workQueue||(this.workQueue=new re({concurrency:ge-1}));for await(const[y,O]of this.loaders){const S={...c,options:this.options[y]??{}};if(O.alwaysProcess||J(S.id,O.test)){this.logger.debug({message:`Processing ${y} loader for ${S.id}`,plugin:"css"});try{const f=await this.workQueue.add(O.process.bind(S,s));f&&(s={...f,extracted:f.extracted??s.extracted,meta:f.meta??s.meta},this.logger.debug({message:`Completed ${y} loader for ${S.id}`,outputSize:f.code?.length||0,plugin:"css"}))}catch(f){throw this.logger.error({file:S.id,loader:y,message:`Error in ${y} loader for ${S.id}: ${f instanceof Error?f.message:String(f)}`,plugin:"css"}),f}}}return s}}var xe=Object.defineProperty,z=N((e,s)=>xe(e,"name",{value:s,configurable:!0}),"b");const ye=z(async(e,s)=>e.sort((c,y)=>s.indexOf(c.name)-s.indexOf(y.name)),"sortByNameOrder"),Fe=z(async(e,s,c,y,O,S,f,Z,K)=>{const C={...K,...e.alias},B=ee(e.include,e.exclude),E=ae(e.sourceMap),i={...ce(e.mode),autoModules:e.autoModules??!1,dts:e.dts,extensions:e.extensions,namedExports:e.namedExports};let a,I,H=!1;if(e.loaders)for(const r of e.loaders)r.name==="postcss"&&(H=!0);else e.loaders=[];H&&(i.postcss={...e.postcss,config:G(e.postcss?.config,{}),import:W(e.postcss?.import,C),modules:G(e.postcss?.modules,void 0),to:e.postcss?.to,url:W(e.postcss?.url,C)});let b=[];const F=z((r,d)=>{const g=[];for(const o of Object.keys(r)){const u=new Set;let h=[o];do{const $=[];for(const m of h){if(u.has(m))continue;if(I.isSupported(m)){B(m)&&$.push(m);continue}u.add(m);const P=d(m);P&&$.push(...P.importedIds)}h=$}while(h.some($=>!I.isSupported($)));g.push(...h)}return g},"traverseImportedModules");return{augmentChunkHash(r){if(b.length===0)return;const d=F(r.modules,this.getModuleInfo),g=b.filter(o=>d.includes(o.id)).sort((o,u)=>d.lastIndexOf(o.id)-d.lastIndexOf(u.id)).map(o=>`${V(o.id)}:${o.css}`);if(g.length!==0)return g.join(":")},async buildStart(){b=[],a=se(this,"css"),H&&i.postcss&&(e.postcss?.parser&&(i.postcss.parser=await R(e.postcss.parser,"parser",c,a)),e.postcss?.syntax&&(i.postcss.syntax=await R(e.postcss.syntax,"syntax",c,a)),e.postcss?.stringifier&&(i.postcss.stringifier=await R(e.postcss.stringifier,"stringifier",c,a)),e.postcss?.plugins&&(i.postcss.plugins=await le(e.postcss.plugins,c,a))),I=new he({extensions:i.extensions,loaders:await ye(e.loaders||[],["sourcemap","stylus","less","sass","postcss"]),logger:a,options:{...e,...i,alias:C}}),a.info({extract:typeof i.extract=="string"?i.extract:"individual",loaders:e.loaders?.map(r=>r.name)||[],message:"CSS plugin initialized",minify:!!(Z&&e.minifier),namedExports:!!i.namedExports,plugin:"css",sourceMap:!!S}),typeof i.inject=="object"&&i.inject.treeshakeable&&(i.namedExports=!1,a.info({message:"Disabling named exports due to `inject.treeshakeable` option",plugin:"css"}))},async generateBundle(r,d){if(b.length===0||!(r.dir||r.file))return;const g=Object.values(d),o=r.dir??L(r.file),u=g.filter(n=>n.type==="chunk"),h=u.filter(n=>!n.facadeModuleId),$=r.preserveModules?u:u.filter(n=>n.isEntry||n.isDynamicEntry),m=[],P=z(async(n,l)=>{const t=typeof i.extract=="string"?M(i.extract).replace(/^\.[/\\]/,""):M(`${n}.css`);te(t)&&this.error(["Extraction path must be relative to the output directory,",`which is ${U(c,o)}`].join(`
2
+ `)),ie(t)&&this.error(["Extraction path must be nested inside output directory,",`which is ${U(c,o)}`].join(`
3
+ `));const w=b.filter(x=>l.includes(x.id)).sort((x,v)=>l.lastIndexOf(x.id)-l.lastIndexOf(v.id)),D=await ne(w);return{css:D.css,map:q(D.map.toString()).relative(L(oe(o,t))).toString(),name:t}},"getExtractedData"),A=z(n=>{if(r.file)return T(r.file).name;if(r.preserveModules){const{dir:l,name:t}=T(n.fileName);return l?_(l,t):t}return n.name},"getName"),k=[];if(typeof i.extract=="string"){a.debug({message:`Extracting to ${i.extract}`,prefix:"css"});const n=[];for(const t of h){const w=F(t.modules,this.getModuleInfo);k.push(...w),n.push(...w)}for(const t of $)n.push(...F(t.modules,this.getModuleInfo).filter(w=>!k.includes(w)));const l=A(u[0]);m.push([l,n])}else{a.debug({message:"Extracting to individual files",prefix:"css"});for(const n of h){const l=F(n.modules,this.getModuleInfo);if(l.length===0)continue;k.push(...l);const t=A(n);m.push([t,l])}for(const n of $){const l=F(n.modules,this.getModuleInfo).filter(w=>!k.includes(w));if(l.length===0)continue;const t=A(n);m.push([t,l])}}for await(const[n,l]of m){const t=await P(n,l);if(typeof e.onExtract=="function"&&!e.onExtract(t))continue;if(Z&&e.minifier){a.info({message:`Minifying ${t.name} with ${e.minifier.name}`,prefix:"css"});const{css:x,map:v}=await e.minifier.handler.bind({browserTargets:s,logger:a})(t,E,e[e.minifier.name]??{});t.css=x,t.map=v}const w={fileName:t.name,name:t.name,names:[t.name],originalFileName:t.name,originalFileNames:[t.name],source:t.css,type:"asset"},D=this.emitFile(w);if(a.info({chunkIds:l.length,hasSourceMap:!!(t.map&&E),message:`Emitted CSS file: ${t.name}`,plugin:"css",size:t.css.length}),t.map&&E){const x=this.getFileName(D);let v="assert";typeof r.assetFileNames=="string"?v=M(L(r.assetFileNames)):typeof r.assetFileNames=="function"&&(v=M(L(r.assetFileNames(w))));const j=q(t.map).modify(p=>(p.file=V(x),p)).modifySources(p=>{if(p==="<no source>"||v.length<=1)return p;p=`../${p}`;for(const Q of v)Q==="/"&&(p=`../${p}`);return p});if(E.inline)j.modify(p=>E.transform?.(p,M(_(o,x)))),d[x].source+=j.toCommentData(),a.debug({message:`Generated inline source map for ${x}`,plugin:"css"});else{const p=`${x}.map`;j.modify(X=>E.transform?.(X,M(_(o,p)))),this.emitFile({fileName:p,source:j.toString(),type:"asset"});const{base:Q}=T(p);d[x].source+=j.toCommentFile(Q),a.debug({message:`Generated external source map: ${p}`,plugin:"css"})}}}m.length>0&&a.info({filesEmitted:m.length,message:"CSS processing complete",plugin:"css",totalExtracted:b.length,totalSize:m.reduce((n,[,l])=>n+l.length,0)})},name:"rollup-plugin-css",async transform(r,d){if(!B(d)||!I.isSupported(d))return;if(r.replaceAll(/\s/g,"")===""){a.debug({message:`Skipping empty file: ${d}`,plugin:"css"});return}a.info({message:`Processing CSS file: ${d}`,plugin:"css",size:r.length}),typeof e.onImport=="function"&&e.onImport(r,d);const g={alias:C,assets:new Map,autoModules:i.autoModules,browserTargets:s,cwd:c,debug:f,deps:new Set,dts:i.dts,emit:i.emit,environment:O,extensions:i.extensions,extract:i.extract,id:d,inject:i.inject,inline:i.inline,logger:a,namedExports:i.namedExports,options:{},plugin:this,sourceDir:y,sourceMap:E,useSourcemap:S},o=await I.process({code:r},g);a.info({assets:g.assets.size,dependencies:g.deps.size,hasExtracted:!!o.extracted,message:`Processed ${d}`,outputSize:o.code.length,plugin:"css"});for(const u of g.deps)this.addWatchFile(u);for(const[u,h]of g.assets)this.emitFile({fileName:u,source:h,type:"asset"}),a.debug({message:`Emitted asset: ${u}`,plugin:"css",size:h.length});if(o.extracted){const{id:u}=o.extracted;b=b.filter(h=>h.id!==u),b.push(o.extracted),a.debug({cssSize:o.extracted.css.length,hasSourceMap:!!o.extracted.map,message:`Extracted CSS from ${u}`,plugin:"css"})}return{code:o.code,map:E&&o.map?o.map:{mappings:""},meta:{styles:o.meta},moduleSideEffects:o.extracted?!0:void 0}}}},"cssPlugin");export{Fe as default};
@@ -61,7 +61,25 @@ type SassLoaderOptions = {
61
61
  warnRuleAsWarning?: boolean;
62
62
  } & (Omit<StringOptions<"sync">, "charset" | "indentedSyntax"> | Omit<StringOptions$1<"sync">, "charset" | "indentedSyntax">);
63
63
 
64
- type StylusLoaderOptions = RenderOptions;
64
+ type StylusLoaderContext = {
65
+ environment: Environment;
66
+ resourcePath: string;
67
+ rootContext: string;
68
+ };
69
+ type StylusPlugin = string | ((renderer: unknown) => void);
70
+ type StylusDefinition = [string, unknown] | [string, unknown, boolean];
71
+ type StylusLoaderOptions = {
72
+ additionalData?: string | ((content: string, loaderContext: StylusLoaderContext) => Promise<string> | string);
73
+ disableCache?: boolean;
74
+ hoistAtrules?: boolean;
75
+ implementation?: string | ((code: string, options?: unknown) => unknown);
76
+ import?: string[];
77
+ include?: string[];
78
+ includeCSS?: boolean;
79
+ lineNumbers?: boolean;
80
+ define?: Record<string, unknown> | StylusDefinition[];
81
+ use?: StylusPlugin[];
82
+ } & RenderOptions;
65
83
 
66
84
  interface Extracted {
67
85
  css: string;
@@ -185,4 +203,4 @@ interface StyleOptions {
185
203
  stylus?: StylusLoaderOptions;
186
204
  }
187
205
 
188
- export type { AutoModules as A, ExtractedData as E, InjectOptions as I, LightningCSSOptions as L, Minifier as M, PostCSSConfigLoaderOptions as P, StyleOptions as S, InternalStyleOptions as a, PostCSSOptions as b, Loader as c, LESSLoaderOptions as d, SassLoaderOptions as e, SassLoaderContext as f, StylusLoaderOptions as g, Extracted as h, LoaderContext as i };
206
+ export type { AutoModules as A, ExtractedData as E, InjectOptions as I, LightningCSSOptions as L, Minifier as M, PostCSSConfigLoaderOptions as P, StyleOptions as S, InternalStyleOptions as a, PostCSSOptions as b, Loader as c, LESSLoaderOptions as d, SassLoaderOptions as e, SassLoaderContext as f, StylusLoaderOptions as g, StylusDefinition as h, StylusLoaderContext as i, StylusPlugin as j, Extracted as k, LoaderContext as l };
@@ -1,5 +1,5 @@
1
1
  import { SourceMapGenerator, RawSourceMap, SourceMapConsumer } from 'source-map-js';
2
- import { h as Extracted, b as PostCSSOptions, S as StyleOptions, a as InternalStyleOptions, i as LoaderContext } from '../packem_shared/types-15b79qIg.js';
2
+ import { k as Extracted, b as PostCSSOptions, S as StyleOptions, a as InternalStyleOptions, l as LoaderContext } from '../packem_shared/types-B7InbTq8.js';
3
3
  import { RollupLogger } from '@visulima/packem-share/utils';
4
4
  import { Result } from 'postcss-load-config';
5
5
  import { NapiResolveOptions } from 'oxc-resolver';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/rollup-plugin-css",
3
- "version": "1.0.0-alpha.29",
3
+ "version": "1.0.0-alpha.30",
4
4
  "description": "CSS processing plugin for packem",
5
5
  "keywords": [
6
6
  "visulima",
@@ -99,7 +99,7 @@
99
99
  "@rollup/pluginutils": "5.3.0",
100
100
  "@visulima/fs": "4.1.0",
101
101
  "@visulima/package": "4.1.7",
102
- "@visulima/packem-share": "1.0.0-alpha.30",
102
+ "@visulima/packem-share": "1.0.0-alpha.31",
103
103
  "@visulima/path": "2.0.5",
104
104
  "mlly": "1.8.2",
105
105
  "oxc-resolver": "11.19.1",
@@ -1,3 +0,0 @@
1
- var Y=Object.defineProperty;var N=(e,t)=>Y(e,"name",{value:t,configurable:!0});import{createFilter as ee}from"@rollup/pluginutils";import{createRollupLogger as se}from"@visulima/packem-share/utils";import{dirname as L,normalize as M,isAbsolute as te,relative as U,resolve as oe,parse as T,join as _,basename as V}from"@visulima/path";import{isRelative as ie}from"@visulima/path/utils";import re from"p-queue";import ne from"./concat-WcWAYbOc.js";import{inferSourceMapOption as ae,inferModeOption as ce,inferHandlerOption as W,inferOption as G,ensurePCSSOption as R,ensurePCSSPlugins as le}from"./inferModeOption-9h3Eq6JH.js";import{m as q}from"./sourcemap-CB6ochh0.js";var ue=Object.defineProperty,de=N((e,t)=>ue(e,"name",{value:t,configurable:!0}),"r");const J=de((e,t)=>{if(!t)return!1;if(typeof t=="function")return t(e);if(typeof t.test=="function")return t.test(e);throw new Error("Invalid condition type")},"matchFile");var pe=Object.defineProperty,fe=N((e,t)=>pe(e,"name",{value:t,configurable:!0}),"a");const me=4,ge=process.env.UV_THREADPOOL_SIZE?Number.parseInt(process.env.UV_THREADPOOL_SIZE,10):me;class he{static{N(this,"c")}static{fe(this,"LoaderManager")}test;loaders=new Map;options;workQueue;logger;constructor({extensions:t,loaders:c,logger:y,options:O}){this.test=S=>t.some(g=>S.toLowerCase().endsWith(g)),c.length>0&&this.add(...c),this.options=O,this.logger=y}add(...t){for(const c of t)this.loaders.has(c.name)||this.loaders.set(c.name,c)}isSupported(t){if(this.test(t))return!0;for(const[,c]of this.loaders)if(J(t,c.test))return!0;return!1}async process(t,c){this.workQueue||(this.workQueue=new re({concurrency:ge-1}));for await(const[y,O]of this.loaders){const S={...c,options:this.options[y]??{}};if(O.alwaysProcess||J(S.id,O.test)){this.logger.debug({message:`Processing ${y} loader for ${S.id}`,plugin:"css"});try{const g=await this.workQueue.add(O.process.bind(S,t));g&&(t=g,this.logger.debug({message:`Completed ${y} loader for ${S.id}`,outputSize:g.code?.length||0,plugin:"css"}))}catch(g){throw this.logger.error({file:S.id,loader:y,message:`Error in ${y} loader for ${S.id}: ${g instanceof Error?g.message:String(g)}`,plugin:"css"}),g}}}return t}}var xe=Object.defineProperty,z=N((e,t)=>xe(e,"name",{value:t,configurable:!0}),"b");const ye=z(async(e,t)=>e.sort((c,y)=>t.indexOf(c.name)-t.indexOf(y.name)),"sortByNameOrder"),Fe=z(async(e,t,c,y,O,S,g,Z,K)=>{const C={...K,...e.alias},B=ee(e.include,e.exclude),E=ae(e.sourceMap),i={...ce(e.mode),autoModules:e.autoModules??!1,dts:e.dts,extensions:e.extensions,namedExports:e.namedExports};let a,I,H=!1;if(e.loaders)for(const r of e.loaders)r.name==="postcss"&&(H=!0);else e.loaders=[];H&&(i.postcss={...e.postcss,config:G(e.postcss?.config,{}),import:W(e.postcss?.import,C),modules:G(e.postcss?.modules,void 0),to:e.postcss?.to,url:W(e.postcss?.url,C)});let b=[];const F=z((r,u)=>{const m=[];for(const o of Object.keys(r)){const d=new Set;let h=[o];do{const $=[];for(const f of h){if(d.has(f))continue;if(I.isSupported(f)){B(f)&&$.push(f);continue}d.add(f);const P=u(f);P&&$.push(...P.importedIds)}h=$}while(h.some($=>!I.isSupported($)));m.push(...h)}return m},"traverseImportedModules");return{augmentChunkHash(r){if(b.length===0)return;const u=F(r.modules,this.getModuleInfo),m=b.filter(o=>u.includes(o.id)).sort((o,d)=>u.lastIndexOf(o.id)-u.lastIndexOf(d.id)).map(o=>`${V(o.id)}:${o.css}`);if(m.length!==0)return m.join(":")},async buildStart(){b=[],a=se(this,"css"),H&&i.postcss&&(e.postcss?.parser&&(i.postcss.parser=await R(e.postcss.parser,"parser",c,a)),e.postcss?.syntax&&(i.postcss.syntax=await R(e.postcss.syntax,"syntax",c,a)),e.postcss?.stringifier&&(i.postcss.stringifier=await R(e.postcss.stringifier,"stringifier",c,a)),e.postcss?.plugins&&(i.postcss.plugins=await le(e.postcss.plugins,c,a))),I=new he({extensions:i.extensions,loaders:await ye(e.loaders||[],["sourcemap","stylus","less","sass","postcss"]),logger:a,options:{...e,...i,alias:C}}),a.info({extract:typeof i.extract=="string"?i.extract:"individual",loaders:e.loaders?.map(r=>r.name)||[],message:"CSS plugin initialized",minify:!!(Z&&e.minifier),namedExports:!!i.namedExports,plugin:"css",sourceMap:!!S}),typeof i.inject=="object"&&i.inject.treeshakeable&&(i.namedExports=!1,a.info({message:"Disabling named exports due to `inject.treeshakeable` option",plugin:"css"}))},async generateBundle(r,u){if(b.length===0||!(r.dir||r.file))return;const m=Object.values(u),o=r.dir??L(r.file),d=m.filter(n=>n.type==="chunk"),h=d.filter(n=>!n.facadeModuleId),$=r.preserveModules?d:d.filter(n=>n.isEntry||n.isDynamicEntry),f=[],P=z(async(n,l)=>{const s=typeof i.extract=="string"?M(i.extract).replace(/^\.[/\\]/,""):M(`${n}.css`);te(s)&&this.error(["Extraction path must be relative to the output directory,",`which is ${U(c,o)}`].join(`
2
- `)),ie(s)&&this.error(["Extraction path must be nested inside output directory,",`which is ${U(c,o)}`].join(`
3
- `));const w=b.filter(x=>l.includes(x.id)).sort((x,v)=>l.lastIndexOf(x.id)-l.lastIndexOf(v.id)),D=await ne(w);return{css:D.css,map:q(D.map.toString()).relative(L(oe(o,s))).toString(),name:s}},"getExtractedData"),A=z(n=>{if(r.file)return T(r.file).name;if(r.preserveModules){const{dir:l,name:s}=T(n.fileName);return l?_(l,s):s}return n.name},"getName"),k=[];if(typeof i.extract=="string"){a.debug({message:`Extracting to ${i.extract}`,prefix:"css"});const n=[];for(const s of h){const w=F(s.modules,this.getModuleInfo);k.push(...w),n.push(...w)}for(const s of $)n.push(...F(s.modules,this.getModuleInfo).filter(w=>!k.includes(w)));const l=A(d[0]);f.push([l,n])}else{a.debug({message:"Extracting to individual files",prefix:"css"});for(const n of h){const l=F(n.modules,this.getModuleInfo);if(l.length===0)continue;k.push(...l);const s=A(n);f.push([s,l])}for(const n of $){const l=F(n.modules,this.getModuleInfo).filter(w=>!k.includes(w));if(l.length===0)continue;const s=A(n);f.push([s,l])}}for await(const[n,l]of f){const s=await P(n,l);if(typeof e.onExtract=="function"&&!e.onExtract(s))continue;if(Z&&e.minifier){a.info({message:`Minifying ${s.name} with ${e.minifier.name}`,prefix:"css"});const{css:x,map:v}=await e.minifier.handler.bind({browserTargets:t,logger:a})(s,E,e[e.minifier.name]??{});s.css=x,s.map=v}const w={fileName:s.name,name:s.name,names:[s.name],originalFileName:s.name,originalFileNames:[s.name],source:s.css,type:"asset"},D=this.emitFile(w);if(a.info({chunkIds:l.length,hasSourceMap:!!(s.map&&E),message:`Emitted CSS file: ${s.name}`,plugin:"css",size:s.css.length}),s.map&&E){const x=this.getFileName(D);let v="assert";typeof r.assetFileNames=="string"?v=M(L(r.assetFileNames)):typeof r.assetFileNames=="function"&&(v=M(L(r.assetFileNames(w))));const j=q(s.map).modify(p=>(p.file=V(x),p)).modifySources(p=>{if(p==="<no source>"||v.length<=1)return p;p=`../${p}`;for(const Q of v)Q==="/"&&(p=`../${p}`);return p});if(E.inline)j.modify(p=>E.transform?.(p,M(_(o,x)))),u[x].source+=j.toCommentData(),a.debug({message:`Generated inline source map for ${x}`,plugin:"css"});else{const p=`${x}.map`;j.modify(X=>E.transform?.(X,M(_(o,p)))),this.emitFile({fileName:p,source:j.toString(),type:"asset"});const{base:Q}=T(p);u[x].source+=j.toCommentFile(Q),a.debug({message:`Generated external source map: ${p}`,plugin:"css"})}}}f.length>0&&a.info({filesEmitted:f.length,message:"CSS processing complete",plugin:"css",totalExtracted:b.length,totalSize:f.reduce((n,[,l])=>n+l.length,0)})},name:"rollup-plugin-css",async transform(r,u){if(!B(u)||!I.isSupported(u))return;if(r.replaceAll(/\s/g,"")===""){a.debug({message:`Skipping empty file: ${u}`,plugin:"css"});return}a.info({message:`Processing CSS file: ${u}`,plugin:"css",size:r.length}),typeof e.onImport=="function"&&e.onImport(r,u);const m={alias:C,assets:new Map,autoModules:i.autoModules,browserTargets:t,cwd:c,debug:g,deps:new Set,dts:i.dts,emit:i.emit,environment:O,extensions:i.extensions,extract:i.extract,id:u,inject:i.inject,inline:i.inline,logger:a,namedExports:i.namedExports,options:{},plugin:this,sourceDir:y,sourceMap:E,useSourcemap:S},o=await I.process({code:r},m);a.info({assets:m.assets.size,dependencies:m.deps.size,hasExtracted:!!o.extracted,message:`Processed ${u}`,outputSize:o.code.length,plugin:"css"});for(const d of m.deps)this.addWatchFile(d);for(const[d,h]of m.assets)this.emitFile({fileName:d,source:h,type:"asset"}),a.debug({message:`Emitted asset: ${d}`,plugin:"css",size:h.length});if(o.extracted){const{id:d}=o.extracted;b=b.filter(h=>h.id!==d),b.push(o.extracted),a.debug({cssSize:o.extracted.css.length,hasSourceMap:!!o.extracted.map,message:`Extracted CSS from ${d}`,plugin:"css"})}return{code:o.code,map:E&&o.map?o.map:{mappings:""},meta:{styles:o.meta},moduleSideEffects:o.extracted?!0:void 0}}}},"cssPlugin");export{Fe as default};