@salty-css/vite 0.1.0-alpha.9 → 0.1.0-refactor-add-additional-paths-to-config-cache.0

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/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var d=Object.create;var l=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var p=(t,e,s,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of m(e))!w.call(t,r)&&r!==s&&l(t,r,{get:()=>e[r],enumerable:!(a=y(e,r))||a.enumerable});return t};var f=(t,e,s)=>(s=t!=null?d(h(t)):{},p(e||!t||!t.__esModule?l(s,"default",{value:t,enumerable:!0}):s,t));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("@salty-css/core/compiler/helpers"),g=require("@salty-css/core/compiler/salty-compiler"),c=require("@salty-css/core/server"),F=async t=>{if(t==="react"||t===void 0)return(await import("@salty-css/react/transform-salty-file")).transformSaltyFile;throw new Error(`@salty-css/vite: framework "${t}" is not supported. Supported: react.`)},u=t=>{const e=new g.SaltyCompiler(t);let s;const a=()=>(s||(s=e.getFramework().then(F)),s);return{name:"stylegen",buildStart:async()=>await e.generateCss(),load:async r=>{if(i.isSaltyFile(r))return await(await a())(e,r)},handleHotUpdate:async({file:r,server:o})=>{await c.checkShouldRestart(r)&&o.restart()},watchChange:{handler:async(r,o)=>{i.isSaltyFile(r)&&o.event!=="delete"&&(await c.checkShouldRestart(r)||await e.generateFile(r))}}}};exports.default=u;exports.saltyPlugin=u;
1
+ "use strict";var h=Object.create;var c=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var v=(e,r,o,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of p(r))!w.call(e,s)&&s!==o&&c(e,s,{get:()=>r[s],enumerable:!(a=g(r,s))||a.enumerable});return e};var F=(e,r,o)=>(o=e!=null?h(C(e)):{},v(r||!e||!e.__esModule?c(o,"default",{value:e,enumerable:!0}):o,e));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("@salty-css/core/compiler/helpers"),S=require("@salty-css/core/compiler/salty-compiler"),d=require("@salty-css/core/compiler/copy-config-cache"),y=require("@salty-css/core/server"),m=require("path"),R=async e=>{if(e==="react"||e===void 0)return(await import("@salty-css/react/transform-salty-file")).transformSaltyFile;throw new Error(`@salty-css/vite: framework "${e}" is not supported. Supported: react.`)},f=(e,r={})=>{const o=new S.SaltyCompiler(e,{mode:r.mode});let a;const s=()=>(a||(a=o.getFramework().then(R)),a);let n;return{name:"stylegen",configResolved:t=>{n=t},buildStart:async()=>await o.generateCss(),load:async t=>{if(u.isSaltyFile(t))return await(await s())(o,t)},handleHotUpdate:async({file:t,server:i})=>{await y.checkShouldRestart(t)&&i.restart()},watchChange:{handler:async(t,i)=>{u.isSaltyFile(t)&&i.event!=="delete"&&(await y.checkShouldRestart(t)||await o.generateFile(t))}},closeBundle:async()=>{if(!n||n.command!=="build"||!o.isProduction)return;const t=n.build.outDir,i=m.isAbsolute(t)?t:m.resolve(n.root,t),l=d.resolveCopyConfigCacheDestinations(r.copyConfigCache,i,n.root);await d.copyConfigCacheTo(o,l)}}};exports.default=f;exports.saltyPlugin=f;
package/index.d.ts CHANGED
@@ -1,3 +1,20 @@
1
+ import { SaltyCompilerMode } from '@salty-css/core/compiler/salty-compiler';
2
+ import { CopyConfigCacheOption } from '@salty-css/core/compiler/copy-config-cache';
1
3
  import { PluginOption } from 'vite';
