@pandacss/postcss 1.11.2 → 2.0.0-beta.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/LICENSE.md +1 -1
- package/README.md +31 -0
- package/dist/index.cjs +134 -0
- package/dist/index.d.cts +17 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.js +107 -80
- package/package.json +17 -16
- package/dist/index.d.mts +0 -14
- package/dist/index.mjs +0 -75
package/LICENSE.md
CHANGED
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @pandacss/postcss
|
|
2
|
+
|
|
3
|
+
The PostCSS plugin for [Panda CSS](https://panda-css.com).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -D @pandacss/postcss
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
> If you use `@pandacss/dev`, you can reference the plugin as `@pandacss/dev/postcss` without installing this package
|
|
12
|
+
> separately.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
// postcss.config.cjs
|
|
18
|
+
module.exports = {
|
|
19
|
+
plugins: {
|
|
20
|
+
'@pandacss/postcss': {},
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Documentation
|
|
26
|
+
|
|
27
|
+
Visit the [Panda CSS documentation](https://panda-css.com) to learn more.
|
|
28
|
+
|
|
29
|
+
## License
|
|
30
|
+
|
|
31
|
+
MIT © [Chakra Systems Inc.](https://github.com/chakra-ui)
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/index.ts
|
|
2
|
+
var _compiler = require('@pandacss/compiler');
|
|
3
|
+
var _path = require('path');
|
|
4
|
+
var PLUGIN_NAME = "pandacss";
|
|
5
|
+
var driverStates = /* @__PURE__ */ new Map();
|
|
6
|
+
var driverGuard;
|
|
7
|
+
var pandacss = (options = {}) => {
|
|
8
|
+
const postcssProcess = async (root, result) => {
|
|
9
|
+
const fileName = result.opts.from;
|
|
10
|
+
if (shouldSkip(fileName, options.allow)) return;
|
|
11
|
+
const inputCss = getInputCss(root, result);
|
|
12
|
+
if (!inputCss.includes("@layer")) return;
|
|
13
|
+
const cwd = _path.resolve.call(void 0, _nullishCoalesce(options.cwd, () => ( process.cwd())));
|
|
14
|
+
const key = getDriverKey(cwd, options.configPath);
|
|
15
|
+
let state = driverStates.get(key);
|
|
16
|
+
if (!state) {
|
|
17
|
+
const driver2 = await _compiler.createNodeDriver.call(void 0, { cwd, configPath: options.configPath });
|
|
18
|
+
state = { driver: driver2, generatedOutdirs: /* @__PURE__ */ new Set() };
|
|
19
|
+
driverStates.set(key, state);
|
|
20
|
+
} else {
|
|
21
|
+
const diff = await state.driver.reload();
|
|
22
|
+
if (diff.hasChanged) {
|
|
23
|
+
state.generatedOutdirs.clear();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const { driver } = state;
|
|
27
|
+
if (!driver.compiler.hasLayerDeclaration(inputCss)) return;
|
|
28
|
+
ensureCodegen(state, { cwd, outdir: options.outdir });
|
|
29
|
+
driver.parseFiles();
|
|
30
|
+
registerDependencies(driver, result, cwd, fileName);
|
|
31
|
+
const output = driver.cssgen({ emitLayerDeclaration: false });
|
|
32
|
+
emitDiagnostics(root, result, output.diagnostics);
|
|
33
|
+
root.append(output.css);
|
|
34
|
+
root.walk((node) => {
|
|
35
|
+
if (!node.source) {
|
|
36
|
+
node.source = root.source;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
postcssPlugin: PLUGIN_NAME,
|
|
42
|
+
Once(root, helpers) {
|
|
43
|
+
driverGuard = Promise.resolve(driverGuard).catch(() => {
|
|
44
|
+
}).then(() => postcssProcess(root, helpers.result));
|
|
45
|
+
return driverGuard;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
pandacss.postcss = true;
|
|
50
|
+
var index_default = pandacss;
|
|
51
|
+
var nodeModulesRegex = /node_modules/;
|
|
52
|
+
function isValidCss(file) {
|
|
53
|
+
const [filePath] = file.split("?");
|
|
54
|
+
return _path.extname.call(void 0, filePath) === ".css";
|
|
55
|
+
}
|
|
56
|
+
var shouldSkip = (fileName, allow) => {
|
|
57
|
+
if (!fileName) return true;
|
|
58
|
+
if (!isValidCss(fileName)) return true;
|
|
59
|
+
if (_optionalChain([allow, 'optionalAccess', _ => _.some, 'call', _2 => _2((pattern) => pattern.test(fileName))])) return false;
|
|
60
|
+
return nodeModulesRegex.test(fileName);
|
|
61
|
+
};
|
|
62
|
+
function getDriverKey(cwd, configPath) {
|
|
63
|
+
return `${cwd}:${_nullishCoalesce(configPath, () => ( ""))}`;
|
|
64
|
+
}
|
|
65
|
+
function getInputCss(root, result) {
|
|
66
|
+
const opts = result.opts;
|
|
67
|
+
return _nullishCoalesce(opts.css, () => ( root.toString()));
|
|
68
|
+
}
|
|
69
|
+
function ensureCodegen(state, options) {
|
|
70
|
+
const outdirKey = state.driver.getOutdir(options.outdir);
|
|
71
|
+
if (state.generatedOutdirs.has(outdirKey)) return;
|
|
72
|
+
state.driver.codegen({ cwd: options.cwd, outdir: options.outdir });
|
|
73
|
+
state.generatedOutdirs.add(outdirKey);
|
|
74
|
+
}
|
|
75
|
+
function registerDependencies(driver, result, cwd, parent) {
|
|
76
|
+
for (const source of driver.compiler.sources()) {
|
|
77
|
+
result.messages.push(
|
|
78
|
+
withPluginMetadata(
|
|
79
|
+
createSourceDependency({
|
|
80
|
+
dir: _path.normalize.call(void 0, _path.resolve.call(void 0, cwd, source.base)),
|
|
81
|
+
glob: source.pattern
|
|
82
|
+
}),
|
|
83
|
+
parent
|
|
84
|
+
)
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
const configDeps = new Set(driver.configDependencies.map((file) => _path.normalize.call(void 0, _path.resolve.call(void 0, cwd, file))));
|
|
88
|
+
if (driver.configPath) {
|
|
89
|
+
configDeps.add(_path.normalize.call(void 0, _path.resolve.call(void 0, cwd, driver.configPath)));
|
|
90
|
+
}
|
|
91
|
+
for (const file of configDeps) {
|
|
92
|
+
result.messages.push(
|
|
93
|
+
withPluginMetadata(
|
|
94
|
+
{
|
|
95
|
+
type: "dependency",
|
|
96
|
+
file
|
|
97
|
+
},
|
|
98
|
+
parent
|
|
99
|
+
)
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function createSourceDependency(source) {
|
|
104
|
+
if (process.env.ROLLUP_WATCH === "true") {
|
|
105
|
+
return { type: "dependency", file: source.dir };
|
|
106
|
+
}
|
|
107
|
+
return { type: "dir-dependency", dir: source.dir, glob: source.glob };
|
|
108
|
+
}
|
|
109
|
+
function withPluginMetadata(message, parent) {
|
|
110
|
+
return {
|
|
111
|
+
...message,
|
|
112
|
+
plugin: PLUGIN_NAME,
|
|
113
|
+
parent
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function formatDiagnostic(diagnostic) {
|
|
117
|
+
const file = diagnostic.file ? `${diagnostic.file}` : "";
|
|
118
|
+
const location = diagnostic.location ? `:${diagnostic.location.start.line}:${diagnostic.location.start.column}` : diagnostic.span ? `:${diagnostic.span.start}` : "";
|
|
119
|
+
return `${diagnostic.severity} ${diagnostic.code} ${file}${location} ${diagnostic.message}`.replace(/\s+/g, " ");
|
|
120
|
+
}
|
|
121
|
+
function emitDiagnostics(root, result, diagnostics) {
|
|
122
|
+
const error = diagnostics.find((diagnostic) => diagnostic.severity === "error");
|
|
123
|
+
if (error) {
|
|
124
|
+
throw root.error(formatDiagnostic(error), { plugin: PLUGIN_NAME });
|
|
125
|
+
}
|
|
126
|
+
for (const diagnostic of diagnostics) {
|
|
127
|
+
result.warn(formatDiagnostic(diagnostic), { plugin: PLUGIN_NAME });
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
exports.default = index_default;
|
|
133
|
+
|
|
134
|
+
module.exports = exports.default;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PluginCreator } from 'postcss';
|
|
2
|
+
|
|
3
|
+
interface PluginOptions {
|
|
4
|
+
/** Explicit config file (relative to `cwd`); otherwise discovered upward. */
|
|
5
|
+
configPath?: string;
|
|
6
|
+
/** Project root. Defaults to the current working directory. */
|
|
7
|
+
cwd?: string;
|
|
8
|
+
/** Where codegen artifacts are written. Defaults to the config `outdir`. */
|
|
9
|
+
outdir?: string;
|
|
10
|
+
/** Allow selected `node_modules` CSS files through the processing guard. */
|
|
11
|
+
allow?: RegExp[];
|
|
12
|
+
}
|
|
13
|
+
declare const pandacss: PluginCreator<PluginOptions>;
|
|
14
|
+
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
export = pandacss;
|
|
17
|
+
export type { PluginOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { Builder } from '@pandacss/node';
|
|
2
1
|
import { PluginCreator } from 'postcss';
|
|
3
2
|
|
|
4
3
|
interface PluginOptions {
|
|
4
|
+
/** Explicit config file (relative to `cwd`); otherwise discovered upward. */
|
|
5
5
|
configPath?: string;
|
|
6
|
+
/** Project root. Defaults to the current working directory. */
|
|
6
7
|
cwd?: string;
|
|
7
|
-
|
|
8
|
+
/** Where codegen artifacts are written. Defaults to the config `outdir`. */
|
|
9
|
+
outdir?: string;
|
|
10
|
+
/** Allow selected `node_modules` CSS files through the processing guard. */
|
|
8
11
|
allow?: RegExp[];
|
|
9
12
|
}
|
|
10
|
-
declare const loadConfig: () => any;
|
|
11
|
-
declare const builder: Builder;
|
|
12
13
|
declare const pandacss: PluginCreator<PluginOptions>;
|
|
13
14
|
|
|
14
|
-
export { type PluginOptions,
|
|
15
|
+
export { type PluginOptions, pandacss as default };
|
package/dist/index.js
CHANGED
|
@@ -1,72 +1,36 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
1
|
// src/index.ts
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
builder: () => builder,
|
|
34
|
-
default: () => index_default,
|
|
35
|
-
loadConfig: () => loadConfig,
|
|
36
|
-
pandacss: () => pandacss
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(index_exports);
|
|
39
|
-
var import_node = require("@pandacss/node");
|
|
40
|
-
var import_module = require("module");
|
|
41
|
-
var import_path = __toESM(require("path"));
|
|
42
|
-
var customRequire = (0, import_module.createRequire)(__dirname);
|
|
2
|
+
import { createNodeDriver } from "@pandacss/compiler";
|
|
3
|
+
import { extname, normalize, resolve } from "path";
|
|
43
4
|
var PLUGIN_NAME = "pandacss";
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
var stream;
|
|
47
|
-
var builder = new import_node.Builder();
|
|
48
|
-
var builderGuard;
|
|
5
|
+
var driverStates = /* @__PURE__ */ new Map();
|
|
6
|
+
var driverGuard;
|
|
49
7
|
var pandacss = (options = {}) => {
|
|
50
|
-
const
|
|
51
|
-
if (!stream && logfile) {
|
|
52
|
-
stream = (0, import_node.setLogStream)({ cwd, logfile });
|
|
53
|
-
}
|
|
54
|
-
const postcssProcess = async function(root, result) {
|
|
8
|
+
const postcssProcess = async (root, result) => {
|
|
55
9
|
const fileName = result.opts.from;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
10
|
+
if (shouldSkip(fileName, options.allow)) return;
|
|
11
|
+
const inputCss = getInputCss(root, result);
|
|
12
|
+
if (!inputCss.includes("@layer")) return;
|
|
13
|
+
const cwd = resolve(options.cwd ?? process.cwd());
|
|
14
|
+
const key = getDriverKey(cwd, options.configPath);
|
|
15
|
+
let state = driverStates.get(key);
|
|
16
|
+
if (!state) {
|
|
17
|
+
const driver2 = await createNodeDriver({ cwd, configPath: options.configPath });
|
|
18
|
+
state = { driver: driver2, generatedOutdirs: /* @__PURE__ */ new Set() };
|
|
19
|
+
driverStates.set(key, state);
|
|
20
|
+
} else {
|
|
21
|
+
const diff = await state.driver.reload();
|
|
22
|
+
if (diff.hasChanged) {
|
|
23
|
+
state.generatedOutdirs.clear();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const { driver } = state;
|
|
27
|
+
if (!driver.compiler.hasLayerDeclaration(inputCss)) return;
|
|
28
|
+
ensureCodegen(state, { cwd, outdir: options.outdir });
|
|
29
|
+
driver.parseFiles();
|
|
30
|
+
registerDependencies(driver, result, cwd, fileName);
|
|
31
|
+
const output = driver.cssgen({ emitLayerDeclaration: false });
|
|
32
|
+
emitDiagnostics(root, result, output.diagnostics);
|
|
33
|
+
root.append(output.css);
|
|
70
34
|
root.walk((node) => {
|
|
71
35
|
if (!node.source) {
|
|
72
36
|
node.source = root.source;
|
|
@@ -75,13 +39,11 @@ var pandacss = (options = {}) => {
|
|
|
75
39
|
};
|
|
76
40
|
return {
|
|
77
41
|
postcssPlugin: PLUGIN_NAME,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
]
|
|
42
|
+
Once(root, helpers) {
|
|
43
|
+
driverGuard = Promise.resolve(driverGuard).catch(() => {
|
|
44
|
+
}).then(() => postcssProcess(root, helpers.result));
|
|
45
|
+
return driverGuard;
|
|
46
|
+
}
|
|
85
47
|
};
|
|
86
48
|
};
|
|
87
49
|
pandacss.postcss = true;
|
|
@@ -89,17 +51,82 @@ var index_default = pandacss;
|
|
|
89
51
|
var nodeModulesRegex = /node_modules/;
|
|
90
52
|
function isValidCss(file) {
|
|
91
53
|
const [filePath] = file.split("?");
|
|
92
|
-
return
|
|
54
|
+
return extname(filePath) === ".css";
|
|
93
55
|
}
|
|
94
56
|
var shouldSkip = (fileName, allow) => {
|
|
95
57
|
if (!fileName) return true;
|
|
96
58
|
if (!isValidCss(fileName)) return true;
|
|
97
|
-
if (allow?.some((
|
|
59
|
+
if (allow?.some((pattern) => pattern.test(fileName))) return false;
|
|
98
60
|
return nodeModulesRegex.test(fileName);
|
|
99
61
|
};
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
62
|
+
function getDriverKey(cwd, configPath) {
|
|
63
|
+
return `${cwd}:${configPath ?? ""}`;
|
|
64
|
+
}
|
|
65
|
+
function getInputCss(root, result) {
|
|
66
|
+
const opts = result.opts;
|
|
67
|
+
return opts.css ?? root.toString();
|
|
68
|
+
}
|
|
69
|
+
function ensureCodegen(state, options) {
|
|
70
|
+
const outdirKey = state.driver.getOutdir(options.outdir);
|
|
71
|
+
if (state.generatedOutdirs.has(outdirKey)) return;
|
|
72
|
+
state.driver.codegen({ cwd: options.cwd, outdir: options.outdir });
|
|
73
|
+
state.generatedOutdirs.add(outdirKey);
|
|
74
|
+
}
|
|
75
|
+
function registerDependencies(driver, result, cwd, parent) {
|
|
76
|
+
for (const source of driver.compiler.sources()) {
|
|
77
|
+
result.messages.push(
|
|
78
|
+
withPluginMetadata(
|
|
79
|
+
createSourceDependency({
|
|
80
|
+
dir: normalize(resolve(cwd, source.base)),
|
|
81
|
+
glob: source.pattern
|
|
82
|
+
}),
|
|
83
|
+
parent
|
|
84
|
+
)
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
const configDeps = new Set(driver.configDependencies.map((file) => normalize(resolve(cwd, file))));
|
|
88
|
+
if (driver.configPath) {
|
|
89
|
+
configDeps.add(normalize(resolve(cwd, driver.configPath)));
|
|
90
|
+
}
|
|
91
|
+
for (const file of configDeps) {
|
|
92
|
+
result.messages.push(
|
|
93
|
+
withPluginMetadata(
|
|
94
|
+
{
|
|
95
|
+
type: "dependency",
|
|
96
|
+
file
|
|
97
|
+
},
|
|
98
|
+
parent
|
|
99
|
+
)
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function createSourceDependency(source) {
|
|
104
|
+
if (process.env.ROLLUP_WATCH === "true") {
|
|
105
|
+
return { type: "dependency", file: source.dir };
|
|
106
|
+
}
|
|
107
|
+
return { type: "dir-dependency", dir: source.dir, glob: source.glob };
|
|
108
|
+
}
|
|
109
|
+
function withPluginMetadata(message, parent) {
|
|
110
|
+
return {
|
|
111
|
+
...message,
|
|
112
|
+
plugin: PLUGIN_NAME,
|
|
113
|
+
parent
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function formatDiagnostic(diagnostic) {
|
|
117
|
+
const file = diagnostic.file ? `${diagnostic.file}` : "";
|
|
118
|
+
const location = diagnostic.location ? `:${diagnostic.location.start.line}:${diagnostic.location.start.column}` : diagnostic.span ? `:${diagnostic.span.start}` : "";
|
|
119
|
+
return `${diagnostic.severity} ${diagnostic.code} ${file}${location} ${diagnostic.message}`.replace(/\s+/g, " ");
|
|
120
|
+
}
|
|
121
|
+
function emitDiagnostics(root, result, diagnostics) {
|
|
122
|
+
const error = diagnostics.find((diagnostic) => diagnostic.severity === "error");
|
|
123
|
+
if (error) {
|
|
124
|
+
throw root.error(formatDiagnostic(error), { plugin: PLUGIN_NAME });
|
|
125
|
+
}
|
|
126
|
+
for (const diagnostic of diagnostics) {
|
|
127
|
+
result.warn(formatDiagnostic(diagnostic), { plugin: PLUGIN_NAME });
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
export {
|
|
131
|
+
index_default as default
|
|
132
|
+
};
|
package/package.json
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/postcss",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "PostCSS
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
3
|
+
"version": "2.0.0-beta.0",
|
|
4
|
+
"description": "PostCSS plugin for Panda CSS",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
8
|
"author": "Segun Adebayo <joseshegs@gmail.com>",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
12
|
"source": "./src/index.ts",
|
|
13
13
|
"types": "./dist/index.d.ts",
|
|
14
|
-
"require": "./dist/index.
|
|
15
|
-
"import":
|
|
16
|
-
"types": "./dist/index.d.mts",
|
|
17
|
-
"default": "./dist/index.mjs"
|
|
18
|
-
}
|
|
14
|
+
"require": "./dist/index.cjs",
|
|
15
|
+
"import": "./dist/index.js"
|
|
19
16
|
},
|
|
20
17
|
"./package.json": "./package.json"
|
|
21
18
|
},
|
|
@@ -33,15 +30,19 @@
|
|
|
33
30
|
"dist"
|
|
34
31
|
],
|
|
35
32
|
"dependencies": {
|
|
36
|
-
"
|
|
37
|
-
"@pandacss/
|
|
33
|
+
"@pandacss/compiler": "2.0.0-beta.0",
|
|
34
|
+
"@pandacss/compiler-shared": "2.0.0-beta.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"postcss": ">=8"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"
|
|
40
|
+
"postcss": "8.5.14"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
|
-
"build": "tsup
|
|
44
|
-
"build
|
|
45
|
-
"dev": "pnpm build
|
|
43
|
+
"build": "tsup",
|
|
44
|
+
"build:fast": "tsup --no-dts",
|
|
45
|
+
"dev": "pnpm build:fast --watch src",
|
|
46
|
+
"test": "vitest run"
|
|
46
47
|
}
|
|
47
48
|
}
|
package/dist/index.d.mts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Builder } from '@pandacss/node';
|
|
2
|
-
import { PluginCreator } from 'postcss';
|
|
3
|
-
|
|
4
|
-
interface PluginOptions {
|
|
5
|
-
configPath?: string;
|
|
6
|
-
cwd?: string;
|
|
7
|
-
logfile?: string;
|
|
8
|
-
allow?: RegExp[];
|
|
9
|
-
}
|
|
10
|
-
declare const loadConfig: () => any;
|
|
11
|
-
declare const builder: Builder;
|
|
12
|
-
declare const pandacss: PluginCreator<PluginOptions>;
|
|
13
|
-
|
|
14
|
-
export { type PluginOptions, builder, pandacss as default, loadConfig, pandacss };
|
package/dist/index.mjs
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
// ../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.15.3_@swc+helpers@0.5.17__jiti@2.6.1_postcss@8.5.14_tsx@4.20.6_typescript@6.0.2_yaml@2.8.1/node_modules/tsup/assets/esm_shims.js
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
var getFilename = () => fileURLToPath(import.meta.url);
|
|
5
|
-
var getDirname = () => path.dirname(getFilename());
|
|
6
|
-
var __dirname = /* @__PURE__ */ getDirname();
|
|
7
|
-
|
|
8
|
-
// src/index.ts
|
|
9
|
-
import { Builder, setLogStream } from "@pandacss/node";
|
|
10
|
-
import { createRequire } from "module";
|
|
11
|
-
import path2 from "path";
|
|
12
|
-
var customRequire = createRequire(__dirname);
|
|
13
|
-
var PLUGIN_NAME = "pandacss";
|
|
14
|
-
var interopDefault = (obj) => obj && obj.__esModule ? obj.default : obj;
|
|
15
|
-
var loadConfig = () => interopDefault(customRequire("@pandacss/postcss"));
|
|
16
|
-
var stream;
|
|
17
|
-
var builder = new Builder();
|
|
18
|
-
var builderGuard;
|
|
19
|
-
var pandacss = (options = {}) => {
|
|
20
|
-
const { configPath, cwd, logfile, allow } = options;
|
|
21
|
-
if (!stream && logfile) {
|
|
22
|
-
stream = setLogStream({ cwd, logfile });
|
|
23
|
-
}
|
|
24
|
-
const postcssProcess = async function(root, result) {
|
|
25
|
-
const fileName = result.opts.from;
|
|
26
|
-
const skip = shouldSkip(fileName, allow);
|
|
27
|
-
if (skip) return;
|
|
28
|
-
await builder.setup({ configPath, cwd });
|
|
29
|
-
if (!builder.isValidRoot(root)) return;
|
|
30
|
-
await builder.emit();
|
|
31
|
-
builder.extract();
|
|
32
|
-
builder.registerDependency((dep) => {
|
|
33
|
-
result.messages.push({
|
|
34
|
-
...dep,
|
|
35
|
-
plugin: PLUGIN_NAME,
|
|
36
|
-
parent: result.opts.from
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
builder.write(root);
|
|
40
|
-
root.walk((node) => {
|
|
41
|
-
if (!node.source) {
|
|
42
|
-
node.source = root.source;
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
return {
|
|
47
|
-
postcssPlugin: PLUGIN_NAME,
|
|
48
|
-
plugins: [
|
|
49
|
-
function(...args) {
|
|
50
|
-
builderGuard = Promise.resolve(builderGuard).catch(() => {
|
|
51
|
-
}).then(() => postcssProcess(...args));
|
|
52
|
-
return builderGuard;
|
|
53
|
-
}
|
|
54
|
-
]
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
pandacss.postcss = true;
|
|
58
|
-
var index_default = pandacss;
|
|
59
|
-
var nodeModulesRegex = /node_modules/;
|
|
60
|
-
function isValidCss(file) {
|
|
61
|
-
const [filePath] = file.split("?");
|
|
62
|
-
return path2.extname(filePath) === ".css";
|
|
63
|
-
}
|
|
64
|
-
var shouldSkip = (fileName, allow) => {
|
|
65
|
-
if (!fileName) return true;
|
|
66
|
-
if (!isValidCss(fileName)) return true;
|
|
67
|
-
if (allow?.some((p) => p.test(fileName))) return false;
|
|
68
|
-
return nodeModulesRegex.test(fileName);
|
|
69
|
-
};
|
|
70
|
-
export {
|
|
71
|
-
builder,
|
|
72
|
-
index_default as default,
|
|
73
|
-
loadConfig,
|
|
74
|
-
pandacss
|
|
75
|
-
};
|