@visulima/packem
Version:
A fast and modern bundler for Node.js and TypeScript.
2 lines (1 loc) • 1.17 kB
JavaScript
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-Crbje9In.mjs";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};