@salty-css/webpack 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";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("path"),f=require("@salty-css/core/server"),g=require("fs"),u=require("@salty-css/core/compiler/helpers"),h=require("@salty-css/core/compiler/salty-compiler"),n=(t,e,c=!1,p=!1)=>{var a,l,r;const s=new h.SaltyCompiler(e);(l=(a=t.module)==null?void 0:a.rules)==null||l.push({test:u.saltyFileRegExp(),use:[{loader:d.resolve(__dirname,p?"./loader.cjs":"./loader.js"),options:{dir:e}}]}),c||(r=t.plugins)==null||r.push({apply:y=>{let o=!1;y.hooks.beforeCompile.tapPromise({name:"generateCss"},async()=>{o||(o=!0,await s.generateCss(),g.watch(e,{recursive:!0},async(m,i)=>{await f.checkShouldRestart(i)?await s.generateCss():u.isSaltyFile(i)&&await s.generateFile(e)}))})}})};exports.default=n;exports.saltyPlugin=n;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("path"),v=require("@salty-css/core/server"),w=require("fs"),h=require("@salty-css/core/compiler/helpers"),P=require("@salty-css/core/compiler/salty-compiler"),C=require("@salty-css/core/compiler/copy-config-cache"),f=(r,e,d=!1,g=!1,a={})=>{var i,l,n;const t=new P.SaltyCompiler(e,{mode:a.mode});(l=(i=r.module)==null?void 0:i.rules)==null||l.push({test:h.saltyFileRegExp(),use:[{loader:m.resolve(__dirname,g?"./loader.cjs":"./loader.js"),options:{dir:e,mode:a.mode}}]}),d||(n=r.plugins)==null||n.push({apply:o=>{var c;let u=!1;o.hooks.beforeCompile.tapPromise({name:"generateCss"},async()=>{u||(u=!0,await t.generateCss(),w.watch(e,{recursive:!0},async(p,s)=>{await v.checkShouldRestart(s)?await t.generateCss():h.isSaltyFile(s)&&await t.generateFile(e)}))}),(c=o.hooks.afterEmit)==null||c.tapPromise({name:"copyConfigCache"},async p=>{if(!t.isProduction)return;const s=o.outputPath||p.outputOptions.path;if(!s)return;const y=C.resolveCopyConfigCacheDestinations(a.copyConfigCache,s,e);await C.copyConfigCacheTo(t,y)})}})};exports.default=f;exports.saltyPlugin=f;
package/index.d.ts CHANGED
@@ -1,3 +1,21 @@
1
1
  import { Configuration } from 'webpack';
2
- export declare const saltyPlugin: (config: Configuration, dir: string, isServer?: boolean, cjs?: boolean) => void;
2
+ import { SaltyCompilerMode } from '@salty-css/core/compiler/salty-compiler';
3
+ import { CopyConfigCacheOption } from '@salty-css/core/compiler/copy-config-cache';
4
+ export interface SaltyWebpackPluginOptions {
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 webpack's `output.path`.
13
+ * - `false` → no copy.
14
+ * - `string | string[]` → copy to the default destination PLUS each listed path.
15
+ * For Next.js `output: 'standalone'`, supply the standalone output path here
16
+ * (e.g. `['.next/standalone/<project>']`) — it cannot be auto-detected.
17
+ */
18
+ copyConfigCache?: CopyConfigCacheOption;
19
+ }
20
+ export declare const saltyPlugin: (config: Configuration, dir: string, isServer?: boolean, cjs?: boolean, options?: SaltyWebpackPluginOptions) => void;
3
21
  export default saltyPlugin;
