@pandacss/config 0.7.0 → 0.9.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.
@@ -0,0 +1,21 @@
1
+ // src/resolve-ts-path-pattern.ts
2
+ var resolveTsPathPattern = (pathMappings, moduleSpecifier) => {
3
+ for (const mapping of pathMappings) {
4
+ const match = moduleSpecifier.match(mapping.pattern);
5
+ if (!match) {
6
+ continue;
7
+ }
8
+ for (const pathTemplate of mapping.paths) {
9
+ let starCount = 0;
10
+ const mappedId = pathTemplate.replace(/\*/g, () => {
11
+ const matchIndex = Math.min(++starCount, match.length - 1);
12
+ return match[matchIndex];
13
+ });
14
+ return mappedId;
15
+ }
16
+ }
17
+ };
18
+
19
+ export {
20
+ resolveTsPathPattern
21
+ };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,8 @@
1
+ import { P as PathMapping } from './ts-config-paths-d717c9e2.js';
2
+ export { c as convertTsPathsToRegexes } from './ts-config-paths-d717c9e2.js';
1
3
  import * as _pandacss_types from '@pandacss/types';
2
- import { Config, LoadConfigResult } from '@pandacss/types';
4
+ import { ConfigTsOptions, Config, LoadConfigResult } from '@pandacss/types';
5
+ import { TSConfig } from 'pkg-types';
3
6
  export { mergeConfigs } from './merge-config.mjs';
4
7
 