2
- export declare const saltyPlugin: (dir: string) => PluginOption;
4
+ export interface SaltyVitePluginOptions {
5
+ /**
6
+ * Explicit build mode. Defaults to NODE_ENV-based detection.
7
+ */
8
+ mode?: SaltyCompilerMode;
9
+ /**
10
+ * Where to copy the Salty `config-cache.json` after a production build.
11
+ *
12
+ * - `true` (default) → copy to the bundler's `build.outDir`.
13
+ * - `false` → no copy.
14
+ * - `string | string[]` → copy to the default destination PLUS each listed path.
15
+ * Directories receive `saltygen/cache/config-cache.json`; `.json` paths are used as-is.
16
+ */
17
+ copyConfigCache?: CopyConfigCacheOption;
18
+ }
19
+ export declare const saltyPlugin: (dir: string, options?: SaltyVitePluginOptions) => PluginOption;
3
20
  export default saltyPlugin;
package/index.js CHANGED
@@ -1,32 +1,43 @@
1
- import { isSaltyFile as n } from "@salty-css/core/compiler/helpers";
2
- import { SaltyCompiler as c } from "@salty-css/core/compiler/salty-compiler";
3
- import { checkShouldRestart as i } from "@salty-css/core/server";
4
- const m = async (a) => {
1
+ import { isSaltyFile as l } from "@salty-css/core/compiler/helpers";
2
+ import { SaltyCompiler as m } from "@salty-css/core/compiler/salty-compiler";
3
+ import { resolveCopyConfigCacheDestinations as u, copyConfigCacheTo as f } from "@salty-css/core/compiler/copy-config-cache";
4
+ import { checkShouldRestart as c } from "@salty-css/core/server";
5
+ import { isAbsolute as y, resolve as p } from "path";
6
+ const w = async (a) => {
5
7
  if (a === "react" || a === void 0)
6
8
  return (await import("@salty-css/react/transform-salty-file")).transformSaltyFile;
7
9
  throw new Error(`@salty-css/vite: framework "${a}" is not supported. Supported: react.`);
8
- }, p = (a) => {
9
- const r = new c(a);
10
- let s;
11
- const l = () => (s || (s = r.getFramework().then(m)), s);
10
+ }, S = (a, n = {}) => {
11
+ const o = new m(a, { mode: n.mode });
12
+ let i;
13
+ const d = () => (i || (i = o.getFramework().then(w)), i);
14
+ let e;
12
15
  return {
13
16
  name: "stylegen",
14
- buildStart: async () => await r.generateCss(),
17
+ configResolved: (t) => {
18
+ e = t;
19
+ },
20
+ buildStart: async () => await o.generateCss(),
15
21
  load: async (t) => {
16
- if (n(t))
17
- return await (await l())(r, t);
22
+ if (l(t))
23
+ return await (await d())(o, t);
18
24
  },
19
- handleHotUpdate: async ({ file: t, server: e }) => {
20
- await i(t) && e.restart();
25
+ handleHotUpdate: async ({ file: t, server: r }) => {
26
+ await c(t) && r.restart();
21
27
  },
22
28
  watchChange: {
23
- handler: async (t, e) => {
24
- n(t) && e.event !== "delete" && (await i(t) || await r.generateFile(t));
29
+ handler: async (t, r) => {
30
+ l(t) && r.event !== "delete" && (await c(t) || await o.generateFile(t));
25
31
  }
32
+ },
33
+ closeBundle: async () => {
34
+ if (!e || e.command !== "build" || !o.isProduction) return;
35
+ const t = e.build.outDir, r = y(t) ? t : p(e.root, t), s = u(n.copyConfigCache, r, e.root);
36
+ await f(o, s);
26
37
  }
27
38
  };
28
39
  };
29
40
  export {
30
- p as default,
31
- p as saltyPlugin
41
+ S as default,
42
+ S as saltyPlugin
32
43
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/vite",
3
- "version": "0.1.0-alpha.9",
3
+ "version": "0.1.0-refactor-add-additional-paths-to-config-cache.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -34,7 +34,7 @@
34
34
  }
35
35
  },
36
36
  "dependencies": {
37
- "@salty-css/core": "^0.1.0-alpha.9",
37
+ "@salty-css/core": "^0.1.0-refactor-add-additional-paths-to-config-cache.0",
38
38
  "vite": "^6.4.1"
39
39
  },
40
40
  "peerDependencies": {