package/index.js CHANGED
@@ -1,31 +1,39 @@
1
- import { resolve as u } from "path";
2
- import { checkShouldRestart as f } from "@salty-css/core/server";
3
- import { watch as c } from "fs";
4
- import { saltyFileRegExp as y, isSaltyFile as d } from "@salty-css/core/compiler/helpers";
5
- import { SaltyCompiler as h } from "@salty-css/core/compiler/salty-compiler";
6
- const k = (s, e, m = !1, n = !1) => {
7
- var a, l, r;
8
- const t = new h(e);
9
- (l = (a = s.module) == null ? void 0 : a.rules) == null || l.push({
10
- test: y(),
1
+ import { resolve as y } from "path";
2
+ import { checkShouldRestart as C } from "@salty-css/core/server";
3
+ import { watch as d } from "fs";
4
+ import { saltyFileRegExp as g, isSaltyFile as w } from "@salty-css/core/compiler/helpers";
5
+ import { SaltyCompiler as F } from "@salty-css/core/compiler/salty-compiler";
6
+ import { resolveCopyConfigCacheDestinations as P, copyConfigCacheTo as v } from "@salty-css/core/compiler/copy-config-cache";
7
+ const b = (r, e, c = !1, h = !1, a = {}) => {
8
+ var i, l, n;
9
+ const t = new F(e, { mode: a.mode });
10
+ (l = (i = r.module) == null ? void 0 : i.rules) == null || l.push({
11
+ test: g(),
11
12
  use: [
12
13
  {
13
- loader: u(__dirname, n ? "./loader.cjs" : "./loader.js"),
14
- options: { dir: e }
14
+ loader: y(__dirname, h ? "./loader.cjs" : "./loader.js"),
15
+ options: { dir: e, mode: a.mode }
15
16
  }
16
17
  ]
17
- }), m || (r = s.plugins) == null || r.push({
18
- apply: (p) => {
19
- let o = !1;
20
- p.hooks.beforeCompile.tapPromise({ name: "generateCss" }, async () => {
21
- o || (o = !0, await t.generateCss(), c(e, { recursive: !0 }, async (g, i) => {
22
- await f(i) ? await t.generateCss() : d(i) && await t.generateFile(e);
18
+ }), c || (n = r.plugins) == null || n.push({
19
+ apply: (s) => {
20
+ var p;
21
+ let m = !1;
22
+ s.hooks.beforeCompile.tapPromise({ name: "generateCss" }, async () => {
23
+ m || (m = !0, await t.generateCss(), d(e, { recursive: !0 }, async (u, o) => {
24
+ await C(o) ? await t.generateCss() : w(o) && await t.generateFile(e);
23
25
  }));
26
+ }), (p = s.hooks.afterEmit) == null || p.tapPromise({ name: "copyConfigCache" }, async (u) => {
27
+ if (!t.isProduction) return;
28
+ const o = s.outputPath || u.outputOptions.path;
29
+ if (!o) return;
30
+ const f = P(a.copyConfigCache, o, e);
31
+ await v(t, f);
24
32
  });
25
33
  }
26
34
  });
27
35
  };
28
36
  export {
29
- k as default,
30
- k as saltyPlugin
37
+ b as default,
38
+ b as saltyPlugin
31
39
  };
package/loader.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var i=Object.create;var s=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var m=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var u=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of p(e))!w.call(t,o)&&o!==r&&s(t,o,{get:()=>e[o],enumerable:!(a=l(e,o))||a.enumerable});return t};var d=(t,e,r)=>(r=t!=null?i(m(t)):{},u(e||!t||!t.__esModule?s(r,"default",{value:t,enumerable:!0}):r,t));const f=require("@salty-css/core/compiler/salty-compiler"),n=new WeakMap,c=new Map,h=async t=>{if(t==="react"||t===void 0)return(await import("@salty-css/react/transform-salty-file")).transformSaltyFile;throw new Error(`@salty-css/webpack: framework "${t}" is not supported. Supported: react.`)},g=t=>{let e=c.get(t);return e||(e=new f.SaltyCompiler(t),c.set(t,e)),e},y=t=>{let e=n.get(t);return e||(e=t.getFramework().then(h),n.set(t,e)),e};async function C(){const{dir:t}=this.getOptions(),{resourcePath:e}=this,r=g(t);return await r.generateFile(e),await(await y(r))(r,e)}module.exports=C;
1
+ "use strict";var i=Object.create;var s=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var m=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var u=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of p(e))!w.call(t,a)&&a!==r&&s(t,a,{get:()=>e[a],enumerable:!(o=l(e,a))||o.enumerable});return t};var d=(t,e,r)=>(r=t!=null?i(m(t)):{},u(e||!t||!t.__esModule?s(r,"default",{value:t,enumerable:!0}):r,t));const h=require("@salty-css/core/compiler/salty-compiler"),n=new WeakMap,c=new Map,f=async t=>{if(t==="react"||t===void 0)return(await import("@salty-css/react/transform-salty-file")).transformSaltyFile;throw new Error(`@salty-css/webpack: framework "${t}" is not supported. Supported: react.`)},y=(t,e)=>{const r=`${t}|${e??""}`;let o=c.get(r);return o||(o=new h.SaltyCompiler(t,{mode:e}),c.set(r,o)),o},g=t=>{let e=n.get(t);return e||(e=t.getFramework().then(f),n.set(t,e)),e};async function C(){const{dir:t,mode:e}=this.getOptions(),{resourcePath:r}=this,o=y(t,e);return await o.generateFile(r),await(await g(o))(o,r)}module.exports=C;
package/loader.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { LoaderContext } from 'webpack';
2
+ import { SaltyCompilerMode } from '@salty-css/core/compiler/salty-compiler';
2
3
  interface SaltyLoaderOptions {
3
4
  dir: string;
5
+ mode?: SaltyCompilerMode;
4
6
  }
5
7
  type WebpackLoaderThis = LoaderContext<SaltyLoaderOptions>;
6
8
  export default function (this: WebpackLoaderThis): Promise<string | undefined>;
package/loader.js CHANGED
@@ -1,19 +1,20 @@
1
- import { SaltyCompiler as n } from "@salty-css/core/compiler/salty-compiler";
2
- const o = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Map(), s = async (t) => {
1
+ import { SaltyCompiler as s } from "@salty-css/core/compiler/salty-compiler";
2
+ const a = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new Map(), c = async (t) => {
3
3
  if (t === "react" || t === void 0)
4
4
  return (await import("@salty-css/react/transform-salty-file")).transformSaltyFile;
5
5
  throw new Error(`@salty-css/webpack: framework "${t}" is not supported. Supported: react.`);
6
- }, c = (t) => {
6
+ }, i = (t, e) => {
7
+ const o = `${t}|${e ?? ""}`;
8
+ let r = n.get(o);
9
+ return r || (r = new s(t, { mode: e }), n.set(o, r)), r;
10
+ }, l = (t) => {
7
11
  let e = a.get(t);
8
- return e || (e = new n(t), a.set(t, e)), e;
9
- }, i = (t) => {
10
- let e = o.get(t);
11
- return e || (e = t.getFramework().then(s), o.set(t, e)), e;
12
+ return e || (e = t.getFramework().then(c), a.set(t, e)), e;
12
13
  };
13
- async function p() {
14
- const { dir: t } = this.getOptions(), { resourcePath: e } = this, r = c(t);
15
- return await r.generateFile(e), await (await i(r))(r, e);
14
+ async function w() {
15
+ const { dir: t, mode: e } = this.getOptions(), { resourcePath: o } = this, r = i(t, e);
16
+ return await r.generateFile(o), await (await l(r))(r, o);
16
17
  }
17
18
  export {
18
- p as default
19
+ w as default
19
20
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/webpack",
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
  "webpack": ">=5.x"
39
39
  },
40
40
  "peerDependencies": {