@tailwindcss/vite 4.0.0-alpha.31 → 4.0.0-alpha.32
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/dist/index.mjs +1 -1
- package/package.json +5 -4
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{compile as
|
|
1
|
+
import{compile as T,env as m,normalizePath as R}from"@tailwindcss/node";import{clearRequireCache as U}from"@tailwindcss/node/require-cache";import{Scanner as P}from"@tailwindcss/oxide";import{Features as B,transform as G}from"lightningcss";import x from"node:fs/promises";import h from"node:path";import{sveltePreprocess as F}from"svelte-preprocess";var M=/[?&](raw|url)\b/;function V(){let a=[],i=null,l=!1,u=!1,f=new w(()=>new Set),p=new P({}),r=new w(e=>new y(e,()=>f,i.base));function d(e,t,s,o){let n=!1;for(let c of p.scanFiles([{content:t,extension:s}]))n=!0,f.get(e).add(c);n&&g(o)}function g(e){for(let t of a){let s=[];for(let[o,n]of r.entries()){let c=t.moduleGraph.getModuleById(o);if(!c){if(n.builtBeforeTransform)return;e||r.delete(o);continue}r.get(o).requiresRebuild=!1,t.moduleGraph.invalidateModule(c),s.push({type:`${c.type}-update`,path:c.url,acceptedPath:c.url,timestamp:Date.now()})}s.length>0&&t.hot.send({type:"update",updates:s})}}async function b(e,t){let s=e.lastContent,o=await e.generate(s,t);if(o===!1)return;m.DEBUG&&console.time("[@tailwindcss/vite] Optimize CSS");let n=q(o,{minify:u});return m.DEBUG&&console.timeEnd("[@tailwindcss/vite] Optimize CSS"),n}async function C(e,t,s){let o={...e,getCombinedSourcemap:()=>{throw new Error("getCombinedSourcemap not implemented")}};for(let n of i.plugins){if(!n.transform||n.name.startsWith("@tailwindcss/"))continue;if(n.name.startsWith("vite:")&&n.name!=="vite:css"&&n.name!=="vite:css-post"&&n.name!=="vite:vue")continue;if(n.name==="ssr-styles")continue;let c="handler"in n.transform?n.transform.handler:n.transform;try{let v=await c.call(o,s,t);if(!v)continue;typeof v=="string"?s=v:v.code&&(s=v.code)}catch{console.error(`Error running ${n.name} on Tailwind CSS output. Skipping.`)}}return s}return[A(r),{name:"@tailwindcss/vite:scan",enforce:"pre",configureServer(e){a.push(e)},async configResolved(e){i=e,u=i.build.cssMinify!==!1,l=i.build.ssr!==!1&&i.build.ssr!==void 0},transformIndexHtml(e,{path:t}){d(t,e,"html",l)},transform(e,t,s){let o=D(t);S(t)||d(t,e,o,s?.ssr??!1)}},{name:"@tailwindcss/vite:generate:serve",apply:"serve",enforce:"pre",async transform(e,t,s){if(!S(t))return;let o=r.get(t);o.builtBeforeTransform&&(o.builtBeforeTransform.forEach(c=>this.addWatchFile(c)),o.builtBeforeTransform=void 0,o.requiresRebuild=!1),s?.ssr||await Promise.all(a.map(c=>c.waitForRequestsIdle(t)));let n=await o.generate(e,c=>this.addWatchFile(c));return n?{code:n}:(r.delete(t),e)}},{name:"@tailwindcss/vite:generate:build",apply:"build",enforce:"pre",async transform(e,t){if(!S(t))return;let s=r.get(t);if(s.builtBeforeTransform){s.builtBeforeTransform.forEach(n=>this.addWatchFile(n)),s.builtBeforeTransform=void 0;return}let o=await s.generate(e,n=>this.addWatchFile(n));return o?{code:o}:(r.delete(t),e)},async renderStart(){for(let[e,t]of r.entries()){let s=await b(t,()=>{});if(!s){r.delete(e);continue}await C(this,e,s)}}}]}function D(a){let[i]=a.split("?",2);return h.extname(i).slice(1)}function S(a){if(a.includes("/.vite/"))return;let i=D(a);return(i==="css"||i==="vue"&&a.includes("&lang.css")||i==="astro"&&a.includes("&lang.css")||i==="svelte"&&a.includes("&lang.css"))&&!M.test(a)}function q(a,{file:i="input.css",minify:l=!1}={}){function u(f){return G({filename:i,code:f,minify:l,sourceMap:!1,drafts:{customMedia:!0},nonStandard:{deepSelectorCombinator:!0},include:B.Nesting,exclude:B.LogicalProperties,targets:{safari:16<<16|1024},errorRecovery:!0}).code}return u(u(Buffer.from(a))).toString()}function E(a){return h.resolve(a.replace(/\?.*$/,""))}var w=class extends Map{constructor(l){super();this.factory=l}get(l){let u=super.get(l);return u===void 0&&(u=this.factory(l,this),this.set(l,u)),u}},y=class{constructor(i,l,u){this.id=i;this.getSharedCandidates=l;this.base=u}lastContent="";builtBeforeTransform;compiler;requiresRebuild=!0;scanner;candidates=new Set;dependencies=new Set;basePath=null;async generate(i,l){this.lastContent=i;let u=E(this.id),f=h.dirname(h.resolve(u));if(!this.compiler||!this.scanner||this.requiresRebuild){U(Array.from(this.dependencies)),this.dependencies=new Set([E(u)]),m.DEBUG&&console.time("[@tailwindcss/vite] Setup compiler"),this.compiler=await T(i,{base:f,shouldRewriteUrls:!0,onDependency:d=>{l(d),this.dependencies.add(d)}}),m.DEBUG&&console.timeEnd("[@tailwindcss/vite] Setup compiler");let r=(this.compiler.root==="none"?[]:this.compiler.root===null?[]:[this.compiler.root]).concat(this.compiler.globs);this.scanner=new P({sources:r})}m.DEBUG&&console.time("[@tailwindcss/vite] Scan for candidates");for(let r of this.scanner.scan())this.candidates.add(r);m.DEBUG&&console.timeEnd("[@tailwindcss/vite] Scan for candidates");for(let r of this.scanner.files)l(r);for(let r of this.scanner.globs){if(r.pattern[0]==="!")continue;let d=h.relative(this.base,r.base);d[0]!=="."&&(d="./"+d),d=R(d),l(h.posix.join(d,r.pattern));let g=this.compiler.root;if(g!=="none"&&g!==null){let b=R(h.resolve(g.base,g.pattern));if(!await x.stat(b).then(e=>e.isDirectory(),()=>!1))throw new Error(`The path given to \`source(\u2026)\` must be a directory but got \`source(${b})\` instead.`);this.basePath=b}else g===null&&(this.basePath=null)}this.requiresRebuild=!0,m.DEBUG&&console.time("[@tailwindcss/vite] Build CSS");let p=this.compiler.build([...this.sharedCandidates(),...this.candidates]);return m.DEBUG&&console.timeEnd("[@tailwindcss/vite] Build CSS"),p}sharedCandidates(){if(!this.compiler)return new Set;if(this.compiler.root==="none")return new Set;let i=/^[A-Z]:/,l=f=>this.basePath===null||f.startsWith(this.basePath)?!0:i.test(f)?!1:!f.startsWith("/"),u=new Set;for(let[f,p]of this.getSharedCandidates())if(l(f))for(let r of p)u.add(r);return u}};function A(a){return{name:"@tailwindcss/svelte",api:{sveltePreprocess:F({aliases:[["postcss","tailwindcss"],["css","tailwindcss"]],async tailwindcss({content:i,attributes:l,filename:u}){if(!u)return;let f=u+"?svelte&type=style&lang.css",p=a.get(f);p.builtBeforeTransform=[];let r=await p.generate(i,d=>p?.builtBeforeTransform?.push(d));return r?{code:r,attributes:l}:(a.delete(f),{code:i,attributes:l})}})}}}export{V as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailwindcss/vite",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.32",
|
|
4
4
|
"description": "A utility-first CSS framework for rapidly building custom user interfaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -25,9 +25,10 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"lightningcss": "^1.26.0",
|
|
28
|
-
"
|
|
29
|
-
"tailwindcss": "4.0.0-alpha.
|
|
30
|
-
"
|
|
28
|
+
"svelte-preprocess": "^6.0.2",
|
|
29
|
+
"@tailwindcss/node": "4.0.0-alpha.32",
|
|
30
|
+
"tailwindcss": "4.0.0-alpha.32",
|
|
31
|
+
"@tailwindcss/oxide": "4.0.0-alpha.32"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@types/node": "^20.14.8",
|