@pandacss/config 0.0.0-dev-20230601114337 → 0.0.0-dev-20230602132346

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -107,18 +107,27 @@ function getConfigDependencies(filePath) {
107
107
 
108
108
  // src/load-config.ts
109
109
  var import_error = require("@pandacss/error");
110
- var import_logger = require("@pandacss/logger");
110
+ var import_logger2 = require("@pandacss/logger");
111
111
 
112
112
  // src/merge-config.ts
113
113
  var import_merge_anything = require("merge-anything");
114
114
 
115
115
  // src/bundle.ts
116
116
  var import_jiti = __toESM(require("jiti"));
117
+ var import_logger = require("@pandacss/logger");
118
+ var jiti;
117
119
  var bundle = async (filePath, cwd) => {
118
- const jiti = (0, import_jiti.default)(cwd, { cache: false, requireCache: false, v8cache: false });
119
- const conf = jiti(filePath);
120
+ let conf;
121
+ try {
122
+ jiti = jiti ?? (0, import_jiti.default)(cwd, { esmResolve: true, interopDefault: true });
123
+ conf = jiti(filePath);
124
+ } catch {
125
+ import_logger.logger.debug("bundle", "Couldn't load config with jiti, trying require: " + filePath);
126
+ conf = require(filePath);
127
+ }
120
128
  return {
121
- config: conf.default ? conf.default : conf,
129
+ config: Object.assign({}, conf.default ?? conf),
130
+ // prevent mutating the original config
122
131
  dependencies: Array.from(getConfigDependencies(filePath))
123
132
  };
124
133
  };
@@ -227,7 +236,7 @@ async function bundleConfigFile(options) {
227
236
  if (!filePath) {
228
237
  throw new import_error.ConfigNotFoundError();
229
238
  }
230
- import_logger.logger.debug("config:path", filePath);
239
+ import_logger2.logger.debug("config:path", filePath);
231
240
  const result = await bundle(filePath, cwd);
232
241
  if (typeof result.config !== "object") {
233
242
  throw new import_error.ConfigError(`\u{1F4A5} Config must export or return an object.`);
package/dist/index.mjs CHANGED
@@ -1,3 +1,11 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined")
5
+ return require.apply(this, arguments);
6
+ throw new Error('Dynamic require of "' + x + '" is not supported');
7
+ });
8
+
1
9
  // src/find-config.ts
2
10
  import findUp from "escalade/sync";
3
11
  import { resolve } from "path";
@@ -65,18 +73,27 @@ function getConfigDependencies(filePath) {
65
73
 
66
74
  // src/load-config.ts
67
75
  import { ConfigError, ConfigNotFoundError } from "@pandacss/error";
68
- import { logger } from "@pandacss/logger";
76
+ import { logger as logger2 } from "@pandacss/logger";
69
77
 
70
78
  // src/merge-config.ts
71
79
  import { mergeAndConcat } from "merge-anything";
72
80
 
73
81
  // src/bundle.ts
74
82
  import createJITI from "jiti";
83
+ import { logger } from "@pandacss/logger";
84
+ var jiti;
75
85
  var bundle = async (filePath, cwd) => {
76
- const jiti = createJITI(cwd, { cache: false, requireCache: false, v8cache: false });
77
- const conf = jiti(filePath);
86
+ let conf;
87
+ try {
88
+ jiti = jiti ?? createJITI(cwd, { esmResolve: true, interopDefault: true });
89
+ conf = jiti(filePath);
90
+ } catch {
91
+ logger.debug("bundle", "Couldn't load config with jiti, trying require: " + filePath);
92
+ conf = __require(filePath);
93
+ }
78
94
  return {
79
- config: conf.default ? conf.default : conf,
95
+ config: Object.assign({}, conf.default ?? conf),
96
+ // prevent mutating the original config
80
97
  dependencies: Array.from(getConfigDependencies(filePath))
81
98
  };
82
99
  };
@@ -185,7 +202,7 @@ async function bundleConfigFile(options) {
185
202
  if (!filePath) {
186
203
  throw new ConfigNotFoundError();
187
204
  }
188
- logger.debug("config:path", filePath);
205
+ logger2.debug("config:path", filePath);
189
206
  const result = await bundle(filePath, cwd);
190
207
  if (typeof result.config !== "object") {
191
208
  throw new ConfigError(`\u{1F4A5} Config must export or return an object.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/config",
3
- "version": "0.0.0-dev-20230601114337",
3
+ "version": "0.0.0-dev-20230602132346",
4
4
  "description": "Find and load panda config",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -17,9 +17,9 @@
17
17
  "escalade": "3.1.1",
18
18
  "jiti": "^1.18.2",
19
19
  "merge-anything": "^5.1.7",
20
- "@pandacss/error": "0.0.0-dev-20230601114337",
21
- "@pandacss/logger": "0.0.0-dev-20230601114337",
22
- "@pandacss/types": "0.0.0-dev-20230601114337"
20
+ "@pandacss/error": "0.0.0-dev-20230602132346",
21
+ "@pandacss/logger": "0.0.0-dev-20230602132346",
22
+ "@pandacss/types": "0.0.0-dev-20230602132346"
23
23
  },
24
24
  "scripts": {
25
25
  "build": "pnpm tsup src/index.ts --format=esm,cjs --shims --dts",