@pandacss/config 1.11.4 → 1.12.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.d.mts CHANGED
@@ -5,6 +5,8 @@ import { TSConfig } from 'pkg-types';
5
5
  import { P as PathMapping } from './ts-config-paths-qwrwgu2Q.mjs';
6
6
  export { c as convertTsPathsToRegexes } from './ts-config-paths-qwrwgu2Q.mjs';
7
7
  export { mergeConfigs, mergeHooks } from './merge-config.mjs';
8
+ import * as get_tsconfig from 'get-tsconfig';
9
+ import { TsConfigJsonResolved } from 'get-tsconfig';
8
10
 
9
11
  interface ConfigFileOptions {
10
12
  cwd: string;
@@ -56,4 +58,39 @@ declare function loadConfig(options: ConfigFileOptions): Promise<_pandacss_types
56
58
  */
57
59
  declare function resolveConfig(result: BundleConfigResult, cwd: string): Promise<LoadConfigResult>;
58
60
 
59
- export { type BundleConfigResult, type GetDepsOptions, bundleConfig, findConfig, getConfigDependencies, getResolvedConfig, loadConfig, resolveConfig };
61
+ /**
62
+ * Resolve the tsconfig file esbuild should use when bundling a config file.
63
+ *
64
+ * 1. Prefer the project that owns the config file (inclusion / references).
65
+ * 2. If that project has no `paths`, fall back to the first referenced project
66
+ * that defines them (Vite: config owned by tsconfig.node.json, aliases on
67
+ * tsconfig.app.json).
68
+ */
69
+ declare function resolveTsconfigForConfigBundle(configFile: string, cwd: string): Promise<string | undefined>;
70
+
71
+ /**
72
+ * If `filename` points to a `.json` file that exists as a regular file, return its absolute path.
73
+ */
74
+ declare function resolveDirectTsconfigJson(filename: string): Promise<string | null>;
75
+ /**
76
+ * Walk upward from `dirname(filename)` and return the first existing `configName`,
77
+ * stopping at `root` (inclusive) or the filesystem root.
78
+ */
79
+ declare function findClosestTsconfig(filename: string, root: string, configName?: string): Promise<string | null>;
80
+ /**
81
+ * Resolve `compilerOptions.baseUrl` the same way TypeScript does: relative to the tsconfig file.
82
+ * Falls back to `cwd` when `baseUrl` is omitted.
83
+ */
84
+ declare function resolveBaseUrlForCompilerOptions(baseUrl: string | undefined, tsconfigFile: string, cwd: string): string;
85
+ /**
86
+ * When a file belongs to a referenced project (TypeScript project references),
87
+ * return that project's merged tsconfig for `compilerOptions`.
88
+ */
89
+ declare function resolveSolutionTsconfigForFile(absoluteFilename: string, rootTsconfigPath: string, rootParsed: TsConfigJsonResolved, getTsconfigModule: typeof get_tsconfig): Promise<{
90
+ tsconfig: TsConfigJsonResolved;
91
+ tsconfigFile: string;
92
+ }>;
93
+ /** Whether `absoluteFilename` is part of the compilation set defined by this tsconfig. */
94
+ declare function isSourceFileIncludedInTsconfig(absoluteFilename: string, tsconfigFile: string, tsconfig: TsConfigJsonResolved): boolean;
95
+
96
+ export { type BundleConfigResult, type GetDepsOptions, bundleConfig, findClosestTsconfig, findConfig, getConfigDependencies, getResolvedConfig, isSourceFileIncludedInTsconfig, loadConfig, resolveBaseUrlForCompilerOptions, resolveConfig, resolveDirectTsconfigJson, resolveSolutionTsconfigForFile, resolveTsconfigForConfigBundle };
package/dist/index.d.ts CHANGED
@@ -5,6 +5,8 @@ import { TSConfig } from 'pkg-types';
5
5
  import { P as PathMapping } from './ts-config-paths-qwrwgu2Q.js';
6
6
  export { c as convertTsPathsToRegexes } from './ts-config-paths-qwrwgu2Q.js';
7
7
  export { mergeConfigs, mergeHooks } from './merge-config.js';
8
+ import * as get_tsconfig from 'get-tsconfig';
9
+ import { TsConfigJsonResolved } from 'get-tsconfig';
8
10
 
9
11
  interface ConfigFileOptions {
10
12
  cwd: string;
@@ -56,4 +58,39 @@ declare function loadConfig(options: ConfigFileOptions): Promise<_pandacss_types
56
58
  */
57
59
  declare function resolveConfig(result: BundleConfigResult, cwd: string): Promise<LoadConfigResult>;
58
60
 
59
- export { type BundleConfigResult, type GetDepsOptions, bundleConfig, findConfig, getConfigDependencies, getResolvedConfig, loadConfig, resolveConfig };
61
+ /**
62
+ * Resolve the tsconfig file esbuild should use when bundling a config file.
63
+ *
64
+ * 1. Prefer the project that owns the config file (inclusion / references).
65
+ * 2. If that project has no `paths`, fall back to the first referenced project
66
+ * that defines them (Vite: config owned by tsconfig.node.json, aliases on
67
+ * tsconfig.app.json).
68
+ */
69
+ declare function resolveTsconfigForConfigBundle(configFile: string, cwd: string): Promise<string | undefined>;
70
+
71
+ /**
72
+ * If `filename` points to a `.json` file that exists as a regular file, return its absolute path.
73
+ */
74
+ declare function resolveDirectTsconfigJson(filename: string): Promise<string | null>;
75
+ /**
76
+ * Walk upward from `dirname(filename)` and return the first existing `configName`,
77
+ * stopping at `root` (inclusive) or the filesystem root.
78
+ */
79
+ declare function findClosestTsconfig(filename: string, root: string, configName?: string): Promise<string | null>;
80
+ /**
81
+ * Resolve `compilerOptions.baseUrl` the same way TypeScript does: relative to the tsconfig file.
82
+ * Falls back to `cwd` when `baseUrl` is omitted.
83
+ */
84
+ declare function resolveBaseUrlForCompilerOptions(baseUrl: string | undefined, tsconfigFile: string, cwd: string): string;
85
+ /**
86
+ * When a file belongs to a referenced project (TypeScript project references),
87
+ * return that project's merged tsconfig for `compilerOptions`.
88
+ */
89
+ declare function resolveSolutionTsconfigForFile(absoluteFilename: string, rootTsconfigPath: string, rootParsed: TsConfigJsonResolved, getTsconfigModule: typeof get_tsconfig): Promise<{
90
+ tsconfig: TsConfigJsonResolved;
91
+ tsconfigFile: string;
92
+ }>;
93
+ /** Whether `absoluteFilename` is part of the compilation set defined by this tsconfig. */
94
+ declare function isSourceFileIncludedInTsconfig(absoluteFilename: string, tsconfigFile: string, tsconfig: TsConfigJsonResolved): boolean;
95
+
96
+ export { type BundleConfigResult, type GetDepsOptions, bundleConfig, findClosestTsconfig, findConfig, getConfigDependencies, getResolvedConfig, isSourceFileIncludedInTsconfig, loadConfig, resolveBaseUrlForCompilerOptions, resolveConfig, resolveDirectTsconfigJson, resolveSolutionTsconfigForFile, resolveTsconfigForConfigBundle };
package/dist/index.js CHANGED
@@ -33,13 +33,19 @@ __export(index_exports, {
33
33
  bundleConfig: () => bundleConfig,
34
34
  convertTsPathsToRegexes: () => convertTsPathsToRegexes,
35
35
  diffConfigs: () => diffConfigs,
36
+ findClosestTsconfig: () => findClosestTsconfig,
36
37
  findConfig: () => findConfig,
37
38
  getConfigDependencies: () => getConfigDependencies,
38
39
  getResolvedConfig: () => getResolvedConfig,
40
+ isSourceFileIncludedInTsconfig: () => isSourceFileIncludedInTsconfig,
39
41
  loadConfig: () => loadConfig,
40
42
  mergeConfigs: () => mergeConfigs,
41
43
  mergeHooks: () => mergeHooks,
42
- resolveConfig: () => resolveConfig
44
+ resolveBaseUrlForCompilerOptions: () => resolveBaseUrlForCompilerOptions,
45
+ resolveConfig: () => resolveConfig,
46
+ resolveDirectTsconfigJson: () => resolveDirectTsconfigJson,
47
+ resolveSolutionTsconfigForFile: () => resolveSolutionTsconfigForFile,
48
+ resolveTsconfigForConfigBundle: () => resolveTsconfigForConfigBundle
43
49
  });
44
50
  module.exports = __toCommonJS(index_exports);
45
51
 
@@ -48,12 +54,277 @@ var import_logger = require("@pandacss/logger");
48
54
  var import_shared2 = require("@pandacss/shared");
49
55
 
50
56
  // src/bundle-n-require.ts
51
- var import_node_fs = require("fs");
57
+ var import_node_fs3 = require("fs");
52
58
  var import_node_module = require("module");
53
- var import_node_path = require("path");
59
+ var import_node_path3 = require("path");
54
60
  var import_esbuild = require("esbuild");
61
+
62
+ // src/resolve-tsconfig.ts
63
+ var import_node_fs2 = require("fs");
64
+ var import_node_path2 = __toESM(require("path"));
65
+
66
+ // src/tsconfig-utils.ts
67
+ var import_node_fs = require("fs");
68
+ var import_node_path = __toESM(require("path"));
69
+ async function resolveDirectTsconfigJson(filename) {
70
+ if (import_node_path.default.extname(filename) !== ".json") return null;
71
+ const resolved = import_node_path.default.resolve(filename);
72
+ try {
73
+ const stat = await import_node_fs.promises.stat(resolved);
74
+ if (stat.isFile() || stat.isFIFO()) return resolved;
75
+ throw new Error(`${filename} exists but is not a regular file.`);
76
+ } catch (e) {
77
+ if (e && typeof e === "object" && "code" in e && e.code === "ENOENT") {
78
+ return null;
79
+ }
80
+ throw e;
81
+ }
82
+ }
83
+ async function findClosestTsconfig(filename, root, configName2 = "tsconfig.json") {
84
+ const resolvedRoot = import_node_path.default.resolve(root);
85
+ let dir = import_node_path.default.dirname(import_node_path.default.resolve(filename));
86
+ for (; ; ) {
87
+ const candidate = import_node_path.default.join(dir, configName2);
88
+ try {
89
+ const stat = await import_node_fs.promises.stat(candidate);
90
+ if (stat.isFile() || stat.isFIFO()) {
91
+ return candidate;
92
+ }
93
+ } catch {
94
+ }
95
+ if (dir === resolvedRoot || import_node_path.default.dirname(dir) === dir) {
96
+ return null;
97
+ }
98
+ dir = import_node_path.default.dirname(dir);
99
+ }
100
+ }
101
+ function resolveBaseUrlForCompilerOptions(baseUrl, tsconfigFile, cwd) {
102
+ if (baseUrl == null) return cwd;
103
+ if (baseUrl.startsWith("${")) return baseUrl;
104
+ if (import_node_path.default.isAbsolute(baseUrl)) return baseUrl;
105
+ return import_node_path.default.resolve(import_node_path.default.dirname(tsconfigFile), baseUrl);
106
+ }
107
+ var SOURCE_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts"];
108
+ function resolveReferencedTsconfigPath(refPath, fromDir, configName2 = "tsconfig.json") {
109
+ const p = refPath.endsWith(".json") ? refPath : import_node_path.default.join(refPath, configName2);
110
+ return import_node_path.default.resolve(fromDir, p);
111
+ }
112
+ async function resolveSolutionTsconfigForFile(absoluteFilename, rootTsconfigPath, rootParsed, getTsconfigModule) {
113
+ const { parseTsconfig } = getTsconfigModule;
114
+ if (isSourceFileIncludedInTsconfig(absoluteFilename, rootTsconfigPath, rootParsed)) {
115
+ return { tsconfig: rootParsed, tsconfigFile: rootTsconfigPath };
116
+ }
117
+ const refs = rootParsed.references;
118
+ if (!refs?.length) {
119
+ return { tsconfig: rootParsed, tsconfigFile: rootTsconfigPath };
120
+ }
121
+ if (!SOURCE_EXTENSIONS.some((ext) => absoluteFilename.endsWith(ext))) {
122
+ return { tsconfig: rootParsed, tsconfigFile: rootTsconfigPath };
123
+ }
124
+ const rootDir = import_node_path.default.dirname(rootTsconfigPath);
125
+ for (const ref of refs) {
126
+ const refPath = resolveReferencedTsconfigPath(ref.path, rootDir);
127
+ try {
128
+ await import_node_fs.promises.access(refPath);
129
+ } catch {
130
+ continue;
131
+ }
132
+ const childParsed = parseTsconfig(refPath);
133
+ if (isSourceFileIncludedInTsconfig(absoluteFilename, refPath, childParsed)) {
134
+ return { tsconfig: childParsed, tsconfigFile: refPath };
135
+ }
136
+ }
137
+ return { tsconfig: rootParsed, tsconfigFile: rootTsconfigPath };
138
+ }
139
+ var POSIX_SEP_RE = new RegExp("\\" + import_node_path.default.posix.sep, "g");
140
+ var NATIVE_SEP_RE = new RegExp("\\" + import_node_path.default.sep, "g");
141
+ var PATTERN_REGEX_CACHE = /* @__PURE__ */ new Map();
142
+ var GLOB_ALL_PATTERN = `**/*`;
143
+ var TS_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts"];
144
+ var JS_EXTENSIONS = [".js", ".jsx", ".mjs", ".cjs"];
145
+ var TSJS_EXTENSIONS = TS_EXTENSIONS.concat(JS_EXTENSIONS);
146
+ var TS_EXTENSIONS_RE_GROUP = `\\.(?:${TS_EXTENSIONS.map((ext) => ext.slice(1)).join("|")})`;
147
+ var TSJS_EXTENSIONS_RE_GROUP = `\\.(?:${TSJS_EXTENSIONS.map((ext) => ext.slice(1)).join("|")})`;
148
+ var IS_POSIX = import_node_path.default.posix.sep === import_node_path.default.sep;
149
+ var native2posix = IS_POSIX ? (filename) => filename : (filename) => filename.replace(NATIVE_SEP_RE, import_node_path.default.posix.sep);
150
+ var resolve2posix = IS_POSIX ? (dir, filename) => dir ? import_node_path.default.resolve(dir, filename) : import_node_path.default.resolve(filename) : (dir, filename) => {
151
+ const posix2native = (f) => f.replace(POSIX_SEP_RE, import_node_path.default.sep);
152
+ return native2posix(
153
+ dir ? import_node_path.default.resolve(posix2native(dir), posix2native(filename)) : import_node_path.default.resolve(posix2native(filename))
154
+ );
155
+ };
156
+ function isGlobMatch(filename, dir, patterns, allowJs) {
157
+ const extensions = allowJs ? TSJS_EXTENSIONS : TS_EXTENSIONS;
158
+ return patterns.some((patternArg) => {
159
+ let pattern = patternArg;
160
+ let lastWildcardIndex = pattern.length;
161
+ let hasWildcard = false;
162
+ let hasExtension = false;
163
+ let hasSlash = false;
164
+ let lastSlashIndex = -1;
165
+ for (let i = pattern.length - 1; i > -1; i--) {
166
+ const c = pattern[i];
167
+ if (!hasWildcard) {
168
+ if (c === "*" || c === "?") {
169
+ lastWildcardIndex = i;
170
+ hasWildcard = true;
171
+ }
172
+ }
173
+ if (!hasSlash) {
174
+ if (c === ".") {
175
+ hasExtension = true;
176
+ } else if (c === "/") {
177
+ lastSlashIndex = i;
178
+ hasSlash = true;
179
+ }
180
+ }
181
+ if (hasWildcard && hasSlash) {
182
+ break;
183
+ }
184
+ }
185
+ if (!hasExtension && (!hasWildcard || lastWildcardIndex < lastSlashIndex)) {
186
+ pattern += `${pattern.endsWith("/") ? "" : "/"}${GLOB_ALL_PATTERN}`;
187
+ lastWildcardIndex = pattern.length - 1;
188
+ hasWildcard = true;
189
+ }
190
+ if (lastWildcardIndex < pattern.length - 1 && !filename.endsWith(pattern.slice(lastWildcardIndex + 1))) {
191
+ return false;
192
+ }
193
+ if (pattern.endsWith("*") && !extensions.some((ext) => filename.endsWith(ext))) {
194
+ return false;
195
+ }
196
+ if (pattern === GLOB_ALL_PATTERN) {
197
+ return filename.startsWith(`${dir}/`);
198
+ }
199
+ const resolvedPattern = resolve2posix(dir, pattern);
200
+ let firstWildcardIndex = -1;
201
+ for (let i = 0; i < resolvedPattern.length; i++) {
202
+ if (resolvedPattern[i] === "*" || resolvedPattern[i] === "?") {
203
+ firstWildcardIndex = i;
204
+ hasWildcard = true;
205
+ break;
206
+ }
207
+ }
208
+ if (firstWildcardIndex > 1 && !filename.startsWith(resolvedPattern.slice(0, firstWildcardIndex - 1))) {
209
+ return false;
210
+ }
211
+ if (!hasWildcard) {
212
+ return filename === resolvedPattern;
213
+ }
214
+ if (firstWildcardIndex + GLOB_ALL_PATTERN.length === resolvedPattern.length - (pattern.length - 1 - lastWildcardIndex) && resolvedPattern.slice(firstWildcardIndex, firstWildcardIndex + GLOB_ALL_PATTERN.length) === GLOB_ALL_PATTERN) {
215
+ return true;
216
+ }
217
+ if (PATTERN_REGEX_CACHE.has(resolvedPattern)) {
218
+ return PATTERN_REGEX_CACHE.get(resolvedPattern).test(filename);
219
+ }
220
+ const regex = pattern2regex(resolvedPattern, allowJs);
221
+ PATTERN_REGEX_CACHE.set(resolvedPattern, regex);
222
+ return regex.test(filename);
223
+ });
224
+ }
225
+ function pattern2regex(resolvedPattern, allowJs) {
226
+ let regexStr = "^";
227
+ for (let i = 0; i < resolvedPattern.length; i++) {
228
+ const char = resolvedPattern[i];
229
+ if (char === "?") {
230
+ regexStr += "[^\\/]";
231
+ continue;
232
+ }
233
+ if (char === "*") {
234
+ if (resolvedPattern[i + 1] === "*" && resolvedPattern[i + 2] === "/") {
235
+ i += 2;
236
+ regexStr += "(?:[^\\/]*\\/)*";
237
+ continue;
238
+ }
239
+ regexStr += "[^\\/]*";
240
+ continue;
241
+ }
242
+ if ("/.+^${}()|[]\\".includes(char)) {
243
+ regexStr += "\\";
244
+ }
245
+ regexStr += char;
246
+ }
247
+ if (resolvedPattern.endsWith("*")) {
248
+ regexStr += allowJs ? TSJS_EXTENSIONS_RE_GROUP : TS_EXTENSIONS_RE_GROUP;
249
+ }
250
+ regexStr += "$";
251
+ return new RegExp(regexStr);
252
+ }
253
+ function isIncluded(filename, tsconfigFile, tsconfig) {
254
+ const dir = native2posix(import_node_path.default.dirname(tsconfigFile));
255
+ const files = (tsconfig.files || []).map((file) => resolve2posix(dir, file));
256
+ const absoluteFilename = resolve2posix(null, filename);
257
+ if (files.includes(filename)) {
258
+ return true;
259
+ }
260
+ const allowJs = tsconfig.compilerOptions?.allowJs;
261
+ const included = isGlobMatch(
262
+ absoluteFilename,
263
+ dir,
264
+ tsconfig.include || (tsconfig.files ? [] : [GLOB_ALL_PATTERN]),
265
+ allowJs
266
+ );
267
+ if (included) {
268
+ const excluded = isGlobMatch(absoluteFilename, dir, tsconfig.exclude || [], allowJs);
269
+ return !excluded;
270
+ }
271
+ return false;
272
+ }
273
+ function isSourceFileIncludedInTsconfig(absoluteFilename, tsconfigFile, tsconfig) {
274
+ return isIncluded(absoluteFilename, tsconfigFile, tsconfig);
275
+ }
276
+
277
+ // src/resolve-tsconfig.ts
278
+ function hasPathMappings(tsconfig) {
279
+ const paths = tsconfig.compilerOptions?.paths;
280
+ return Boolean(paths && Object.keys(paths).length > 0);
281
+ }
282
+ function resolveReferencedTsconfigPath2(refPath, fromDir, configName2 = "tsconfig.json") {
283
+ const p = refPath.endsWith(".json") ? refPath : import_node_path2.default.join(refPath, configName2);
284
+ return import_node_path2.default.resolve(fromDir, p);
285
+ }
286
+ async function resolveTsconfigForConfigBundle(configFile, cwd) {
287
+ const closest = await findClosestTsconfig(configFile, cwd);
288
+ if (!closest) return void 0;
289
+ const gtc = await import("get-tsconfig");
290
+ let rootParsed;
291
+ try {
292
+ rootParsed = gtc.parseTsconfig(closest);
293
+ } catch {
294
+ return closest;
295
+ }
296
+ const owned = await resolveSolutionTsconfigForFile(import_node_path2.default.resolve(configFile), closest, rootParsed, gtc);
297
+ if (hasPathMappings(owned.tsconfig)) {
298
+ return owned.tsconfigFile;
299
+ }
300
+ const refs = rootParsed.references;
301
+ if (!refs?.length) {
302
+ return owned.tsconfigFile;
303
+ }
304
+ const rootDir = import_node_path2.default.dirname(closest);
305
+ for (const ref of refs) {
306
+ const refPath = resolveReferencedTsconfigPath2(ref.path, rootDir);
307
+ try {
308
+ await import_node_fs2.promises.access(refPath);
309
+ } catch {
310
+ continue;
311
+ }
312
+ try {
313
+ const childParsed = gtc.parseTsconfig(refPath);
314
+ if (hasPathMappings(childParsed)) {
315
+ return refPath;
316
+ }
317
+ } catch {
318
+ continue;
319
+ }
320
+ }
321
+ return owned.tsconfigFile;
322
+ }
323
+
324
+ // src/bundle-n-require.ts
55
325
  var ModuleInternals = import_node_module.Module;
56
326
  async function bundleConfigFile(file, cwd, options) {
327
+ const tsconfig = options?.tsconfig ?? await resolveTsconfigForConfigBundle(file, cwd);
57
328
  const result = await (0, import_esbuild.build)({
58
329
  platform: "node",
59
330
  format: "cjs",
@@ -65,7 +336,8 @@ async function bundleConfigFile(file, cwd, options) {
65
336
  write: false,
66
337
  bundle: true,
67
338
  sourcemap: false,
68
- metafile: true
339
+ metafile: true,
340
+ ...tsconfig ? { tsconfig } : {}
69
341
  });
70
342
  const { text } = result.outputFiles[0];
71
343
  return {
@@ -74,8 +346,8 @@ async function bundleConfigFile(file, cwd, options) {
74
346
  };
75
347
  }
76
348
  function loadBundledFile(req, file, code) {
77
- const extension = (0, import_node_path.extname)(file);
78
- const realFileName = import_node_fs.realpathSync.native(file);
349
+ const extension = (0, import_node_path3.extname)(file);
350
+ const realFileName = import_node_fs3.realpathSync.native(file);
79
351
  const loader = req.extensions[extension];
80
352
  req.extensions[extension] = (mod, filename) => {
81
353
  if (filename === realFileName) {
@@ -97,14 +369,14 @@ function loadBundledFile(req, file, code) {
97
369
  function evalBundledFile(file, code) {
98
370
  const mod = new import_node_module.Module(file);
99
371
  mod.filename = file;
100
- mod.paths = ModuleInternals._nodeModulePaths((0, import_node_path.dirname)(file));
372
+ mod.paths = ModuleInternals._nodeModulePaths((0, import_node_path3.dirname)(file));
101
373
  mod._compile(code, file);
102
374
  const raw = mod.exports;
103
375
  return raw?.default ?? raw;
104
376
  }
105
377
  async function bundleNRequire(file, opts = {}) {
106
378
  const { cwd = process.cwd() } = opts;
107
- const req = (0, import_node_module.createRequire)((0, import_node_path.join)(cwd, "index.js"));
379
+ const req = (0, import_node_module.createRequire)((0, import_node_path3.join)(cwd, "index.js"));
108
380
  const absPath = req.resolve(file);
109
381
  const { code, dependencies } = await bundleConfigFile(absPath, cwd);
110
382
  let mod;
@@ -195,9 +467,9 @@ function createMatcher(id, patterns) {
195
467
  });
196
468
  const include = new RegExp(includePatterns.join("|"));
197
469
  const exclude = new RegExp(excludePatterns.join("|"));
198
- return (path2) => {
199
- if (excludePatterns.length && exclude.test(path2)) return;
200
- return include.test(path2) ? id : void 0;
470
+ return (path4) => {
471
+ if (excludePatterns.length && exclude.test(path4)) return;
472
+ return include.test(path4) ? id : void 0;
201
473
  };
202
474
  }
203
475
 
@@ -613,7 +885,7 @@ var REFERENCE_REGEX = /({([^}]*)})/g;
613
885
  var curlyBracketRegex = /[{}]/g;
614
886
  var isValidToken = (token) => (0, import_shared4.isObject)(token) && Object.hasOwnProperty.call(token, "value");
615
887
  var isTokenReference = (value) => typeof value === "string" && REFERENCE_REGEX.test(value);
616
- var formatPath = (path2) => path2;
888
+ var formatPath = (path4) => path4;
617
889
  var SEP = ".";
618
890
  function getReferences(value) {
619
891
  if (typeof value !== "string") return [];
@@ -902,11 +1174,11 @@ var import_shared9 = require("@pandacss/shared");
902
1174
  // src/validation/validate-token-references.ts
903
1175
  var validateTokenReferences = (props) => {
904
1176
  const { valueAtPath, refsByPath, addError, typeByPath } = props;
905
- refsByPath.forEach((refs, path2) => {
906
- if (refs.has(path2)) {
907
- addError("tokens", `Self token reference: \`${path2}\``);
1177
+ refsByPath.forEach((refs, path4) => {
1178
+ if (refs.has(path4)) {
1179
+ addError("tokens", `Self token reference: \`${path4}\``);
908
1180
  }
909
- const stack = [path2];
1181
+ const stack = [path4];
910
1182
  while (stack.length > 0) {
911
1183
  let currentPath = stack.pop();
912
1184
  if (currentPath.includes("/")) {
@@ -915,8 +1187,8 @@ var validateTokenReferences = (props) => {
915
1187
  }
916
1188
  const value = valueAtPath.get(currentPath);
917
1189
  if (!value) {
918
- const configKey = typeByPath.get(path2);
919
- addError("tokens", `Missing token: \`${currentPath}\` used in \`theme.${configKey}.${path2}\``);
1190
+ const configKey = typeByPath.get(path4);
1191
+ addError("tokens", `Missing token: \`${currentPath}\` used in \`theme.${configKey}.${path4}\``);
920
1192
  }
921
1193
  if (isTokenReference(value) && !refsByPath.has(value)) {
922
1194
  addError("tokens", `Unknown token reference: \`${currentPath}\` used in \`${value}\``);
@@ -924,10 +1196,10 @@ var validateTokenReferences = (props) => {
924
1196
  const deps = refsByPath.get(currentPath);
925
1197
  if (!deps) continue;
926
1198
  for (const transitiveDep of deps) {
927
- if (path2 === transitiveDep) {
1199
+ if (path4 === transitiveDep) {
928
1200
  addError(
929
1201
  "tokens",
930
- `Circular token reference: \`${transitiveDep}\` -> \`${currentPath}\` -> ... -> \`${path2}\``
1202
+ `Circular token reference: \`${transitiveDep}\` -> \`${currentPath}\` -> ... -> \`${path4}\``
931
1203
  );
932
1204
  break;
933
1205
  }
@@ -951,27 +1223,27 @@ var validateTokens = (options) => {
951
1223
  (0, import_shared9.walkObject)(
952
1224
  theme.tokens,
953
1225
  (value, paths) => {
954
- const path2 = paths.join(SEP);
955
- tokenNames.add(path2);
956
- tokenPaths.add(path2);
957
- valueAtPath.set(path2, value);
958
- if (path2.includes("DEFAULT")) {
959
- valueAtPath.set(path2.replace(SEP + "DEFAULT", ""), value);
1226
+ const path4 = paths.join(SEP);
1227
+ tokenNames.add(path4);
1228
+ tokenPaths.add(path4);
1229
+ valueAtPath.set(path4, value);
1230
+ if (path4.includes("DEFAULT")) {
1231
+ valueAtPath.set(path4.replace(SEP + "DEFAULT", ""), value);
960
1232
  }
961
1233
  },
962
1234
  {
963
1235
  stop: isValidToken
964
1236
  }
965
1237
  );
966
- tokenPaths.forEach((path2) => {
967
- const itemValue = valueAtPath.get(path2);
968
- const formattedPath = formatPath(path2);
1238
+ tokenPaths.forEach((path4) => {
1239
+ const itemValue = valueAtPath.get(path4);
1240
+ const formattedPath = formatPath(path4);
969
1241
  typeByPath.set(formattedPath, "tokens");
970
1242
  if (!isValidToken(itemValue)) {
971
1243
  addError("tokens", `Token must contain 'value': \`theme.tokens.${formattedPath}\``);
972
1244
  return;
973
1245
  }
974
- if (path2.includes(" ")) {
1246
+ if (path4.includes(" ")) {
975
1247
  addError("tokens", `Token key must not contain spaces: \`theme.tokens.${formattedPath}\``);
976
1248
  return;
977
1249
  }
@@ -991,17 +1263,17 @@ var validateTokens = (options) => {
991
1263
  (0, import_shared9.walkObject)(
992
1264
  theme.semanticTokens,
993
1265
  (value, paths) => {
994
- const path2 = paths.join(SEP);
995
- semanticTokenNames.add(path2);
996
- valueAtPath.set(path2, value);
997
- tokenPaths.add(path2);
998
- if (path2.includes("DEFAULT")) {
999
- valueAtPath.set(path2.replace(SEP + "DEFAULT", ""), value);
1266
+ const path4 = paths.join(SEP);
1267
+ semanticTokenNames.add(path4);
1268
+ valueAtPath.set(path4, value);
1269
+ tokenPaths.add(path4);
1270
+ if (path4.includes("DEFAULT")) {
1271
+ valueAtPath.set(path4.replace(SEP + "DEFAULT", ""), value);
1000
1272
  }
1001
1273
  if (!isValidToken(value)) return;
1002
1274
  (0, import_shared9.walkObject)(value, (itemValue, paths2) => {
1003
1275
  const valuePath = paths2.join(SEP);
1004
- const formattedPath = formatPath(path2);
1276
+ const formattedPath = formatPath(path4);
1005
1277
  typeByPath.set(formattedPath, "semanticTokens");
1006
1278
  const fullPath = formattedPath + "." + paths2.join(SEP);
1007
1279
  if (valuePath.includes("value" + SEP + "value")) {
@@ -1024,14 +1296,14 @@ var validateTokens = (options) => {
1024
1296
  stop: isValidToken
1025
1297
  }
1026
1298
  );
1027
- tokenPaths.forEach((path2) => {
1028
- const formattedPath = formatPath(path2);
1029
- const value = valueAtPath.get(path2);
1030
- if (path2.includes(" ")) {
1299
+ tokenPaths.forEach((path4) => {
1300
+ const formattedPath = formatPath(path4);
1301
+ const value = valueAtPath.get(path4);
1302
+ if (path4.includes(" ")) {
1031
1303
  addError("tokens", `Token key must not contain spaces: \`theme.tokens.${formattedPath}\``);
1032
1304
  return;
1033
1305
  }
1034
- if (!(0, import_shared9.isObject)(value) && !path2.includes("value")) {
1306
+ if (!(0, import_shared9.isObject)(value) && !path4.includes("value")) {
1035
1307
  addError("tokens", `Token must contain 'value': \`theme.semanticTokens.${formattedPath}\``);
1036
1308
  }
1037
1309
  });
@@ -1139,11 +1411,17 @@ async function loadConfig(options) {
1139
1411
  bundleConfig,
1140
1412
  convertTsPathsToRegexes,
1141
1413
  diffConfigs,
1414
+ findClosestTsconfig,
1142
1415
  findConfig,
1143
1416
  getConfigDependencies,
1144
1417
  getResolvedConfig,
1418
+ isSourceFileIncludedInTsconfig,
1145
1419
  loadConfig,
1146
1420
  mergeConfigs,
1147
1421
  mergeHooks,
1148
- resolveConfig
1422
+ resolveBaseUrlForCompilerOptions,
1423
+ resolveConfig,
1424
+ resolveDirectTsconfigJson,
1425
+ resolveSolutionTsconfigForFile,
1426
+ resolveTsconfigForConfigBundle
1149
1427
  });
package/dist/index.mjs CHANGED
@@ -24,8 +24,273 @@ import { realpathSync } from "fs";
24
24
  import { createRequire, Module } from "module";
25
25
  import { dirname, extname, join } from "path";
26
26
  import { build } from "esbuild";
27
+
28
+ // src/resolve-tsconfig.ts
29
+ import { promises as fs2 } from "fs";
30
+ import path2 from "path";
31
+
32
+ // src/tsconfig-utils.ts
33
+ import { promises as fs } from "fs";
34
+ import path from "path";
35
+ async function resolveDirectTsconfigJson(filename) {
36
+ if (path.extname(filename) !== ".json") return null;
37
+ const resolved = path.resolve(filename);
38
+ try {
39
+ const stat = await fs.stat(resolved);
40
+ if (stat.isFile() || stat.isFIFO()) return resolved;
41
+ throw new Error(`${filename} exists but is not a regular file.`);
42
+ } catch (e) {
43
+ if (e && typeof e === "object" && "code" in e && e.code === "ENOENT") {
44
+ return null;
45
+ }
46
+ throw e;
47
+ }
48
+ }
49
+ async function findClosestTsconfig(filename, root, configName2 = "tsconfig.json") {
50
+ const resolvedRoot = path.resolve(root);
51
+ let dir = path.dirname(path.resolve(filename));
52
+ for (; ; ) {
53
+ const candidate = path.join(dir, configName2);
54
+ try {
55
+ const stat = await fs.stat(candidate);
56
+ if (stat.isFile() || stat.isFIFO()) {
57
+ return candidate;
58
+ }
59
+ } catch {
60
+ }
61
+ if (dir === resolvedRoot || path.dirname(dir) === dir) {
62
+ return null;
63
+ }
64
+ dir = path.dirname(dir);
65
+ }
66
+ }
67
+ function resolveBaseUrlForCompilerOptions(baseUrl, tsconfigFile, cwd) {
68
+ if (baseUrl == null) return cwd;
69
+ if (baseUrl.startsWith("${")) return baseUrl;
70
+ if (path.isAbsolute(baseUrl)) return baseUrl;
71
+ return path.resolve(path.dirname(tsconfigFile), baseUrl);
72
+ }
73
+ var SOURCE_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts"];
74
+ function resolveReferencedTsconfigPath(refPath, fromDir, configName2 = "tsconfig.json") {
75
+ const p = refPath.endsWith(".json") ? refPath : path.join(refPath, configName2);
76
+ return path.resolve(fromDir, p);
77
+ }
78
+ async function resolveSolutionTsconfigForFile(absoluteFilename, rootTsconfigPath, rootParsed, getTsconfigModule) {
79
+ const { parseTsconfig } = getTsconfigModule;
80
+ if (isSourceFileIncludedInTsconfig(absoluteFilename, rootTsconfigPath, rootParsed)) {
81
+ return { tsconfig: rootParsed, tsconfigFile: rootTsconfigPath };
82
+ }
83
+ const refs = rootParsed.references;
84
+ if (!refs?.length) {
85
+ return { tsconfig: rootParsed, tsconfigFile: rootTsconfigPath };
86
+ }
87
+ if (!SOURCE_EXTENSIONS.some((ext) => absoluteFilename.endsWith(ext))) {
88
+ return { tsconfig: rootParsed, tsconfigFile: rootTsconfigPath };
89
+ }
90
+ const rootDir = path.dirname(rootTsconfigPath);
91
+ for (const ref of refs) {
92
+ const refPath = resolveReferencedTsconfigPath(ref.path, rootDir);
93
+ try {
94
+ await fs.access(refPath);
95
+ } catch {
96
+ continue;
97
+ }
98
+ const childParsed = parseTsconfig(refPath);
99
+ if (isSourceFileIncludedInTsconfig(absoluteFilename, refPath, childParsed)) {
100
+ return { tsconfig: childParsed, tsconfigFile: refPath };
101
+ }
102
+ }
103
+ return { tsconfig: rootParsed, tsconfigFile: rootTsconfigPath };
104
+ }
105
+ var POSIX_SEP_RE = new RegExp("\\" + path.posix.sep, "g");
106
+ var NATIVE_SEP_RE = new RegExp("\\" + path.sep, "g");
107
+ var PATTERN_REGEX_CACHE = /* @__PURE__ */ new Map();
108
+ var GLOB_ALL_PATTERN = `**/*`;
109
+ var TS_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts"];
110
+ var JS_EXTENSIONS = [".js", ".jsx", ".mjs", ".cjs"];
111
+ var TSJS_EXTENSIONS = TS_EXTENSIONS.concat(JS_EXTENSIONS);
112
+ var TS_EXTENSIONS_RE_GROUP = `\\.(?:${TS_EXTENSIONS.map((ext) => ext.slice(1)).join("|")})`;
113
+ var TSJS_EXTENSIONS_RE_GROUP = `\\.(?:${TSJS_EXTENSIONS.map((ext) => ext.slice(1)).join("|")})`;
114
+ var IS_POSIX = path.posix.sep === path.sep;
115
+ var native2posix = IS_POSIX ? (filename) => filename : (filename) => filename.replace(NATIVE_SEP_RE, path.posix.sep);
116
+ var resolve2posix = IS_POSIX ? (dir, filename) => dir ? path.resolve(dir, filename) : path.resolve(filename) : (dir, filename) => {
117
+ const posix2native = (f) => f.replace(POSIX_SEP_RE, path.sep);
118
+ return native2posix(
119
+ dir ? path.resolve(posix2native(dir), posix2native(filename)) : path.resolve(posix2native(filename))
120
+ );
121
+ };
122
+ function isGlobMatch(filename, dir, patterns, allowJs) {
123
+ const extensions = allowJs ? TSJS_EXTENSIONS : TS_EXTENSIONS;
124
+ return patterns.some((patternArg) => {
125
+ let pattern = patternArg;
126
+ let lastWildcardIndex = pattern.length;
127
+ let hasWildcard = false;
128
+ let hasExtension = false;
129
+ let hasSlash = false;
130
+ let lastSlashIndex = -1;
131
+ for (let i = pattern.length - 1; i > -1; i--) {
132
+ const c = pattern[i];
133
+ if (!hasWildcard) {
134
+ if (c === "*" || c === "?") {
135
+ lastWildcardIndex = i;
136
+ hasWildcard = true;
137
+ }
138
+ }
139
+ if (!hasSlash) {
140
+ if (c === ".") {
141
+ hasExtension = true;
142
+ } else if (c === "/") {
143
+ lastSlashIndex = i;
144
+ hasSlash = true;
145
+ }
146
+ }
147
+ if (hasWildcard && hasSlash) {
148
+ break;
149
+ }
150
+ }
151
+ if (!hasExtension && (!hasWildcard || lastWildcardIndex < lastSlashIndex)) {
152
+ pattern += `${pattern.endsWith("/") ? "" : "/"}${GLOB_ALL_PATTERN}`;
153
+ lastWildcardIndex = pattern.length - 1;
154
+ hasWildcard = true;
155
+ }
156
+ if (lastWildcardIndex < pattern.length - 1 && !filename.endsWith(pattern.slice(lastWildcardIndex + 1))) {
157
+ return false;
158
+ }
159
+ if (pattern.endsWith("*") && !extensions.some((ext) => filename.endsWith(ext))) {
160
+ return false;
161
+ }
162
+ if (pattern === GLOB_ALL_PATTERN) {
163
+ return filename.startsWith(`${dir}/`);
164
+ }
165
+ const resolvedPattern = resolve2posix(dir, pattern);
166
+ let firstWildcardIndex = -1;
167
+ for (let i = 0; i < resolvedPattern.length; i++) {
168
+ if (resolvedPattern[i] === "*" || resolvedPattern[i] === "?") {
169
+ firstWildcardIndex = i;
170
+ hasWildcard = true;
171
+ break;
172
+ }
173
+ }
174
+ if (firstWildcardIndex > 1 && !filename.startsWith(resolvedPattern.slice(0, firstWildcardIndex - 1))) {
175
+ return false;
176
+ }
177
+ if (!hasWildcard) {
178
+ return filename === resolvedPattern;
179
+ }
180
+ if (firstWildcardIndex + GLOB_ALL_PATTERN.length === resolvedPattern.length - (pattern.length - 1 - lastWildcardIndex) && resolvedPattern.slice(firstWildcardIndex, firstWildcardIndex + GLOB_ALL_PATTERN.length) === GLOB_ALL_PATTERN) {
181
+ return true;
182
+ }
183
+ if (PATTERN_REGEX_CACHE.has(resolvedPattern)) {
184
+ return PATTERN_REGEX_CACHE.get(resolvedPattern).test(filename);
185
+ }
186
+ const regex = pattern2regex(resolvedPattern, allowJs);
187
+ PATTERN_REGEX_CACHE.set(resolvedPattern, regex);
188
+ return regex.test(filename);
189
+ });
190
+ }
191
+ function pattern2regex(resolvedPattern, allowJs) {
192
+ let regexStr = "^";
193
+ for (let i = 0; i < resolvedPattern.length; i++) {
194
+ const char = resolvedPattern[i];
195
+ if (char === "?") {
196
+ regexStr += "[^\\/]";
197
+ continue;
198
+ }
199
+ if (char === "*") {
200
+ if (resolvedPattern[i + 1] === "*" && resolvedPattern[i + 2] === "/") {
201
+ i += 2;
202
+ regexStr += "(?:[^\\/]*\\/)*";
203
+ continue;
204
+ }
205
+ regexStr += "[^\\/]*";
206
+ continue;
207
+ }
208
+ if ("/.+^${}()|[]\\".includes(char)) {
209
+ regexStr += "\\";
210
+ }
211
+ regexStr += char;
212
+ }
213
+ if (resolvedPattern.endsWith("*")) {
214
+ regexStr += allowJs ? TSJS_EXTENSIONS_RE_GROUP : TS_EXTENSIONS_RE_GROUP;
215
+ }
216
+ regexStr += "$";
217
+ return new RegExp(regexStr);
218
+ }
219
+ function isIncluded(filename, tsconfigFile, tsconfig) {
220
+ const dir = native2posix(path.dirname(tsconfigFile));
221
+ const files = (tsconfig.files || []).map((file) => resolve2posix(dir, file));
222
+ const absoluteFilename = resolve2posix(null, filename);
223
+ if (files.includes(filename)) {
224
+ return true;
225
+ }
226
+ const allowJs = tsconfig.compilerOptions?.allowJs;
227
+ const included = isGlobMatch(
228
+ absoluteFilename,
229
+ dir,
230
+ tsconfig.include || (tsconfig.files ? [] : [GLOB_ALL_PATTERN]),
231
+ allowJs
232
+ );
233
+ if (included) {
234
+ const excluded = isGlobMatch(absoluteFilename, dir, tsconfig.exclude || [], allowJs);
235
+ return !excluded;
236
+ }
237
+ return false;
238
+ }
239
+ function isSourceFileIncludedInTsconfig(absoluteFilename, tsconfigFile, tsconfig) {
240
+ return isIncluded(absoluteFilename, tsconfigFile, tsconfig);
241
+ }
242
+
243
+ // src/resolve-tsconfig.ts
244
+ function hasPathMappings(tsconfig) {
245
+ const paths = tsconfig.compilerOptions?.paths;
246
+ return Boolean(paths && Object.keys(paths).length > 0);
247
+ }
248
+ function resolveReferencedTsconfigPath2(refPath, fromDir, configName2 = "tsconfig.json") {
249
+ const p = refPath.endsWith(".json") ? refPath : path2.join(refPath, configName2);
250
+ return path2.resolve(fromDir, p);
251
+ }
252
+ async function resolveTsconfigForConfigBundle(configFile, cwd) {
253
+ const closest = await findClosestTsconfig(configFile, cwd);
254
+ if (!closest) return void 0;
255
+ const gtc = await import("get-tsconfig");
256
+ let rootParsed;
257
+ try {
258
+ rootParsed = gtc.parseTsconfig(closest);
259
+ } catch {
260
+ return closest;
261
+ }
262
+ const owned = await resolveSolutionTsconfigForFile(path2.resolve(configFile), closest, rootParsed, gtc);
263
+ if (hasPathMappings(owned.tsconfig)) {
264
+ return owned.tsconfigFile;
265
+ }
266
+ const refs = rootParsed.references;
267
+ if (!refs?.length) {
268
+ return owned.tsconfigFile;
269
+ }
270
+ const rootDir = path2.dirname(closest);
271
+ for (const ref of refs) {
272
+ const refPath = resolveReferencedTsconfigPath2(ref.path, rootDir);
273
+ try {
274
+ await fs2.access(refPath);
275
+ } catch {
276
+ continue;
277
+ }
278
+ try {
279
+ const childParsed = gtc.parseTsconfig(refPath);
280
+ if (hasPathMappings(childParsed)) {
281
+ return refPath;
282
+ }
283
+ } catch {
284
+ continue;
285
+ }
286
+ }
287
+ return owned.tsconfigFile;
288
+ }
289
+
290
+ // src/bundle-n-require.ts
27
291
  var ModuleInternals = Module;
28
292
  async function bundleConfigFile(file, cwd, options) {
293
+ const tsconfig = options?.tsconfig ?? await resolveTsconfigForConfigBundle(file, cwd);
29
294
  const result = await build({
30
295
  platform: "node",
31
296
  format: "cjs",
@@ -37,7 +302,8 @@ async function bundleConfigFile(file, cwd, options) {
37
302
  write: false,
38
303
  bundle: true,
39
304
  sourcemap: false,
40
- metafile: true
305
+ metafile: true,
306
+ ...tsconfig ? { tsconfig } : {}
41
307
  });
42
308
  const { text } = result.outputFiles[0];
43
309
  return {
@@ -148,8 +414,8 @@ async function bundleConfig(options) {
148
414
  }
149
415
 
150
416
  // src/get-mod-deps.ts
151
- import fs from "fs";
152
- import path from "path";
417
+ import fs3 from "fs";
418
+ import path3 from "path";
153
419
  import ts from "typescript";
154
420
 
155
421
  // src/ts-config-paths.ts
@@ -182,13 +448,13 @@ var tsResolutionOrder = ["", ".ts", ".cts", ".mts", ".tsx", ".js", ".cjs", ".mjs
182
448
  function resolveWithExtension(file, extensions) {
183
449
  for (const ext of extensions) {
184
450
  const full = `${file}${ext}`;
185
- if (fs.existsSync(full) && fs.statSync(full).isFile()) {
451
+ if (fs3.existsSync(full) && fs3.statSync(full).isFile()) {
186
452
  return full;
187
453
  }
188
454
  }
189
455
  for (const ext of extensions) {
190
456
  const full = `${file}/index${ext}`;
191
- if (fs.existsSync(full)) {
457
+ if (fs3.existsSync(full)) {
192
458
  return full;
193
459
  }
194
460
  }
@@ -202,7 +468,7 @@ function getDeps(opts, fromAlias) {
202
468
  const { filename, seen } = opts;
203
469
  const { moduleResolution: _, ...compilerOptions } = opts.compilerOptions ?? {};
204
470
  const absoluteFile = resolveWithExtension(
205
- path.resolve(opts.cwd, filename),
471
+ path3.resolve(opts.cwd, filename),
206
472
  jsExtensions.includes(opts.ext) ? jsResolutionOrder : tsResolutionOrder
207
473
  );
208
474
  if (absoluteFile === null) return;
@@ -211,7 +477,7 @@ function getDeps(opts, fromAlias) {
211
477
  }
212
478
  if (seen.size > 1 && seen.has(absoluteFile)) return;
213
479
  seen.add(absoluteFile);
214
- const contents = fs.readFileSync(absoluteFile, "utf-8");
480
+ const contents = fs3.readFileSync(absoluteFile, "utf-8");
215
481
  const fileDeps = [
216
482
  ...contents.matchAll(importRegex),
217
483
  ...contents.matchAll(importFromRegex),
@@ -221,8 +487,8 @@ function getDeps(opts, fromAlias) {
221
487
  if (!fileDeps.length) return;
222
488
  const nextOpts = {
223
489
  // Resolve new base for new imports/requires
224
- cwd: path.dirname(absoluteFile),
225
- ext: path.extname(absoluteFile),
490
+ cwd: path3.dirname(absoluteFile),
491
+ ext: path3.extname(absoluteFile),
226
492
  seen,
227
493
  baseUrl: opts.baseUrl,
228
494
  pathMappings: opts.pathMappings,
@@ -255,8 +521,8 @@ function getConfigDependencies(filePath, tsOptions = { pathMappings: [] }, compi
255
521
  deps.add(filePath);
256
522
  getDeps({
257
523
  filename: filePath,
258
- ext: path.extname(filePath),
259
- cwd: path.dirname(filePath),
524
+ ext: path3.extname(filePath),
525
+ cwd: path3.dirname(filePath),
260
526
  seen: deps,
261
527
  baseUrl: tsOptions.baseUrl,
262
528
  pathMappings: tsOptions.pathMappings ?? [],
@@ -447,11 +713,11 @@ import { isObject, walkObject } from "@pandacss/shared";
447
713
  // src/validation/validate-token-references.ts
448
714
  var validateTokenReferences = (props) => {
449
715
  const { valueAtPath, refsByPath, addError, typeByPath } = props;
450
- refsByPath.forEach((refs, path2) => {
451
- if (refs.has(path2)) {
452
- addError("tokens", `Self token reference: \`${path2}\``);
716
+ refsByPath.forEach((refs, path4) => {
717
+ if (refs.has(path4)) {
718
+ addError("tokens", `Self token reference: \`${path4}\``);
453
719
  }
454
- const stack = [path2];
720
+ const stack = [path4];
455
721
  while (stack.length > 0) {
456
722
  let currentPath = stack.pop();
457
723
  if (currentPath.includes("/")) {
@@ -460,8 +726,8 @@ var validateTokenReferences = (props) => {
460
726
  }
461
727
  const value = valueAtPath.get(currentPath);
462
728
  if (!value) {
463
- const configKey = typeByPath.get(path2);
464
- addError("tokens", `Missing token: \`${currentPath}\` used in \`theme.${configKey}.${path2}\``);
729
+ const configKey = typeByPath.get(path4);
730
+ addError("tokens", `Missing token: \`${currentPath}\` used in \`theme.${configKey}.${path4}\``);
465
731
  }
466
732
  if (isTokenReference(value) && !refsByPath.has(value)) {
467
733
  addError("tokens", `Unknown token reference: \`${currentPath}\` used in \`${value}\``);
@@ -469,10 +735,10 @@ var validateTokenReferences = (props) => {
469
735
  const deps = refsByPath.get(currentPath);
470
736
  if (!deps) continue;
471
737
  for (const transitiveDep of deps) {
472
- if (path2 === transitiveDep) {
738
+ if (path4 === transitiveDep) {
473
739
  addError(
474
740
  "tokens",
475
- `Circular token reference: \`${transitiveDep}\` -> \`${currentPath}\` -> ... -> \`${path2}\``
741
+ `Circular token reference: \`${transitiveDep}\` -> \`${currentPath}\` -> ... -> \`${path4}\``
476
742
  );
477
743
  break;
478
744
  }
@@ -496,27 +762,27 @@ var validateTokens = (options) => {
496
762
  walkObject(
497
763
  theme.tokens,
498
764
  (value, paths) => {
499
- const path2 = paths.join(SEP);
500
- tokenNames.add(path2);
501
- tokenPaths.add(path2);
502
- valueAtPath.set(path2, value);
503
- if (path2.includes("DEFAULT")) {
504
- valueAtPath.set(path2.replace(SEP + "DEFAULT", ""), value);
765
+ const path4 = paths.join(SEP);
766
+ tokenNames.add(path4);
767
+ tokenPaths.add(path4);
768
+ valueAtPath.set(path4, value);
769
+ if (path4.includes("DEFAULT")) {
770
+ valueAtPath.set(path4.replace(SEP + "DEFAULT", ""), value);
505
771
  }
506
772
  },
507
773
  {
508
774
  stop: isValidToken
509
775
  }
510
776
  );
511
- tokenPaths.forEach((path2) => {
512
- const itemValue = valueAtPath.get(path2);
513
- const formattedPath = formatPath(path2);
777
+ tokenPaths.forEach((path4) => {
778
+ const itemValue = valueAtPath.get(path4);
779
+ const formattedPath = formatPath(path4);
514
780
  typeByPath.set(formattedPath, "tokens");
515
781
  if (!isValidToken(itemValue)) {
516
782
  addError("tokens", `Token must contain 'value': \`theme.tokens.${formattedPath}\``);
517
783
  return;
518
784
  }
519
- if (path2.includes(" ")) {
785
+ if (path4.includes(" ")) {
520
786
  addError("tokens", `Token key must not contain spaces: \`theme.tokens.${formattedPath}\``);
521
787
  return;
522
788
  }
@@ -536,17 +802,17 @@ var validateTokens = (options) => {
536
802
  walkObject(
537
803
  theme.semanticTokens,
538
804
  (value, paths) => {
539
- const path2 = paths.join(SEP);
540
- semanticTokenNames.add(path2);
541
- valueAtPath.set(path2, value);
542
- tokenPaths.add(path2);
543
- if (path2.includes("DEFAULT")) {
544
- valueAtPath.set(path2.replace(SEP + "DEFAULT", ""), value);
805
+ const path4 = paths.join(SEP);
806
+ semanticTokenNames.add(path4);
807
+ valueAtPath.set(path4, value);
808
+ tokenPaths.add(path4);
809
+ if (path4.includes("DEFAULT")) {
810
+ valueAtPath.set(path4.replace(SEP + "DEFAULT", ""), value);
545
811
  }
546
812
  if (!isValidToken(value)) return;
547
813
  walkObject(value, (itemValue, paths2) => {
548
814
  const valuePath = paths2.join(SEP);
549
- const formattedPath = formatPath(path2);
815
+ const formattedPath = formatPath(path4);
550
816
  typeByPath.set(formattedPath, "semanticTokens");
551
817
  const fullPath = formattedPath + "." + paths2.join(SEP);
552
818
  if (valuePath.includes("value" + SEP + "value")) {
@@ -569,14 +835,14 @@ var validateTokens = (options) => {
569
835
  stop: isValidToken
570
836
  }
571
837
  );
572
- tokenPaths.forEach((path2) => {
573
- const formattedPath = formatPath(path2);
574
- const value = valueAtPath.get(path2);
575
- if (path2.includes(" ")) {
838
+ tokenPaths.forEach((path4) => {
839
+ const formattedPath = formatPath(path4);
840
+ const value = valueAtPath.get(path4);
841
+ if (path4.includes(" ")) {
576
842
  addError("tokens", `Token key must not contain spaces: \`theme.tokens.${formattedPath}\``);
577
843
  return;
578
844
  }
579
- if (!isObject(value) && !path2.includes("value")) {
845
+ if (!isObject(value) && !path4.includes("value")) {
580
846
  addError("tokens", `Token must contain 'value': \`theme.semanticTokens.${formattedPath}\``);
581
847
  }
582
848
  });
@@ -683,11 +949,17 @@ export {
683
949
  bundleConfig,
684
950
  convertTsPathsToRegexes,
685
951
  diffConfigs,
952
+ findClosestTsconfig,
686
953
  findConfig,
687
954
  getConfigDependencies,
688
955
  getResolvedConfig,
956
+ isSourceFileIncludedInTsconfig,
689
957
  loadConfig,
690
958
  mergeConfigs,
691
959
  mergeHooks,
692
- resolveConfig
960
+ resolveBaseUrlForCompilerOptions,
961
+ resolveConfig,
962
+ resolveDirectTsconfigJson,
963
+ resolveSolutionTsconfigForFile,
964
+ resolveTsconfigForConfigBundle
693
965
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/config",
3
- "version": "1.11.4",
3
+ "version": "1.12.0",
4
4
  "description": "Find and load panda config",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -71,13 +71,14 @@
71
71
  "dependencies": {
72
72
  "esbuild": "0.25.12",
73
73
  "escalade": "3.2.0",
74
+ "get-tsconfig": "^4.13.0",
74
75
  "microdiff": "1.5.0",
75
76
  "typescript": "6.0.2",
76
- "@pandacss/logger": "1.11.4",
77
- "@pandacss/preset-base": "1.11.4",
78
- "@pandacss/types": "1.11.4",
79
- "@pandacss/preset-panda": "1.11.4",
80
- "@pandacss/shared": "1.11.4"
77
+ "@pandacss/logger": "1.12.0",
78
+ "@pandacss/preset-base": "1.12.0",
79
+ "@pandacss/preset-panda": "1.12.0",
80
+ "@pandacss/shared": "1.12.0",
81
+ "@pandacss/types": "1.12.0"
81
82
  },
82
83
  "devDependencies": {
83
84
  "pkg-types": "2.3.0"