@pandacss/config 0.0.0-dev-20230702075205 → 0.0.0-dev-20230702194035

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
@@ -10,6 +10,10 @@ type PathMapping = {
10
10
  pattern: RegExp;
11
11
  paths: string[];
12
12
  };
13
+ /**
14
+ * @see https://github.com/aleclarson/vite-tsconfig-paths/blob/e8f0acf7adfcfbf77edbe937f64b4e5d39557ad0/src/mappings.ts
15
+ */
16
+ declare function convertTsPathsToRegexes(paths: Record<string, string[]>, baseUrl: string): PathMapping[];
13
17
 
14
18
  type GetDepsOptions = {
15
19
  filename: string;
@@ -54,4 +58,4 @@ declare function mergeConfigs(configs: ExtendableConfig[]): any;
54
58
  */
55
59
  declare function getResolvedConfig(config: ExtendableConfig, cwd: string): Promise<Config>;
56
60
 
57
- export { GetConfigDependenciesTsOptions, GetDepsOptions, bundleConfigFile, findConfigFile, getConfigDependencies, getResolvedConfig, loadConfigFile, mergeConfigs, resolveConfigFile };
61
+ export { GetConfigDependenciesTsOptions, GetDepsOptions, bundleConfigFile, convertTsPathsToRegexes, findConfigFile, getConfigDependencies, getResolvedConfig, loadConfigFile, mergeConfigs, resolveConfigFile };
package/dist/index.d.ts CHANGED
@@ -10,6 +10,10 @@ type PathMapping = {
10
10
  pattern: RegExp;
11
11
  paths: string[];
12
12
  };
13
+ /**
14
+ * @see https://github.com/aleclarson/vite-tsconfig-paths/blob/e8f0acf7adfcfbf77edbe937f64b4e5d39557ad0/src/mappings.ts
15
+ */
16
+ declare function convertTsPathsToRegexes(paths: Record<string, string[]>, baseUrl: string): PathMapping[];
13
17
 
14
18
  type GetDepsOptions = {
15
19
  filename: string;
@@ -54,4 +58,4 @@ declare function mergeConfigs(configs: ExtendableConfig[]): any;
54
58
  */
55
59
  declare function getResolvedConfig(config: ExtendableConfig, cwd: string): Promise<Config>;
56
60
 
57
- export { GetConfigDependenciesTsOptions, GetDepsOptions, bundleConfigFile, findConfigFile, getConfigDependencies, getResolvedConfig, loadConfigFile, mergeConfigs, resolveConfigFile };
61
+ export { GetConfigDependenciesTsOptions, GetDepsOptions, bundleConfigFile, convertTsPathsToRegexes, findConfigFile, getConfigDependencies, getResolvedConfig, loadConfigFile, mergeConfigs, resolveConfigFile };
package/dist/index.js CHANGED
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
33
  bundleConfigFile: () => bundleConfigFile,
34
+ convertTsPathsToRegexes: () => convertTsPathsToRegexes,
34
35
  findConfigFile: () => findConfigFile,
35
36
  getConfigDependencies: () => getConfigDependencies,
36
37
  getResolvedConfig: () => getResolvedConfig,
@@ -56,9 +57,23 @@ function findConfigFile({ cwd, file }) {
56
57
 
57
58
  // src/get-mod-deps.ts
58
59
  var import_fs = __toESM(require("fs"));
59
- var import_path2 = __toESM(require("path"));
60
+ var import_path3 = __toESM(require("path"));
60
61
 
61
62
  // src/ts-config-paths-mappings.ts
63
+ var import_path2 = require("path");
64
+ function convertTsPathsToRegexes(paths, baseUrl) {
65
+ const sortedPatterns = Object.keys(paths).sort((a, b) => getPrefixLength(b) - getPrefixLength(a));
66
+ const resolved = [];
67
+ for (let pattern of sortedPatterns) {
68
+ const relativePaths = paths[pattern];
69
+ pattern = escapeStringRegexp(pattern).replace(/\*/g, "(.+)");
70
+ resolved.push({
71
+ pattern: new RegExp("^" + pattern + "$"),
72
+ paths: relativePaths.map((relativePath) => (0, import_path2.resolve)(baseUrl, relativePath))
73
+ });
74
+ }
75
+ return resolved;
76
+ }
62
77
  var resolveTsPathPattern = (pathMappings, moduleSpecifier) => {
63
78
  for (const mapping of pathMappings) {
64
79
  const match = moduleSpecifier.match(mapping.pattern);
@@ -75,6 +90,13 @@ var resolveTsPathPattern = (pathMappings, moduleSpecifier) => {
75
90
  }
76
91
  }
77
92
  };
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
+ }
78
100
 
79
101
  // src/get-mod-deps.ts
80
102
  var jsExtensions = [".js", ".cjs", ".mjs"];
@@ -102,7 +124,7 @@ var exportRegex = /export[\s\S]*from[\s\S]*?['"](.{3,}?)['"]/gi;
102
124
  function getDeps(opts, fromAlias) {
103
125
  const { filename, seen } = opts;
104
126
  const absoluteFile = resolveWithExtension(
105
- import_path2.default.resolve(opts.cwd, filename),
127
+ import_path3.default.resolve(opts.cwd, filename),
106
128
  jsExtensions.includes(opts.ext) ? jsResolutionOrder : tsResolutionOrder
107
129
  );
108
130
  if (absoluteFile === null)
@@ -110,7 +132,7 @@ function getDeps(opts, fromAlias) {
110
132
  if (fromAlias) {
111
133
  opts.foundModuleAliases.set(fromAlias, absoluteFile);
112
134
  }
113
- if (seen.has(absoluteFile))
135
+ if (seen.size > 1 && seen.has(absoluteFile))
114
136
  return;
115
137
  seen.add(absoluteFile);
116
138
  const contents = import_fs.default.readFileSync(absoluteFile, "utf-8");
@@ -124,8 +146,8 @@ function getDeps(opts, fromAlias) {
124
146
  return;
125
147
  const nextOpts = {
126
148
  // Resolve new base for new imports/requires
127
- cwd: import_path2.default.dirname(absoluteFile),
128
- ext: import_path2.default.extname(absoluteFile),
149
+ cwd: import_path3.default.dirname(absoluteFile),
150
+ ext: import_path3.default.extname(absoluteFile),
129
151
  seen,
130
152
  baseUrl: opts.baseUrl,
131
153
  pathMappings: opts.pathMappings,
@@ -153,8 +175,8 @@ function getConfigDependencies(filePath, tsOptions = { pathMappings: [] }) {
153
175
  deps.add(filePath);
154
176
  getDeps({
155
177
  filename: filePath,
156
- ext: import_path2.default.extname(filePath),
157
- cwd: import_path2.default.dirname(filePath),
178
+ ext: import_path3.default.extname(filePath),
179
+ cwd: import_path3.default.dirname(filePath),
158
180
  seen: deps,
159
181
  baseUrl: tsOptions.baseUrl,
160
182
  pathMappings: tsOptions.pathMappings ?? [],
@@ -334,6 +356,7 @@ async function bundleConfigFile(options) {
334
356
  // Annotate the CommonJS export names for ESM import in node:
335
357
  0 && (module.exports = {
336
358
  bundleConfigFile,
359
+ convertTsPathsToRegexes,
337
360
  findConfigFile,
338
361
  getConfigDependencies,
339
362
  getResolvedConfig,
package/dist/index.mjs CHANGED
@@ -17,6 +17,20 @@ import fs from "fs";
17
17
  import path from "path";
18
18
 
19
19
  // src/ts-config-paths-mappings.ts
20
+ import { resolve as resolve2 } from "path";
21
+ function convertTsPathsToRegexes(paths, baseUrl) {
22
+ const sortedPatterns = Object.keys(paths).sort((a, b) => getPrefixLength(b) - getPrefixLength(a));
23
+ const resolved = [];
24
+ for (let pattern of sortedPatterns) {
25
+ const relativePaths = paths[pattern];
26
+ pattern = escapeStringRegexp(pattern).replace(/\*/g, "(.+)");
27
+ resolved.push({
28
+ pattern: new RegExp("^" + pattern + "$"),
29
+ paths: relativePaths.map((relativePath) => resolve2(baseUrl, relativePath))
30
+ });
31
+ }
32
+ return resolved;
33
+ }
20
34
  var resolveTsPathPattern = (pathMappings, moduleSpecifier) => {
21
35
  for (const mapping of pathMappings) {
22
36
  const match = moduleSpecifier.match(mapping.pattern);
@@ -33,6 +47,13 @@ var resolveTsPathPattern = (pathMappings, moduleSpecifier) => {
33
47
  }
34
48
  }
35
49
  };
50
+ function getPrefixLength(pattern) {
51
+ const prefixLength = pattern.indexOf("*");
52
+ return pattern.substr(0, prefixLength).length;
53
+ }
54
+ function escapeStringRegexp(string) {
55
+ return string.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/-/g, "\\x2d");
56
+ }
36
57
 
37
58
  // src/get-mod-deps.ts
38
59
  var jsExtensions = [".js", ".cjs", ".mjs"];
@@ -68,7 +89,7 @@ function getDeps(opts, fromAlias) {
68
89
  if (fromAlias) {
69
90
  opts.foundModuleAliases.set(fromAlias, absoluteFile);
70
91
  }
71
- if (seen.has(absoluteFile))
92
+ if (seen.size > 1 && seen.has(absoluteFile))
72
93
  return;
73
94
  seen.add(absoluteFile);
74
95
  const contents = fs.readFileSync(absoluteFile, "utf-8");
@@ -291,6 +312,7 @@ async function bundleConfigFile(options) {
291
312
  }
292
313
  export {
293
314
  bundleConfigFile,
315
+ convertTsPathsToRegexes,
294
316
  findConfigFile,
295
317
  getConfigDependencies,
296
318
  getResolvedConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/config",
3
- "version": "0.0.0-dev-20230702075205",
3
+ "version": "0.0.0-dev-20230702194035",
4
4
  "description": "Find and load panda config",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -19,11 +19,11 @@
19
19
  "jiti": "^1.18.2",
20
20
  "merge-anything": "^5.1.7",
21
21
  "tsconfck": "^2.1.1",
22
- "@pandacss/error": "0.0.0-dev-20230702075205",
23
- "@pandacss/logger": "0.0.0-dev-20230702075205",
24
- "@pandacss/preset-base": "0.0.0-dev-20230702075205",
25
- "@pandacss/preset-panda": "0.0.0-dev-20230702075205",
26
- "@pandacss/types": "0.0.0-dev-20230702075205"
22
+ "@pandacss/error": "0.0.0-dev-20230702194035",
23
+ "@pandacss/logger": "0.0.0-dev-20230702194035",
24
+ "@pandacss/preset-base": "0.0.0-dev-20230702194035",
25
+ "@pandacss/preset-panda": "0.0.0-dev-20230702194035",
26
+ "@pandacss/types": "0.0.0-dev-20230702194035"
27
27
  },
28
28
  "devDependencies": {
29
29
  "pkg-types": "1.0.3"