@pandacss/config 2.1.2 → 2.2.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/dist/index.js +97 -243
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -21,13 +21,12 @@ import {
|
|
|
21
21
|
import { applyConfigDefaults as applyConfigDefaults2 } from "@pandacss/compiler-shared";
|
|
22
22
|
|
|
23
23
|
// src/bundle.ts
|
|
24
|
-
import { existsSync
|
|
24
|
+
import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
25
25
|
import { mkdir, unlink, writeFile } from "node:fs/promises";
|
|
26
26
|
import { builtinModules } from "node:module";
|
|
27
27
|
import { tmpdir } from "node:os";
|
|
28
|
-
import { basename, dirname
|
|
29
|
-
import { pathToFileURL as
|
|
30
|
-
import { debuglog } from "node:util";
|
|
28
|
+
import { basename, dirname, extname, isAbsolute as isAbsolute2, join, normalize, relative, sep } from "node:path";
|
|
29
|
+
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
31
30
|
|
|
32
31
|
// src/bundle-plugins.ts
|
|
33
32
|
import { isAbsolute } from "node:path";
|
|
@@ -45,11 +44,28 @@ function importMetaUrlPlugin() {
|
|
|
45
44
|
}
|
|
46
45
|
};
|
|
47
46
|
}
|
|
47
|
+
var sideEffectImportRe = /^[ \t]*import[ \t]*(['"])([^'"\n]+)\1/gm;
|
|
48
|
+
var nodeModulesRe = /[\\/]node_modules[\\/]/;
|
|
49
|
+
function sideEffectImportsPlugin() {
|
|
50
|
+
const importsByFile = /* @__PURE__ */ new Map();
|
|
51
|
+
return {
|
|
52
|
+
name: "panda-side-effect-imports",
|
|
53
|
+
transform(code, id) {
|
|
54
|
+
if (nodeModulesRe.test(id) || !code.includes("import")) return;
|
|
55
|
+
const specifiers = new Set(Array.from(code.matchAll(sideEffectImportRe), (match) => match[2]));
|
|
56
|
+
if (specifiers.size > 0) importsByFile.set(id, specifiers);
|
|
57
|
+
},
|
|
58
|
+
async resolveId(source, importer) {
|
|
59
|
+
if (!importer || !importsByFile.get(importer)?.has(source)) return;
|
|
60
|
+
const resolved = await this.resolve(source, importer, { skipSelf: true });
|
|
61
|
+
return resolved && { ...resolved, moduleSideEffects: true };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
48
65
|
|
|
49
66
|
// src/resolve.ts
|
|
50
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
51
67
|
import { createRequire } from "node:module";
|
|
52
|
-
import {
|
|
68
|
+
import { resolve } from "node:path";
|
|
53
69
|
function tryResolveFrom(request, fromDir) {
|
|
54
70
|
try {
|
|
55
71
|
return createRequire(resolve(fromDir, "noop.js")).resolve(request, { paths: [fromDir] });
|
|
@@ -75,171 +91,18 @@ function resolveFrom(request, fromDir) {
|
|
|
75
91
|
function errorCode(error) {
|
|
76
92
|
return typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
|
|
77
93
|
}
|
|
78
|
-
function nearestPackageType(start) {
|
|
79
|
-
let current = start;
|
|
80
|
-
while (true) {
|
|
81
|
-
const candidate = join(current, "package.json");
|
|
82
|
-
if (existsSync(candidate)) return JSON.parse(readFileSync(candidate, "utf8")).type;
|
|
83
|
-
const parent = dirname(current);
|
|
84
|
-
if (parent === current) return void 0;
|
|
85
|
-
current = parent;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// src/transpile-loader.ts
|
|
90
|
-
import { existsSync as existsSync2, readFileSync as readFileSync2, statSync } from "node:fs";
|
|
91
|
-
import * as nodeModule from "node:module";
|
|
92
|
-
import { dirname as dirname2, extname, join as join2, sep } from "node:path";
|
|
93
|
-
import { fileURLToPath, pathToFileURL as pathToFileURL2 } from "node:url";
|
|
94
|
-
var SESSION_PARAM = "panda-config";
|
|
95
|
-
var TYPESCRIPT_EXTENSION = /\.[cm]?tsx?$/;
|
|
96
|
-
var RESOLVE_EXTENSIONS = [".ts", ".tsx", ".mts", ".js", ".mjs"];
|
|
97
|
-
var TranspileError = class extends Error {
|
|
98
|
-
name = "TranspileError";
|
|
99
|
-
};
|
|
100
|
-
var MODULE_LOAD_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
101
|
-
"ERR_IMPORT_ATTRIBUTE_MISSING",
|
|
102
|
-
"ERR_IMPORT_ATTRIBUTE_TYPE_INCOMPATIBLE",
|
|
103
|
-
"ERR_IMPORT_ATTRIBUTE_UNSUPPORTED",
|
|
104
|
-
"ERR_INVALID_MODULE_SPECIFIER",
|
|
105
|
-
"ERR_INVALID_PACKAGE_CONFIG",
|
|
106
|
-
"ERR_INVALID_PACKAGE_TARGET",
|
|
107
|
-
"ERR_MODULE_NOT_FOUND",
|
|
108
|
-
"ERR_PACKAGE_IMPORT_NOT_DEFINED",
|
|
109
|
-
"ERR_PACKAGE_PATH_NOT_EXPORTED",
|
|
110
|
-
"ERR_REQUIRE_ASYNC_MODULE",
|
|
111
|
-
"ERR_REQUIRE_CYCLE_MODULE",
|
|
112
|
-
"ERR_REQUIRE_ESM",
|
|
113
|
-
"ERR_UNKNOWN_FILE_EXTENSION",
|
|
114
|
-
"ERR_UNKNOWN_MODULE_FORMAT",
|
|
115
|
-
"ERR_UNSUPPORTED_DIR_IMPORT",
|
|
116
|
-
"ERR_UNSUPPORTED_ESM_URL_SCHEME",
|
|
117
|
-
"MODULE_NOT_FOUND"
|
|
118
|
-
]);
|
|
119
|
-
var COMMONJS_GLOBAL_MISSING = /^(require|module|exports|__dirname|__filename) is not defined\b/;
|
|
120
|
-
function isLoaderFailure(error) {
|
|
121
|
-
if (error instanceof TranspileError) return true;
|
|
122
|
-
const code = error?.code;
|
|
123
|
-
if (typeof code === "string" && MODULE_LOAD_ERROR_CODES.has(code)) return true;
|
|
124
|
-
if (error instanceof SyntaxError) return true;
|
|
125
|
-
return error instanceof ReferenceError && COMMONJS_GLOBAL_MISSING.test(error.message);
|
|
126
|
-
}
|
|
127
|
-
var sessions = /* @__PURE__ */ new Map();
|
|
128
|
-
var commonjsFiles = /* @__PURE__ */ new Set();
|
|
129
|
-
var requireCache = nodeModule.createRequire(import.meta.url).cache;
|
|
130
|
-
var hooksRegistered;
|
|
131
|
-
var nextSession = 0;
|
|
132
|
-
function canTranspile(file) {
|
|
133
|
-
return typeof nodeModule.registerHooks === "function" && !/\.c[jt]s$/.test(file);
|
|
134
|
-
}
|
|
135
|
-
async function importTranspiled(file, evaluate) {
|
|
136
|
-
hooksRegistered ??= registerTranspileHooks();
|
|
137
|
-
await hooksRegistered.catch((cause) => {
|
|
138
|
-
throw new TranspileError("Could not register the transpile hooks.", { cause });
|
|
139
|
-
});
|
|
140
|
-
for (const commonjsFile of commonjsFiles) delete requireCache[commonjsFile];
|
|
141
|
-
const id = String(++nextSession);
|
|
142
|
-
const session = { files: /* @__PURE__ */ new Set([file]), loaded: false };
|
|
143
|
-
sessions.set(id, session);
|
|
144
|
-
try {
|
|
145
|
-
const mod = await import(
|
|
146
|
-
/* @vite-ignore */
|
|
147
|
-
withSession(pathToFileURL2(file).href, id)
|
|
148
|
-
);
|
|
149
|
-
if (!session.loaded) throw new TranspileError("Config was not loaded through the Panda transpile hooks.");
|
|
150
|
-
return { value: await evaluate(mod), files: Array.from(session.files) };
|
|
151
|
-
} finally {
|
|
152
|
-
sessions.delete(id);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
async function registerTranspileHooks() {
|
|
156
|
-
const { transformSync } = await import("rolldown/utils");
|
|
157
|
-
nodeModule.registerHooks({
|
|
158
|
-
resolve(specifier, context, nextResolve) {
|
|
159
|
-
const id = sessionId(context.parentURL);
|
|
160
|
-
if (!id || !context.parentURL) return nextResolve(specifier, context);
|
|
161
|
-
const tag = (file) => {
|
|
162
|
-
sessions.get(id)?.files.add(file);
|
|
163
|
-
return { url: withSession(pathToFileURL2(file).href, id), shortCircuit: true };
|
|
164
|
-
};
|
|
165
|
-
if (isRelative(specifier)) {
|
|
166
|
-
const file = resolveRelative(specifier, context.parentURL);
|
|
167
|
-
return file ? tag(file) : nextResolve(specifier, context);
|
|
168
|
-
}
|
|
169
|
-
const resolved = nextResolve(specifier, context);
|
|
170
|
-
const linked = linkedPackageFile(resolved.url);
|
|
171
|
-
if (linked) return tag(linked);
|
|
172
|
-
if (isCommonJs(resolved)) {
|
|
173
|
-
throw new TranspileError(`${specifier} is CommonJS, so the bundler loads this config.`);
|
|
174
|
-
}
|
|
175
|
-
return resolved;
|
|
176
|
-
},
|
|
177
|
-
load(url, context, nextLoad) {
|
|
178
|
-
const id = sessionId(url);
|
|
179
|
-
if (!id) return nextLoad(url, context);
|
|
180
|
-
const session = sessions.get(id);
|
|
181
|
-
if (session) session.loaded = true;
|
|
182
|
-
const file = fileURLToPath(url);
|
|
183
|
-
if (!TYPESCRIPT_EXTENSION.test(file)) {
|
|
184
|
-
const loaded = nextLoad(url, context);
|
|
185
|
-
if (loaded.format === "commonjs") commonjsFiles.add(file);
|
|
186
|
-
return loaded;
|
|
187
|
-
}
|
|
188
|
-
const result = transformSync(file, readFileSync2(file, "utf8"));
|
|
189
|
-
if (result.errors.length > 0) {
|
|
190
|
-
throw new TranspileError(`Could not transpile ${file}.`, { cause: result.errors[0] });
|
|
191
|
-
}
|
|
192
|
-
return { format: "module", source: result.code, shortCircuit: true };
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
function isCommonJs(resolved) {
|
|
197
|
-
if (resolved.format) return resolved.format === "commonjs";
|
|
198
|
-
if (!resolved.url.startsWith("file:")) return false;
|
|
199
|
-
const file = fileURLToPath(resolved.url);
|
|
200
|
-
if (file.endsWith(".cjs")) return true;
|
|
201
|
-
return file.endsWith(".js") && nearestPackageType(dirname2(file)) !== "module";
|
|
202
|
-
}
|
|
203
|
-
function sessionId(url) {
|
|
204
|
-
if (!url?.startsWith("file:") || !url.includes(`${SESSION_PARAM}=`)) return void 0;
|
|
205
|
-
return new URL(url).searchParams.get(SESSION_PARAM) ?? void 0;
|
|
206
|
-
}
|
|
207
|
-
function withSession(url, id) {
|
|
208
|
-
return `${url}?${SESSION_PARAM}=${id}`;
|
|
209
|
-
}
|
|
210
|
-
function isRelative(specifier) {
|
|
211
|
-
return specifier.startsWith("./") || specifier.startsWith("../");
|
|
212
|
-
}
|
|
213
|
-
function linkedPackageFile(url) {
|
|
214
|
-
if (!url.startsWith("file:")) return void 0;
|
|
215
|
-
const file = fileURLToPath(url);
|
|
216
|
-
return file.includes(`${sep}node_modules${sep}`) ? void 0 : file;
|
|
217
|
-
}
|
|
218
|
-
function resolveRelative(specifier, parentURL) {
|
|
219
|
-
const base = fileURLToPath(new URL(specifier, parentURL));
|
|
220
|
-
const candidates = [
|
|
221
|
-
base,
|
|
222
|
-
...RESOLVE_EXTENSIONS.map((extension) => base + extension),
|
|
223
|
-
...extname(base) === ".js" ? [base.slice(0, -3) + ".ts"] : [],
|
|
224
|
-
...RESOLVE_EXTENSIONS.map((extension) => join2(base, `index${extension}`))
|
|
225
|
-
];
|
|
226
|
-
return candidates.find((candidate) => existsSync2(candidate) && statSync(candidate).isFile());
|
|
227
|
-
}
|
|
228
94
|
|
|
229
95
|
// src/bundle.ts
|
|
230
|
-
var debug = debuglog("panda");
|
|
231
96
|
var nodeBuiltins = /* @__PURE__ */ new Set([...builtinModules, ...builtinModules.map((mod) => `node:${mod}`)]);
|
|
232
97
|
async function bundleConfig(filepath, cwd) {
|
|
233
|
-
const transpiled = await loadTranspiled(filepath, cwd);
|
|
234
|
-
if (transpiled) return transpiled;
|
|
235
98
|
const { rolldown } = await import("rolldown");
|
|
236
99
|
const build = await rolldown({
|
|
237
100
|
input: filepath,
|
|
238
101
|
cwd,
|
|
239
102
|
platform: "node",
|
|
240
103
|
external: (id) => nodeBuiltins.has(id),
|
|
241
|
-
treeshake:
|
|
242
|
-
plugins: [importMetaUrlPlugin()]
|
|
104
|
+
treeshake: true,
|
|
105
|
+
plugins: [importMetaUrlPlugin(), sideEffectImportsPlugin()]
|
|
243
106
|
});
|
|
244
107
|
let chunks;
|
|
245
108
|
try {
|
|
@@ -255,34 +118,15 @@ async function bundleConfig(filepath, cwd) {
|
|
|
255
118
|
const mod = await loadBundledModule(filepath, output.code);
|
|
256
119
|
return { config: await configFromModule(mod), dependencies };
|
|
257
120
|
}
|
|
258
|
-
async function loadTranspiled(filepath, cwd) {
|
|
259
|
-
const file = localFile(filepath, cwd);
|
|
260
|
-
if (!file || !existsSync3(file) || !canTranspile(file)) return void 0;
|
|
261
|
-
try {
|
|
262
|
-
const { value, files } = await importTranspiled(file, configFromModule);
|
|
263
|
-
const base = canonical(cwd);
|
|
264
|
-
const dependencies = new Set(files.map((dependency) => normalize(relative(base, canonical(dependency)))));
|
|
265
|
-
return { config: value, dependencies: Array.from(dependencies) };
|
|
266
|
-
} catch (error) {
|
|
267
|
-
if (!isLoaderFailure(error)) throw error;
|
|
268
|
-
debug("loading %s with the bundler: %s", relative(cwd, file) || file, errorMessage(error));
|
|
269
|
-
return void 0;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
function localFile(filepath, cwd) {
|
|
273
|
-
if (isAbsolute2(filepath)) return filepath;
|
|
274
|
-
if (filepath.startsWith(".")) return join3(cwd, filepath);
|
|
275
|
-
return void 0;
|
|
276
|
-
}
|
|
277
121
|
async function importInstalledConfig(specifier, cwd) {
|
|
278
122
|
if (specifier.startsWith(".") || isAbsolute2(specifier)) return void 0;
|
|
279
123
|
const resolved = tryResolveFrom(specifier, cwd);
|
|
280
124
|
if (!resolved) return void 0;
|
|
281
125
|
const file = canonical(resolved);
|
|
282
|
-
if (!file.includes(`${
|
|
126
|
+
if (!file.includes(`${sep}node_modules${sep}`) || !isEsmFile(file)) return void 0;
|
|
283
127
|
const mod = await import(
|
|
284
128
|
/* @vite-ignore */
|
|
285
|
-
`${
|
|
129
|
+
`${pathToFileURL2(file).href}?mtime=${statSync(file).mtimeMs}`
|
|
286
130
|
);
|
|
287
131
|
return { config: await configFromModule(mod), dependencies: [normalize(relative(canonical(cwd), file))] };
|
|
288
132
|
}
|
|
@@ -292,38 +136,48 @@ async function configFromModule(mod) {
|
|
|
292
136
|
return hasDefaultExport && isPromiseLike(exported) ? await exported : exported;
|
|
293
137
|
}
|
|
294
138
|
function isEsmFile(file) {
|
|
295
|
-
const extension =
|
|
139
|
+
const extension = extname(file);
|
|
296
140
|
if (extension === ".mjs") return true;
|
|
297
141
|
if (extension !== ".js") return false;
|
|
298
|
-
return nearestPackageType(
|
|
142
|
+
return nearestPackageType(dirname(file)) === "module";
|
|
143
|
+
}
|
|
144
|
+
function nearestPackageType(start) {
|
|
145
|
+
let current = start;
|
|
146
|
+
while (true) {
|
|
147
|
+
const candidate = join(current, "package.json");
|
|
148
|
+
if (existsSync(candidate)) return JSON.parse(readFileSync(candidate, "utf8")).type;
|
|
149
|
+
const parent = dirname(current);
|
|
150
|
+
if (parent === current) return void 0;
|
|
151
|
+
current = parent;
|
|
152
|
+
}
|
|
299
153
|
}
|
|
300
154
|
async function loadBundledModule(filepath, code) {
|
|
301
155
|
const target = tempTargetFor(filepath);
|
|
302
|
-
|
|
156
|
+
let evalError;
|
|
157
|
+
if (target) {
|
|
303
158
|
try {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
159
|
+
await mkdir(dirname(target), { recursive: true });
|
|
160
|
+
await writeFile(target, code);
|
|
161
|
+
try {
|
|
162
|
+
return await import(
|
|
163
|
+
/* @vite-ignore */
|
|
164
|
+
pathToFileURL2(target).href
|
|
165
|
+
);
|
|
166
|
+
} finally {
|
|
167
|
+
void unlink(target).catch(() => void 0);
|
|
168
|
+
}
|
|
308
169
|
} catch (error) {
|
|
309
|
-
if (!isUnresolvedTempModule(error, target))
|
|
310
|
-
} finally {
|
|
311
|
-
void unlink(target).catch(() => void 0);
|
|
170
|
+
if (!isUnresolvedTempModule(error, target)) evalError = error;
|
|
312
171
|
}
|
|
313
172
|
}
|
|
314
173
|
const dataUrl = `data:text/javascript;base64,${Buffer.from(code).toString("base64")}`;
|
|
315
|
-
return await import(
|
|
316
|
-
/* @vite-ignore */
|
|
317
|
-
dataUrl
|
|
318
|
-
);
|
|
319
|
-
}
|
|
320
|
-
async function writeTempModule(target, code) {
|
|
321
174
|
try {
|
|
322
|
-
await
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
175
|
+
return await import(
|
|
176
|
+
/* @vite-ignore */
|
|
177
|
+
dataUrl
|
|
178
|
+
);
|
|
179
|
+
} catch (error) {
|
|
180
|
+
throw evalError ?? error;
|
|
327
181
|
}
|
|
328
182
|
}
|
|
329
183
|
function isUnresolvedTempModule(error, target) {
|
|
@@ -333,16 +187,16 @@ function isUnresolvedTempModule(error, target) {
|
|
|
333
187
|
function tempTargetFor(filepath) {
|
|
334
188
|
const unique = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
335
189
|
const name = `panda.config.bundled.${unique}.mjs`;
|
|
336
|
-
const nodeModules = nearestNodeModules(
|
|
337
|
-
const base = nodeModules ?
|
|
338
|
-
return
|
|
190
|
+
const nodeModules = nearestNodeModules(dirname(filepath));
|
|
191
|
+
const base = nodeModules ? join(nodeModules, ".panda") : join(tmpdir(), "panda-config");
|
|
192
|
+
return join(base, name);
|
|
339
193
|
}
|
|
340
194
|
function nearestNodeModules(start) {
|
|
341
195
|
let current = start;
|
|
342
196
|
while (true) {
|
|
343
|
-
const candidate =
|
|
344
|
-
if (
|
|
345
|
-
const parent =
|
|
197
|
+
const candidate = join(current, "node_modules");
|
|
198
|
+
if (existsSync(candidate)) return candidate;
|
|
199
|
+
const parent = dirname(current);
|
|
346
200
|
if (parent === current) return void 0;
|
|
347
201
|
current = parent;
|
|
348
202
|
}
|
|
@@ -373,7 +227,7 @@ function canonical(filepath) {
|
|
|
373
227
|
|
|
374
228
|
// src/find.ts
|
|
375
229
|
import { readdirSync } from "node:fs";
|
|
376
|
-
import { dirname as
|
|
230
|
+
import { dirname as dirname2, resolve as resolve2 } from "node:path";
|
|
377
231
|
var configFiles = /* @__PURE__ */ new Set([
|
|
378
232
|
"panda.config.ts",
|
|
379
233
|
"panda.config.js",
|
|
@@ -394,7 +248,7 @@ function findUp(cwd) {
|
|
|
394
248
|
}
|
|
395
249
|
const match = entries.find(isPandaConfig);
|
|
396
250
|
if (match) return resolve2(dir, match);
|
|
397
|
-
const parent =
|
|
251
|
+
const parent = dirname2(dir);
|
|
398
252
|
if (parent === dir) return void 0;
|
|
399
253
|
dir = parent;
|
|
400
254
|
}
|
|
@@ -635,13 +489,13 @@ import { normalize as normalize2, relative as relative5 } from "node:path";
|
|
|
635
489
|
import {
|
|
636
490
|
outdirBasename
|
|
637
491
|
} from "@pandacss/compiler-shared";
|
|
638
|
-
import { readFileSync as
|
|
639
|
-
import { dirname as
|
|
640
|
-
import { pathToFileURL as
|
|
492
|
+
import { readFileSync as readFileSync3, statSync as statSync2 } from "node:fs";
|
|
493
|
+
import { dirname as dirname4, resolve as resolve4 } from "node:path";
|
|
494
|
+
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
641
495
|
|
|
642
496
|
// src/design-system/package.ts
|
|
643
|
-
import { existsSync as
|
|
644
|
-
import { dirname as
|
|
497
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
498
|
+
import { dirname as dirname3, join as join2 } from "node:path";
|
|
645
499
|
|
|
646
500
|
// src/design-system/publishable-files.ts
|
|
647
501
|
import { relative as relative3, resolve as resolve3 } from "node:path";
|
|
@@ -763,7 +617,7 @@ function readPackageIdentity(cwd) {
|
|
|
763
617
|
if (packagePath === void 0) {
|
|
764
618
|
throw new Error(`Could not find a package.json from ${JSON.stringify(cwd)} to build the design system manifest.`);
|
|
765
619
|
}
|
|
766
|
-
const pkg = JSON.parse(
|
|
620
|
+
const pkg = JSON.parse(readFileSync2(packagePath, "utf8"));
|
|
767
621
|
const name = pkg.name;
|
|
768
622
|
if (typeof name !== "string" || name.length === 0) {
|
|
769
623
|
throw new Error(`${JSON.stringify(packagePath)} has no "name"; a design system must be a named package.`);
|
|
@@ -820,9 +674,9 @@ function isSubpathExportMap(exports) {
|
|
|
820
674
|
function nearestPackageJson(start) {
|
|
821
675
|
let current = start;
|
|
822
676
|
while (true) {
|
|
823
|
-
const candidate =
|
|
824
|
-
if (
|
|
825
|
-
const parent =
|
|
677
|
+
const candidate = join2(current, "package.json");
|
|
678
|
+
if (existsSync2(candidate)) return candidate;
|
|
679
|
+
const parent = dirname3(current);
|
|
826
680
|
if (parent === current) return void 0;
|
|
827
681
|
current = parent;
|
|
828
682
|
}
|
|
@@ -857,7 +711,7 @@ async function loadDesignSystemChain(spec, cwd, deps) {
|
|
|
857
711
|
levels.push(level);
|
|
858
712
|
if (parent === void 0) break;
|
|
859
713
|
declaredBy = level.info.name;
|
|
860
|
-
fromDir =
|
|
714
|
+
fromDir = dirname4(manifestPath);
|
|
861
715
|
currentSpec = parent;
|
|
862
716
|
}
|
|
863
717
|
return levels.reverse();
|
|
@@ -1011,7 +865,7 @@ function manifestNotExportedError(spec) {
|
|
|
1011
865
|
async function loadManifestLevel(spec, manifestPath, deps) {
|
|
1012
866
|
let parsed;
|
|
1013
867
|
try {
|
|
1014
|
-
parsed = JSON.parse(
|
|
868
|
+
parsed = JSON.parse(readFileSync3(manifestPath, "utf8"));
|
|
1015
869
|
} catch (error) {
|
|
1016
870
|
const message = `Failed to parse ${JSON.stringify(manifestPath)} as JSON: ${errorMessage(error)}. This file must be generated by \`panda lib\`, not hand-written or added to \`include\`.`;
|
|
1017
871
|
throw createConfigError(message, [
|
|
@@ -1019,8 +873,8 @@ async function loadManifestLevel(spec, manifestPath, deps) {
|
|
|
1019
873
|
]);
|
|
1020
874
|
}
|
|
1021
875
|
const manifest = validateManifest(spec, manifestPath, parsed);
|
|
1022
|
-
const presetPath = resolve4(
|
|
1023
|
-
const buildInfoPath = resolve4(
|
|
876
|
+
const presetPath = resolve4(dirname4(manifestPath), manifest.preset);
|
|
877
|
+
const buildInfoPath = resolve4(dirname4(manifestPath), manifest.buildInfo);
|
|
1024
878
|
deps.add(presetPath);
|
|
1025
879
|
deps.add(buildInfoPath);
|
|
1026
880
|
let preset;
|
|
@@ -1060,9 +914,9 @@ async function loadManifestLevel(spec, manifestPath, deps) {
|
|
|
1060
914
|
}
|
|
1061
915
|
function readPackageExports(manifestPath) {
|
|
1062
916
|
try {
|
|
1063
|
-
const packageJsonPath = nearestPackageJson(
|
|
917
|
+
const packageJsonPath = nearestPackageJson(dirname4(manifestPath));
|
|
1064
918
|
if (packageJsonPath === void 0) return void 0;
|
|
1065
|
-
const pkg = JSON.parse(
|
|
919
|
+
const pkg = JSON.parse(readFileSync3(packageJsonPath, "utf8"));
|
|
1066
920
|
return isExportsMap(pkg.exports) ? pkg.exports : void 0;
|
|
1067
921
|
} catch {
|
|
1068
922
|
return void 0;
|
|
@@ -1072,8 +926,8 @@ function isExportsMap(value) {
|
|
|
1072
926
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1073
927
|
}
|
|
1074
928
|
function presetImportUrl(path) {
|
|
1075
|
-
const url =
|
|
1076
|
-
url.searchParams.set("mtime", String(
|
|
929
|
+
const url = pathToFileURL3(path);
|
|
930
|
+
url.searchParams.set("mtime", String(statSync2(path).mtimeMs));
|
|
1077
931
|
return url.href;
|
|
1078
932
|
}
|
|
1079
933
|
function designSystemImportMap(map, spec) {
|
|
@@ -1177,8 +1031,8 @@ function unsupportedSpecifierError(spec, protocol) {
|
|
|
1177
1031
|
}
|
|
1178
1032
|
|
|
1179
1033
|
// src/design-system/smart-include.ts
|
|
1180
|
-
import { existsSync as
|
|
1181
|
-
import { dirname as
|
|
1034
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
1035
|
+
import { dirname as dirname5, isAbsolute as isAbsolute4, join as join3, relative as relative4, resolve as resolve5, sep as sep2 } from "node:path";
|
|
1182
1036
|
var SMART_INCLUDE_EXTENSIONS = ["js", "mjs", "cjs", "jsx", "ts", "cts", "mts", "tsx", "vue", "svelte", "astro"];
|
|
1183
1037
|
var MANIFEST_SUBPATH = "panda/lib.json";
|
|
1184
1038
|
var PACKAGE_SPECIFIER = /^(?:@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/i;
|
|
@@ -1205,11 +1059,11 @@ function resolveSmartInclude(include, cwd, deps) {
|
|
|
1205
1059
|
next.push(entry);
|
|
1206
1060
|
continue;
|
|
1207
1061
|
}
|
|
1208
|
-
if (
|
|
1062
|
+
if (existsSync3(join3(packageDir, ...MANIFEST_SUBPATH.split("/")))) {
|
|
1209
1063
|
offenders.push(entry);
|
|
1210
1064
|
continue;
|
|
1211
1065
|
}
|
|
1212
|
-
deps.add(
|
|
1066
|
+
deps.add(join3(packageDir, "package.json"));
|
|
1213
1067
|
const base = globBase(packageDir, cwd);
|
|
1214
1068
|
next.push(`${base}/**/*.{${SMART_INCLUDE_EXTENSIONS.join(",")}}`);
|
|
1215
1069
|
excludes.push(`${base}/**/node_modules/**`);
|
|
@@ -1228,11 +1082,11 @@ function mergeExcludes(existing, additions) {
|
|
|
1228
1082
|
return [...existing ?? [], ...additions];
|
|
1229
1083
|
}
|
|
1230
1084
|
function isLocalPath(entry, cwd) {
|
|
1231
|
-
return
|
|
1085
|
+
return existsSync3(isAbsolute4(entry) ? entry : resolve5(cwd, entry));
|
|
1232
1086
|
}
|
|
1233
1087
|
function resolvePackageDir(spec, cwd) {
|
|
1234
1088
|
const fromPackageJson = tryResolve(`${spec}/package.json`, cwd);
|
|
1235
|
-
if (fromPackageJson !== void 0) return
|
|
1089
|
+
if (fromPackageJson !== void 0) return dirname5(fromPackageJson);
|
|
1236
1090
|
const fromEntry = tryResolve(spec, cwd);
|
|
1237
1091
|
return fromEntry === void 0 ? void 0 : nearestPackageDir(fromEntry);
|
|
1238
1092
|
}
|
|
@@ -1247,13 +1101,13 @@ function tryResolve(request, cwd) {
|
|
|
1247
1101
|
function isInsideCwd(relativePath) {
|
|
1248
1102
|
if (relativePath === "" || relativePath === "..") return false;
|
|
1249
1103
|
if (isAbsolute4(relativePath)) return false;
|
|
1250
|
-
return !relativePath.startsWith(`..${
|
|
1104
|
+
return !relativePath.startsWith(`..${sep2}`);
|
|
1251
1105
|
}
|
|
1252
1106
|
function nearestPackageDir(from) {
|
|
1253
|
-
let dir =
|
|
1107
|
+
let dir = dirname5(from);
|
|
1254
1108
|
while (true) {
|
|
1255
|
-
if (
|
|
1256
|
-
const parent =
|
|
1109
|
+
if (existsSync3(join3(dir, "package.json"))) return dir;
|
|
1110
|
+
const parent = dirname5(dir);
|
|
1257
1111
|
if (parent === dir) return void 0;
|
|
1258
1112
|
dir = parent;
|
|
1259
1113
|
}
|
|
@@ -1719,15 +1573,15 @@ function isConfigSnapshot(input) {
|
|
|
1719
1573
|
}
|
|
1720
1574
|
|
|
1721
1575
|
// src/version.ts
|
|
1722
|
-
import { readFileSync as
|
|
1723
|
-
import { dirname as
|
|
1724
|
-
import { fileURLToPath
|
|
1576
|
+
import { readFileSync as readFileSync4 } from "node:fs";
|
|
1577
|
+
import { dirname as dirname6, join as join4 } from "node:path";
|
|
1578
|
+
import { fileURLToPath } from "node:url";
|
|
1725
1579
|
var MAJOR_VERSION_RE = /\d+/;
|
|
1726
1580
|
var STAMPABLE_PANDA_RANGE_RE = /^[v=><~^]|^\d/;
|
|
1727
1581
|
function readPandaVersion() {
|
|
1728
1582
|
try {
|
|
1729
|
-
const pkgPath =
|
|
1730
|
-
return JSON.parse(
|
|
1583
|
+
const pkgPath = join4(dirname6(fileURLToPath(import.meta.url)), "../package.json");
|
|
1584
|
+
return JSON.parse(readFileSync4(pkgPath, "utf8")).version;
|
|
1731
1585
|
} catch {
|
|
1732
1586
|
return void 0;
|
|
1733
1587
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/config",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Self-contained loader that bundles and serializes a Panda config for the Rust compiler",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"dist"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@pandacss/compiler-shared": "2.
|
|
43
|
-
"@pandacss/types": "2.
|
|
42
|
+
"@pandacss/compiler-shared": "2.2.0",
|
|
43
|
+
"@pandacss/types": "2.2.0",
|
|
44
44
|
"acorn": "^8.17.0",
|
|
45
45
|
"acorn-walk": "^8.3.5",
|
|
46
46
|
"javascript-stringify": "2.1.0",
|