@salty-css/vite 0.0.1-alpha.136 → 0.0.1-alpha.138

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.
Files changed (3) hide show
  1. package/index.cjs +1 -1
  2. package/index.js +1 -1
  3. package/package.json +2 -2
package/index.cjs CHANGED
@@ -15,7 +15,7 @@
15
15
  ${Object.entries(x).map(([p,g])=>`${p}?: ${g}`).join(`
16
16
  `)}
17
17
  }
18
- `;f.writeFileSync(w,P)},L=async(e,t,s)=>{const n=H(t),i=l.join(s,"./temp");f.existsSync(i)||f.mkdirSync(i);const o=l.parse(t);let u=f.readFileSync(t,"utf8");u=u.replace(/styled\(([^"'`{,]+),/g,(j,S)=>{if(/^['"`]/.test(S))return j;const N=new RegExp(`import\\s?\\{[^{}]*${S}[^{}]*\\}\\s?from\\s?([^{};]+);`);if(!N.test(u))return j;const b=N.exec(u);if(b){const c=b.at(1);if(oe.some(x=>c==null?void 0:c.includes(x)))return j}return"styled('div',"});const m=l.join(s,"js",n+".js"),a=ne(e),r=await te(e);await X.build({stdin:{contents:u,sourcefile:o.base,resolveDir:o.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:m,format:r,target:["node20"],keepNames:!0,external:a,packages:"external"});const h=Date.now();return await import(`${m}?t=${h}`)},B=async e=>{const t=z(e),s=l.join(t,"salty.config.js"),n=Date.now(),{config:i}=await import(`${s}?t=${n}`);return i},re=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},xe=async(e,t=re())=>{try{const s=Date.now();t?Z.info("Generating CSS in production mode! 🔥"):Z.info("Generating CSS in development mode! 🚀");const n=[],i=[],o=z(e),u=l.join(o,"index.css");(()=>{f.existsSync(o)&&pe.execSync("rm -rf "+o),f.mkdirSync(o),f.mkdirSync(l.join(o,"css")),f.mkdirSync(l.join(o,"types"))})(),await Fe(e);const a=await B(e);async function r(c,y){const x=["node_modules","saltygen"],w=f.statSync(c);if(w.isDirectory()){const T=f.readdirSync(c);if(x.some(p=>c.includes(p)))return;await Promise.all(T.map(p=>r(l.join(c,p),l.join(y,p))))}else if(w.isFile()&&W(c)){const P=await L(e,c,o),p=[];Object.entries(P).forEach(([V,_])=>{if(_.isKeyframes&&_.css){const K=`a_${_.animationName}.css`,le=`css/${K}`,ue=l.join(o,le);n.push(K),f.writeFileSync(ue,_.css);return}if(!_.generator)return;const O=_.generator._withBuildContext({name:V,config:a,prod:t});i[O.priority]||(i[O.priority]=[]),i[O.priority].push(O.cssFileName),p.push(O.cssFileName);const ce=`css/${O.cssFileName}`,ae=l.join(o,ce);f.writeFileSync(ae,O.css)});const g=p.map(V=>`@import url('./${V}');`).join(`
18
+ `;f.writeFileSync(w,P)},L=async(e,t,s)=>{const n=H(t),i=l.join(s,"./temp");f.existsSync(i)||f.mkdirSync(i);const o=l.parse(t);let u=f.readFileSync(t,"utf8");u=u.replace(/styled\(([^"'`{,]+),/g,(j,S)=>{if(/^['"`]/.test(S))return j;const N=new RegExp(`import[^;]*${S}[,\\s{][^;]*from\\s?([^{};]+);`);if(!N.test(u))return j;const b=N.exec(u);if(b){const c=b.at(1);if(oe.some(x=>c==null?void 0:c.includes(x)))return j}return"styled('div',"});const m=l.join(s,"js",n+".js"),a=ne(e),r=await te(e);await X.build({stdin:{contents:u,sourcefile:o.base,resolveDir:o.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:m,format:r,target:["node20"],keepNames:!0,external:a,packages:"external"});const h=Date.now();return await import(`${m}?t=${h}`)},B=async e=>{const t=z(e),s=l.join(t,"salty.config.js"),n=Date.now(),{config:i}=await import(`${s}?t=${n}`);return i},re=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},xe=async(e,t=re())=>{try{const s=Date.now();t?Z.info("Generating CSS in production mode! 🔥"):Z.info("Generating CSS in development mode! 🚀");const n=[],i=[],o=z(e),u=l.join(o,"index.css");(()=>{f.existsSync(o)&&pe.execSync("rm -rf "+o),f.mkdirSync(o),f.mkdirSync(l.join(o,"css")),f.mkdirSync(l.join(o,"types"))})(),await Fe(e);const a=await B(e);async function r(c,y){const x=["node_modules","saltygen"],w=f.statSync(c);if(w.isDirectory()){const T=f.readdirSync(c);if(x.some(p=>c.includes(p)))return;await Promise.all(T.map(p=>r(l.join(c,p),l.join(y,p))))}else if(w.isFile()&&W(c)){const P=await L(e,c,o),p=[];Object.entries(P).forEach(([V,_])=>{if(_.isKeyframes&&_.css){const K=`a_${_.animationName}.css`,le=`css/${K}`,ue=l.join(o,le);n.push(K),f.writeFileSync(ue,_.css);return}if(!_.generator)return;const O=_.generator._withBuildContext({name:V,config:a,prod:t});i[O.priority]||(i[O.priority]=[]),i[O.priority].push(O.cssFileName),p.push(O.cssFileName);const ce=`css/${O.cssFileName}`,ae=l.join(o,ce);f.writeFileSync(ae,O.css)});const g=p.map(V=>`@import url('./${V}');`).join(`
19
19
  `),C=H(c,6),$=l.parse(c),M=E($.name),A=l.join(o,`css/f_${M}-${C}.css`);f.writeFileSync(A,g)}}await r(e,o);const h=n.map(c=>`@import url('./css/${c}');`).join(`
20
20
  `);let k=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
21
21
 
package/index.js CHANGED
@@ -233,7 +233,7 @@ const Ct = {
233
233
  let f = R(e, "utf8");
234
234
  f = f.replace(/styled\(([^"'`{,]+),/g, (S, h) => {
235
235
  if (/^['"`]/.test(h)) return S;
236
- const P = new RegExp(`import\\s?\\{[^{}]*${h}[^{}]*\\}\\s?from\\s?([^{};]+);`);
236
+ const P = new RegExp(`import[^;]*${h}[,\\s{][^;]*from\\s?([^{};]+);`);
237
237
  if (!P.test(f)) return S;
238
238
  const $ = P.exec(f);
239
239
  if ($) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/vite",
3
- "version": "0.0.1-alpha.136",
3
+ "version": "0.0.1-alpha.138",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -34,6 +34,6 @@
34
34
  }
35
35
  },
36
36
  "dependencies": {
37
- "@salty-css/core": "^0.0.1-alpha.136"
37
+ "@salty-css/core": "^0.0.1-alpha.138"
38
38
  }
39
39
  }