@pandacss/config 0.6.0 → 0.8.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,15 +99,9 @@ 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
104
+ var import_typescript = __toESM(require("typescript"));
102
105
  var jsExtensions = [".js", ".cjs", ".mjs"];
103
106
  var jsResolutionOrder = ["", ".js", ".cjs", ".mjs", ".ts", ".cts", ".mts", ".jsx", ".tsx"];
104
107
  var tsResolutionOrder = ["", ".ts", ".cts", ".mts", ".tsx", ".js", ".cjs", ".mjs", ".jsx"];
@@ -123,6 +126,7 @@ var requireRegex = /require\(['"`](.+)['"`]\)/gi;
123
126
  var exportRegex = /export[\s\S]*from[\s\S]*?['"](.{3,}?)['"]/gi;
124
127
  function getDeps(opts, fromAlias) {
125
128
  const { filename, seen } = opts;
129
+ const { moduleResolution: _, ...compilerOptions } = opts.compilerOptions ?? {};
126
130
  const absoluteFile = resolveWithExtension(
127
131
  import_path3.default.resolve(opts.cwd, filename),
128
132
  jsExtensions.includes(opts.ext) ? jsResolutionOrder : tsResolutionOrder
@@ -159,15 +163,23 @@ function getDeps(opts, fromAlias) {
159
163
  getDeps(Object.assign({}, nextOpts, { filename: mod }));
160
164
  return;
161
165
  }
162
- if (!opts.pathMappings)
163
- return;
164
- const filename2 = resolveTsPathPattern(opts.pathMappings, mod);
165
- if (!filename2)
166
- return;
167
- getDeps(Object.assign({}, nextOpts, { filename: filename2 }), mod);
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) {
179
+ }
168
180
  });
169
181
  }
170
- function getConfigDependencies(filePath, tsOptions = { pathMappings: [] }) {
182
+ function getConfigDependencies(filePath, tsOptions = { pathMappings: [] }, compilerOptions) {
171
183
  if (filePath === null)
172
184
  return { deps: /* @__PURE__ */ new Set(), aliases: /* @__PURE__ */ new Map() };
173
185
  const foundModuleAliases = /* @__PURE__ */ new Map();
@@ -180,7 +192,8 @@ function getConfigDependencies(filePath, tsOptions = { pathMappings: [] }) {
180
192
  seen: deps,
181
193
  baseUrl: tsOptions.baseUrl,
182
194
  pathMappings: tsOptions.pathMappings ?? [],
183
- foundModuleAliases
195
+ foundModuleAliases,
196
+ compilerOptions
184
197
  });
185
198
  return { deps, aliases: foundModuleAliases };
186
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;
@@ -60,6 +47,7 @@ function escapeStringRegexp(string) {
60
47
  }
61
48
 
62
49
  // src/get-mod-deps.ts
50
+ import ts from "typescript";
63
51
  var jsExtensions = [".js", ".cjs", ".mjs"];
64
52
  var jsResolutionOrder = ["", ".js", ".cjs", ".mjs", ".ts", ".cts", ".mts", ".jsx", ".tsx"];
65
53
  var tsResolutionOrder = ["", ".ts", ".cts", ".mts", ".tsx", ".js", ".cjs", ".mjs", ".jsx"];
@@ -84,6 +72,7 @@ var requireRegex = /require\(['"`](.+)['"`]\)/gi;
84
72
  var exportRegex = /export[\s\S]*from[\s\S]*?['"](.{3,}?)['"]/gi;
85
73
  function getDeps(opts, fromAlias) {
86
74
  const { filename, seen } = opts;
75
+ const { moduleResolution: _, ...compilerOptions } = opts.compilerOptions ?? {};
87
76
  const absoluteFile = resolveWithExtension(
88
77
  path.resolve(opts.cwd, filename),
89
78
  jsExtensions.includes(opts.ext) ? jsResolutionOrder : tsResolutionOrder
@@ -120,15 +109,23 @@ function getDeps(opts, fromAlias) {
120
109
  getDeps(Object.assign({}, nextOpts, { filename: mod }));
121
110
  return;
122
111
  }
123
- if (!opts.pathMappings)
124
- return;
125
- const filename2 = resolveTsPathPattern(opts.pathMappings, mod);
126
- if (!filename2)
127
- return;
128
- getDeps(Object.assign({}, nextOpts, { filename: filename2 }), mod);
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) {
125
+ }
129
126
  });
130
127
  }
131
- function getConfigDependencies(filePath, tsOptions = { pathMappings: [] }) {
128
+ function getConfigDependencies(filePath, tsOptions = { pathMappings: [] }, compilerOptions) {
132
129
  if (filePath === null)
133
130
  return { deps: /* @__PURE__ */ new Set(), aliases: /* @__PURE__ */ new Map() };
134
131
  const foundModuleAliases = /* @__PURE__ */ new Map();
@@ -141,7 +138,8 @@ function getConfigDependencies(filePath, tsOptions = { pathMappings: [] }) {
141
138
  seen: deps,
142
139
  baseUrl: tsOptions.baseUrl,
143
140
  pathMappings: tsOptions.pathMappings ?? [],
144
- foundModuleAliases
141
+ foundModuleAliases,
142
+ compilerOptions
145
143
  });
146
144
  return { deps, aliases: foundModuleAliases };
147
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.6.0",
3
+ "version": "0.8.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": [
@@ -29,21 +34,21 @@
29
34
  "dependencies": {
30
35
  "bundle-n-require": "^1.0.1",
31
36
  "escalade": "3.1.1",
32
- "jiti": "^1.18.2",
37
+ "jiti": "^1.19.1",
33
38
  "merge-anything": "^5.1.7",
34
- "tsconfck": "^2.1.1",
35
- "@pandacss/error": "0.6.0",
36
- "@pandacss/logger": "0.6.0",
37
- "@pandacss/preset-base": "0.6.0",
38
- "@pandacss/preset-panda": "0.6.0",
39
- "@pandacss/types": "0.6.0"
39
+ "typescript": "^5.1.6",
40
+ "@pandacss/error": "0.8.0",
41
+ "@pandacss/logger": "0.8.0",
42
+ "@pandacss/preset-base": "0.8.0",
43
+ "@pandacss/preset-panda": "0.8.0",
44
+ "@pandacss/types": "0.8.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
  }