@salty-css/webpack 0.1.0-alpha.14 → 0.1.0-alpha.16
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 +8 -1
- package/index.js +18 -18
- 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 y=require("path"),f=require("@salty-css/core/server"),g=require("fs"),n=require("@salty-css/core/compiler/helpers"),h=require("@salty-css/core/compiler/salty-compiler"),c=(t,e,d=!1,p=!1,a={})=>{var l,r,o;const s=new h.SaltyCompiler(e,{mode:a.mode});(r=(l=t.module)==null?void 0:l.rules)==null||r.push({test:n.saltyFileRegExp(),use:[{loader:y.resolve(__dirname,p?"./loader.cjs":"./loader.js"),options:{dir:e,mode:a.mode}}]}),d||(o=t.plugins)==null||o.push({apply:m=>{let i=!1;m.hooks.beforeCompile.tapPromise({name:"generateCss"},async()=>{i||(i=!0,await s.generateCss(),g.watch(e,{recursive:!0},async(C,u)=>{await f.checkShouldRestart(u)?await s.generateCss():n.isSaltyFile(u)&&await s.generateFile(e)}))})}})};exports.default=c;exports.saltyPlugin=c;
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import { Configuration } from 'webpack';
|
|
2
|
-
|
|
2
|
+
import { SaltyCompilerMode } from '@salty-css/core/compiler/salty-compiler';
|
|
3
|
+
export interface SaltyWebpackPluginOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Explicit build mode. Defaults to NODE_ENV-based detection.
|
|
6
|
+
*/
|
|
7
|
+
mode?: SaltyCompilerMode;
|
|
8
|
+
}
|
|
9
|
+
export declare const saltyPlugin: (config: Configuration, dir: string, isServer?: boolean, cjs?: boolean, options?: SaltyWebpackPluginOptions) => void;
|
|
3
10
|
export default saltyPlugin;
|
package/index.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { resolve as
|
|
2
|
-
import { checkShouldRestart as
|
|
1
|
+
import { resolve as f } from "path";
|
|
2
|
+
import { checkShouldRestart as d } from "@salty-css/core/server";
|
|
3
3
|
import { watch as c } from "fs";
|
|
4
|
-
import { saltyFileRegExp as y, isSaltyFile as
|
|
5
|
-
import { SaltyCompiler as
|
|
6
|
-
const
|
|
7
|
-
var
|
|
8
|
-
const t = new
|
|
9
|
-
(l = (
|
|
4
|
+
import { saltyFileRegExp as y, isSaltyFile as h } from "@salty-css/core/compiler/helpers";
|
|
5
|
+
import { SaltyCompiler as g } from "@salty-css/core/compiler/salty-compiler";
|
|
6
|
+
const x = (s, e, n = !1, p = !1, a = {}) => {
|
|
7
|
+
var o, l, r;
|
|
8
|
+
const t = new g(e, { mode: a.mode });
|
|
9
|
+
(l = (o = s.module) == null ? void 0 : o.rules) == null || l.push({
|
|
10
10
|
test: y(),
|
|
11
11
|
use: [
|
|
12
12
|
{
|
|
13
|
-
loader:
|
|
14
|
-
options: { dir: e }
|
|
13
|
+
loader: f(__dirname, p ? "./loader.cjs" : "./loader.js"),
|
|
14
|
+
options: { dir: e, mode: a.mode }
|
|
15
15
|
}
|
|
16
16
|
]
|
|
17
|
-
}),
|
|
18
|
-
apply: (
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
await
|
|
17
|
+
}), n || (r = s.plugins) == null || r.push({
|
|
18
|
+
apply: (u) => {
|
|
19
|
+
let i = !1;
|
|
20
|
+
u.hooks.beforeCompile.tapPromise({ name: "generateCss" }, async () => {
|
|
21
|
+
i || (i = !0, await t.generateCss(), c(e, { recursive: !0 }, async (w, m) => {
|
|
22
|
+
await d(m) ? await t.generateCss() : h(m) && await t.generateFile(e);
|
|
23
23
|
}));
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
};
|
|
28
28
|
export {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
x as default,
|
|
30
|
+
x as saltyPlugin
|
|
31
31
|
};
|
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-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.16",
|
|
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.
|
|
37
|
+
"@salty-css/core": "^0.1.0-alpha.16",
|
|
38
38
|
"webpack": ">=5.x"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|