5
8
  declare function findConfigFile({ cwd, file }: {
@@ -7,15 +10,6 @@ declare function findConfigFile({ cwd, file }: {
7
10
  file?: string;
8
11
  }): string | void;
9
12
 
10
- type PathMapping = {
11
- pattern: RegExp;
12
- paths: string[];
13
- };
14
- /**
15
- * @see https://github.com/aleclarson/vite-tsconfig-paths/blob/e8f0acf7adfcfbf77edbe937f64b4e5d39557ad0/src/mappings.ts
16
- */
17
- declare function convertTsPathsToRegexes(paths: Record<string, string[]>, baseUrl: string): PathMapping[];
18
-
19
13
  type GetDepsOptions = {
20
14
  filename: string;
21
15
  ext: string;
@@ -24,12 +18,9 @@ type GetDepsOptions = {
24
18
  baseUrl: string | undefined;
25
19
  pathMappings: PathMapping[];
26
20
  foundModuleAliases: Map<string, string>;
21
+ compilerOptions?: TSConfig['compilerOptions'];
27
22
  };
28
- type GetConfigDependenciesTsOptions = {
29
- baseUrl?: string | undefined;
30
- pathMappings: PathMapping[];
31
- };
32
- declare function getConfigDependencies(filePath: string, tsOptions?: GetConfigDependenciesTsOptions): {
23
+ declare function getConfigDependencies(filePath: string, tsOptions?: ConfigTsOptions, compilerOptions?: TSConfig['compilerOptions']): {
33
24
  deps: Set<string>;
34
25
  aliases: Map<string, string>;
35
26
  };
@@ -55,4 +46,4 @@ declare function bundleConfigFile(options: ConfigFileOptions): Promise<{
55
46
  dependencies: string[];
56
47
  }>;
57
48
 
58
- export { GetConfigDependenciesTsOptions, GetDepsOptions, bundleConfigFile, convertTsPathsToRegexes, findConfigFile, getConfigDependencies, getResolvedConfig, loadConfigFile, resolveConfigFile };
49
+ export { GetDepsOptions, bundleConfigFile, findConfigFile, getConfigDependencies, getResolvedConfig, loadConfigFile, resolveConfigFile };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
+ import { P as PathMapping } from './ts-config-paths-d717c9e2.js';
2
+ export { c as convertTsPathsToRegexes } from './ts-config-paths-d717c9e2.js';
1
3
  import * as _pandacss_types from '@pandacss/types';
2
- import { Config, LoadConfigResult } from '@pandacss/types';
4
+ import { ConfigTsOptions, Config, LoadConfigResult } from '@pandacss/types';
5
+ import { TSConfig } from 'pkg-types';
3
6
  export { mergeConfigs } from './merge-config.js';
4
7
 
5
8
  declare function findConfigFile({ cwd, file }: {
@@ -7,15 +10,6 @@ declare function findConfigFile({ cwd, file }: {
7
10
  file?: string;
8
11
  }): string | void;
9
12
 
10
- type PathMapping = {
11
- pattern: RegExp;
12
- paths: string[];
13
- };
14
- /**
15
- * @see https://github.com/aleclarson/vite-tsconfig-paths/blob/e8f0acf7adfcfbf77edbe937f64b4e5d39557ad0/src/mappings.ts
16
- */
17
- declare function convertTsPathsToRegexes(paths: Record<string, string[]>, baseUrl: string): PathMapping[];
18
-
19
13
  type GetDepsOptions = {
20
14
  filename: string;
21
15
  ext: string;
@@ -24,12 +18,9 @@ type GetDepsOptions = {
24
18
  baseUrl: string | undefined;
25
19
  pathMappings: PathMapping[];
26
20
  foundModuleAliases: Map<string, string>;
21
+ compilerOptions?: TSConfig['compilerOptions'];
27
22
  };
28
- type GetConfigDependenciesTsOptions = {
29
- baseUrl?: string | undefined;
30
- pathMappings: PathMapping[];
31
- };
32
- declare function getConfigDependencies(filePath: string, tsOptions?: GetConfigDependenciesTsOptions): {
23
+ declare function getConfigDependencies(filePath: string, tsOptions?: ConfigTsOptions, compilerOptions?: TSConfig['compilerOptions']): {
33
24
  deps: Set<string>;
34
25
  aliases: Map<string, string>;
35
26
  };
@@ -55,4 +46,4 @@ declare function bundleConfigFile(options: ConfigFileOptions): Promise<{
55
46
  dependencies: string[];
56
47
  }>;
57
48
 
58
- export { GetConfigDependenciesTsOptions, GetDepsOptions, bundleConfigFile, convertTsPathsToRegexes, findConfigFile, getConfigDependencies, getResolvedConfig, loadConfigFile, resolveConfigFile };
49
+ export { GetDepsOptions, bundleConfigFile, findConfigFile, getConfigDependencies, getResolvedConfig, loadConfigFile, resolveConfigFile };
package/dist/index.js CHANGED
@@ -74,6 +74,15 @@ function convertTsPathsToRegexes(paths, baseUrl) {
74
74
  }
75
75
  return resolved;
76
76
  }
77
+ function getPrefixLength(pattern) {
78
+ const prefixLength = pattern.indexOf("*");
79
+ return pattern.substr(0, prefixLength).length;
80
+ }
81
+ function escapeStringRegexp(string) {
82
+ return string.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/-/g, "\\x2d");
83
+ }
84
+
85
+ // src/resolve-ts-path-pattern.ts
77
86
  var resolveTsPathPattern = (pathMappings, moduleSpecifier) => {
78
87
  for (const mapping of pathMappings) {
79
88
  const match = moduleSpecifier.match(mapping.pattern);
@@ -90,13 +99,6 @@ var resolveTsPathPattern = (pathMappings, moduleSpecifier) => {
90
99
  }
91
100
  }
92
101
  };
93
- function getPrefixLength(pattern) {
94
- const prefixLength = pattern.indexOf("*");
95
- return pattern.substr(0, prefixLength).length;
96
- }
97
- function escapeStringRegexp(string) {
98
- return string.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/-/g, "\\x2d");
99
- }
100
102
 
101
103
  // src/get-mod-deps.ts
102
104
  var import_typescript = __toESM(require("typescript"));
@@ -124,6 +126,7 @@ var requireRegex = /require\(['"`](.+)['"`]\)/gi;
124
126
  var exportRegex = /export[\s\S]*from[\s\S]*?['"](.{3,}?)['"]/gi;
125
127
  function getDeps(opts, fromAlias) {
126
128
  const { filename, seen } = opts;
129
+ const { moduleResolution: _, ...compilerOptions } = opts.compilerOptions ?? {};
127
130
  const absoluteFile = resolveWithExtension(
128
131
  import_path3.default.resolve(opts.cwd, filename),
129
132
  jsExtensions.includes(opts.ext) ? jsResolutionOrder : tsResolutionOrder
@@ -160,20 +163,23 @@ function getDeps(opts, fromAlias) {
160
163
  getDeps(Object.assign({}, nextOpts, { filename: mod }));
161
164
  return;
162
165
  }
163
- const found = import_typescript.default.resolveModuleName(mod, absoluteFile, {}, import_typescript.default.sys).resolvedModule;
164
- if (found && found.extension === ".ts") {
165
- getDeps(Object.assign({}, nextOpts, { filename: found.resolvedFileName }));
166
- return;
166
+ try {
167
+ const found = import_typescript.default.resolveModuleName(mod, absoluteFile, compilerOptions, import_typescript.default.sys).resolvedModule;
168
+ if (found && found.extension === ".ts") {
169
+ getDeps(Object.assign({}, nextOpts, { filename: found.resolvedFileName }));
170
+ return;
171
+ }
172
+ if (!opts.pathMappings)
173
+ return;
174
+ const filename2 = resolveTsPathPattern(opts.pathMappings, mod);
175
+ if (!filename2)
176
+ return;
177
+ getDeps(Object.assign({}, nextOpts, { filename: filename2 }), mod);
178
+ } catch (err) {
167
179
  }
168
- if (!opts.pathMappings)
169
- return;
170
- const filename2 = resolveTsPathPattern(opts.pathMappings, mod);
171
- if (!filename2)
172
- return;
173
- getDeps(Object.assign({}, nextOpts, { filename: filename2 }), mod);
174
180
  });
175
181
  }
176
- function getConfigDependencies(filePath, tsOptions = { pathMappings: [] }) {
182
+ function getConfigDependencies(filePath, tsOptions = { pathMappings: [] }, compilerOptions) {
177
183
  if (filePath === null)
178
184
  return { deps: /* @__PURE__ */ new Set(), aliases: /* @__PURE__ */ new Map() };
179
185
  const foundModuleAliases = /* @__PURE__ */ new Map();
@@ -186,7 +192,8 @@ function getConfigDependencies(filePath, tsOptions = { pathMappings: [] }) {
186
192
  seen: deps,
187
193
  baseUrl: tsOptions.baseUrl,
188
194
  pathMappings: tsOptions.pathMappings ?? [],
189
- foundModuleAliases
195
+ foundModuleAliases,
196
+ compilerOptions
190
197
  });
191
198
  return { deps, aliases: foundModuleAliases };
192
199
  }
package/dist/index.mjs CHANGED
@@ -1,6 +1,9 @@
1
1
  import {
2
2
  mergeConfigs
3
3
  } from "./chunk-5FP5NJ64.mjs";
4
+ import {
5
+ resolveTsPathPattern
6
+ } from "./chunk-KG6DKI2S.mjs";
4
7
 
5
8
  // src/find-config.ts
6
9
  import findUp from "escalade/sync";
@@ -35,22 +38,6 @@ function convertTsPathsToRegexes(paths, baseUrl) {
35
38
  }
36
39
  return resolved;
37
40
  }
38
- var resolveTsPathPattern = (pathMappings, moduleSpecifier) => {
39
- for (const mapping of pathMappings) {
40
- const match = moduleSpecifier.match(mapping.pattern);
41
- if (!match) {
42
- continue;
43
- }
44
- for (const pathTemplate of mapping.paths) {
45
- let starCount = 0;
46
- const mappedId = pathTemplate.replace(/\*/g, () => {
47
- const matchIndex = Math.min(++starCount, match.length - 1);
48
- return match[matchIndex];
49
- });
50
- return mappedId;
51
- }
52
- }
53
- };
54
41
  function getPrefixLength(pattern) {
55
42
  const prefixLength = pattern.indexOf("*");
56
43
  return pattern.substr(0, prefixLength).length;
@@ -85,6 +72,7 @@ var requireRegex = /require\(['"`](.+)['"`]\)/gi;
85
72
  var exportRegex = /export[\s\S]*from[\s\S]*?['"](.{3,}?)['"]/gi;
86
73
  function getDeps(opts, fromAlias) {
87
74
  const { filename, seen } = opts;
75
+ const { moduleResolution: _, ...compilerOptions } = opts.compilerOptions ?? {};
88
76
  const absoluteFile = resolveWithExtension(
89
77
  path.resolve(opts.cwd, filename),
90
78
  jsExtensions.includes(opts.ext) ? jsResolutionOrder : tsResolutionOrder
@@ -121,20 +109,23 @@ function getDeps(opts, fromAlias) {
121
109
  getDeps(Object.assign({}, nextOpts, { filename: mod }));
122
110
  return;
123
111
  }
124
- const found = ts.resolveModuleName(mod, absoluteFile, {}, ts.sys).resolvedModule;
125
- if (found && found.extension === ".ts") {
126
- getDeps(Object.assign({}, nextOpts, { filename: found.resolvedFileName }));
127
- return;
112
+ try {
113
+ const found = ts.resolveModuleName(mod, absoluteFile, compilerOptions, ts.sys).resolvedModule;
114
+ if (found && found.extension === ".ts") {
115
+ getDeps(Object.assign({}, nextOpts, { filename: found.resolvedFileName }));
116
+ return;
117
+ }
118
+ if (!opts.pathMappings)
119
+ return;
120
+ const filename2 = resolveTsPathPattern(opts.pathMappings, mod);
121
+ if (!filename2)
122
+ return;
123
+ getDeps(Object.assign({}, nextOpts, { filename: filename2 }), mod);
124
+ } catch (err) {
128
125
  }
129
- if (!opts.pathMappings)
130
- return;
131
- const filename2 = resolveTsPathPattern(opts.pathMappings, mod);
132
- if (!filename2)
133
- return;
134
- getDeps(Object.assign({}, nextOpts, { filename: filename2 }), mod);
135
126
  });
136
127
  }
137
- function getConfigDependencies(filePath, tsOptions = { pathMappings: [] }) {
128
+ function getConfigDependencies(filePath, tsOptions = { pathMappings: [] }, compilerOptions) {
138
129
  if (filePath === null)
139
130
  return { deps: /* @__PURE__ */ new Set(), aliases: /* @__PURE__ */ new Map() };
140
131
  const foundModuleAliases = /* @__PURE__ */ new Map();
@@ -147,7 +138,8 @@ function getConfigDependencies(filePath, tsOptions = { pathMappings: [] }) {
147
138
  seen: deps,
148
139
  baseUrl: tsOptions.baseUrl,
149
140
  pathMappings: tsOptions.pathMappings ?? [],
150
- foundModuleAliases
141
+ foundModuleAliases,
142
+ compilerOptions
151
143
  });
152
144
  return { deps, aliases: foundModuleAliases };
153
145
  }
@@ -0,0 +1,8 @@
1
+ import { P as PathMapping } from './ts-config-paths-d717c9e2.js';
2
+
3
+ /**
4
+ * @see https://github.com/aleclarson/vite-tsconfig-paths/blob/e8f0acf7adfcfbf77edbe937f64b4e5d39557ad0/src/index.ts#LL231C57-L231C57
5
+ */
6
+ declare const resolveTsPathPattern: (pathMappings: PathMapping[], moduleSpecifier: string) => string | undefined;
7
+
8
+ export { resolveTsPathPattern };
@@ -0,0 +1,8 @@
1
+ import { P as PathMapping } from './ts-config-paths-d717c9e2.js';
2
+
3
+ /**
4
+ * @see https://github.com/aleclarson/vite-tsconfig-paths/blob/e8f0acf7adfcfbf77edbe937f64b4e5d39557ad0/src/index.ts#LL231C57-L231C57
5
+ */
6
+ declare const resolveTsPathPattern: (pathMappings: PathMapping[], moduleSpecifier: string) => string | undefined;
7
+
8
+ export { resolveTsPathPattern };
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/resolve-ts-path-pattern.ts
21
+ var resolve_ts_path_pattern_exports = {};
22
+ __export(resolve_ts_path_pattern_exports, {
23
+ resolveTsPathPattern: () => resolveTsPathPattern
24
+ });
25
+ module.exports = __toCommonJS(resolve_ts_path_pattern_exports);
26
+ var resolveTsPathPattern = (pathMappings, moduleSpecifier) => {
27
+ for (const mapping of pathMappings) {
28
+ const match = moduleSpecifier.match(mapping.pattern);
29
+ if (!match) {
30
+ continue;
31
+ }
32
+ for (const pathTemplate of mapping.paths) {
33
+ let starCount = 0;
34
+ const mappedId = pathTemplate.replace(/\*/g, () => {
35
+ const matchIndex = Math.min(++starCount, match.length - 1);
36
+ return match[matchIndex];
37
+ });
38
+ return mappedId;
39
+ }
40
+ }
41
+ };
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ resolveTsPathPattern
45
+ });
@@ -0,0 +1,6 @@
1
+ import {
2
+ resolveTsPathPattern
3
+ } from "./chunk-KG6DKI2S.mjs";
4
+ export {
5
+ resolveTsPathPattern
6
+ };
@@ -0,0 +1,10 @@
1
+ type PathMapping = {
2
+ pattern: RegExp;
3
+ paths: string[];
4
+ };
5
+ /**
6
+ * @see https://github.com/aleclarson/vite-tsconfig-paths/blob/e8f0acf7adfcfbf77edbe937f64b4e5d39557ad0/src/mappings.ts
7
+ */
8
+ declare function convertTsPathsToRegexes(paths: Record<string, string[]>, baseUrl: string): PathMapping[];
9
+
10
+ export { PathMapping as P, convertTsPathsToRegexes as c };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/config",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Find and load panda config",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -21,6 +21,11 @@
21
21
  "require": "./dist/merge-config.js",
22
22
  "import": "./dist/merge-config.mjs"
23
23
  },
24
+ "./ts-path": {
25
+ "types": "./dist/resolve-ts-path-pattern.d.ts",
26
+ "require": "./dist/resolve-ts-path-pattern.js",
27
+ "import": "./dist/resolve-ts-path-pattern.mjs"
28
+ },
24
29
  "./package.json": "./package.json"
25
30
  },
26
31
  "files": [
@@ -32,18 +37,18 @@
32
37
  "jiti": "^1.19.1",
33
38
  "merge-anything": "^5.1.7",
34
39
  "typescript": "^5.1.6",
35
- "@pandacss/error": "0.7.0",
36
- "@pandacss/logger": "0.7.0",
37
- "@pandacss/preset-base": "0.7.0",
38
- "@pandacss/preset-panda": "0.7.0",
39
- "@pandacss/types": "0.7.0"
40
+ "@pandacss/error": "0.9.0",
41
+ "@pandacss/logger": "0.9.0",
42
+ "@pandacss/preset-base": "0.9.0",
43
+ "@pandacss/preset-panda": "0.9.0",
44
+ "@pandacss/types": "0.9.0"
40
45
  },
41
46
  "devDependencies": {
42
47
  "pkg-types": "1.0.3"
43
48
  },
44
49
  "scripts": {
45
- "build": "pnpm tsup src/index.ts src/merge-config.ts --format=esm,cjs --shims --dts",
46
- "build-fast": "pnpm tsup src/index.ts src/merge-config.ts --format=esm,cjs --shims --no-dts",
50
+ "build": "pnpm tsup src/index.ts src/merge-config.ts src/resolve-ts-path-pattern.ts --format=esm,cjs --shims --dts",
51
+ "build-fast": "pnpm tsup src/index.ts src/merge-config.ts src/resolve-ts-path-pattern.ts --format=esm,cjs --shims --no-dts",
47
52
  "dev": "pnpm build-fast --watch"
48
53
  }
49
54
  }