@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 +1 -1
- package/index.d.ts +19 -1
- package/index.js +28 -20
- package/loader.cjs +1 -1
- package/loader.d.ts +2 -0
- package/loader.js +12 -11
- package/package.json +2 -2
package/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
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
|
-
|
|
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
|
|
2
|
-
import { checkShouldRestart as
|
|
3
|
-
import { watch as
|
|
4
|
-
import { saltyFileRegExp as
|
|
5
|
-
import { SaltyCompiler as
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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:
|
|
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
|
-
}),
|
|
18
|
-
apply: (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
30
|
-
|
|
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,
|
|
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
|
|
2
|
-
const
|
|
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
|
-
},
|
|
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 =
|
|
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
|
|
14
|
-
const { dir: t } = this.getOptions(), { resourcePath:
|
|
15
|
-
return await r.generateFile(
|
|
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
|
-
|
|
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-
|
|
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-
|
|
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": {
|