@pandacss/config 0.0.0-dev-20230428204429 → 0.0.0-dev-20230503105030

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
@@ -53,87 +53,18 @@ function findConfigFile({ cwd, file }) {
53
53
 
54
54
  // src/load-config.ts
55
55
  var import_error = require("@pandacss/error");
56
- var import_logger2 = require("@pandacss/logger");
57
-
58
- // src/bundle-require.ts
59
56
  var import_logger = require("@pandacss/logger");
60
- var import_fs2 = require("fs");
61
- var import_path3 = require("path");
62
-
63
- // src/bundle-config.ts
64
- var import_esbuild = require("esbuild");
65
- async function bundleConfigFile(fileName) {
66
- const result = await (0, import_esbuild.build)({
67
- absWorkingDir: process.cwd(),
68
- entryPoints: [fileName],
69
- outfile: "out.js",
70
- write: false,
71
- platform: "node",
72
- bundle: true,
73
- format: "cjs",
74
- sourcemap: false,
75
- metafile: true,
76
- mainFields: ["module", "main"]
77
- });
78
- const { text } = result.outputFiles[0];
79
- return {
80
- code: text,
81
- dependencies: result.metafile ? Object.keys(result.metafile.inputs) : []
82
- };
83
- }
84
-
85
- // src/load-bundled.ts
86
- var import_fs = __toESM(require("fs"));
87
- var import_path2 = __toESM(require("path"));
88
- function loadBundledFile(fileName, code) {
89
- const extension = import_path2.default.extname(fileName);
90
- const realFileName = import_fs.default.realpathSync(fileName);
91
- const loader = require.extensions[extension];
92
- require.extensions[extension] = (mod, filename) => {
93
- if (filename === realFileName) {
94
- mod._compile(code, filename);
95
- } else {
96
- loader(mod, filename);
97
- }
98
- };
99
- delete require.cache[require.resolve(fileName)];
100
- const raw = require(fileName);
101
- const config = raw.default ?? raw;
102
- require.extensions[extension] = loader;
103
- return config;
104
- }
105
-
106
- // src/bundle-require.ts
107
- async function bundleAndRequire(filepath, cwd) {
108
- const filePath = require.resolve(filepath, { paths: [cwd] });
109
- let config;
110
- let dependencies;
111
- const done = import_logger.logger.time.debug(`Bundling config file ${(0, import_logger.quote)((0, import_path3.relative)(cwd, filePath))}`);
112
- try {
113
- const realFileName = (0, import_fs2.realpathSync)(filePath);
114
- dependencies = [realFileName];
115
- delete require.cache[filePath];
116
- const mod = require(realFileName);
117
- config = mod.default ?? mod;
118
- } catch {
119
- const bundle = await bundleConfigFile(filePath);
120
- dependencies = bundle.dependencies;
121
- try {
122
- config = await loadBundledFile(filePath, bundle.code);
123
- } catch {
124
- config = require("node-eval")(bundle.code).default;
125
- }
126
- }
127
- done();
128
- return {
129
- config,
130
- dependencies
131
- };
132
- }
133
57
 
134
58
  // src/merge-config.ts
135
59
  var import_merge_anything = require("merge-anything");
136
60
 
61
+ // src/bundle.ts
62
+ var import_bundle_n_require = require("bundle-n-require");
63
+ async function bundle(filePath, cwd) {
64
+ const { mod: config, dependencies } = await (0, import_bundle_n_require.bundleNRequire)(filePath, { cwd });
65
+ return { config, dependencies };
66
+ }
67
+
137
68
  // src/utils.ts
138
69
  var isObject = (value) => {
139
70
  return Object.prototype.toString.call(value) === "[object Object]";
@@ -210,7 +141,7 @@ async function getResolvedConfig(config, cwd) {
210
141
  const configs2 = await Promise.all(
211
142
  presets.slice().reverse().map(async (preset) => {
212
143
  if (typeof preset === "string") {
213
- const presetModule = await bundleAndRequire(preset, cwd);
144
+ const presetModule = await bundle(preset, cwd);
214
145
  return getResolvedConfig(presetModule.config, cwd);
215
146
  } else {
216
147
  return getResolvedConfig(preset, cwd);
@@ -228,8 +159,8 @@ async function loadConfigFile(options) {
228
159
  if (!filePath) {
229
160
  throw new import_error.ConfigNotFoundError();
230
161
  }
231
- import_logger2.logger.debug("config:path", filePath);
232
- const result = await bundleAndRequire(filePath, cwd);
162
+ import_logger.logger.debug("config:path", filePath);
163
+ const result = await bundle(filePath, cwd);
233
164
  if (typeof result.config !== "object") {
234
165
  throw new import_error.ConfigError(`\u{1F4A5} Config must export or return an object.`);
235
166
  }
package/dist/index.mjs CHANGED
@@ -1,11 +1,3 @@
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
-
9
1
  // src/find-config.ts
10
2
  import findUp from "escalade/sync";
11
3
  import { resolve } from "path";
@@ -22,87 +14,18 @@ function findConfigFile({ cwd, file }) {
22
14
 
23
15
  // src/load-config.ts
24
16
  import { ConfigError, ConfigNotFoundError } from "@pandacss/error";
25
- import { logger as logger2 } from "@pandacss/logger";
26
-
27
- // src/bundle-require.ts
28
- import { logger, quote } from "@pandacss/logger";
29
- import { realpathSync } from "fs";
30
- import { relative } from "path";
31
-
32
- // src/bundle-config.ts
33
- import { build } from "esbuild";
34
- async function bundleConfigFile(fileName) {
35
- const result = await build({
36
- absWorkingDir: process.cwd(),
37
- entryPoints: [fileName],
38
- outfile: "out.js",
39
- write: false,
40
- platform: "node",
41
- bundle: true,
42
- format: "cjs",
43
- sourcemap: false,
44
- metafile: true,
45
- mainFields: ["module", "main"]
46
- });
47
- const { text } = result.outputFiles[0];
48
- return {
49
- code: text,
50
- dependencies: result.metafile ? Object.keys(result.metafile.inputs) : []
51
- };
52
- }
53
-
54
- // src/load-bundled.ts
55
- import fs from "fs";
56
- import path from "path";
57
- function loadBundledFile(fileName, code) {
58
- const extension = path.extname(fileName);
59
- const realFileName = fs.realpathSync(fileName);
60
- const loader = __require.extensions[extension];
61
- __require.extensions[extension] = (mod, filename) => {
62
- if (filename === realFileName) {
63
- mod._compile(code, filename);
64
- } else {
65
- loader(mod, filename);
66
- }
67
- };
68
- delete __require.cache[__require.resolve(fileName)];
69
- const raw = __require(fileName);
70
- const config = raw.default ?? raw;
71
- __require.extensions[extension] = loader;
72
- return config;
73
- }
74
-
75
- // src/bundle-require.ts
76
- async function bundleAndRequire(filepath, cwd) {
77
- const filePath = __require.resolve(filepath, { paths: [cwd] });
78
- let config;
79
- let dependencies;
80
- const done = logger.time.debug(`Bundling config file ${quote(relative(cwd, filePath))}`);
81
- try {
82
- const realFileName = realpathSync(filePath);
83
- dependencies = [realFileName];
84
- delete __require.cache[filePath];
85
- const mod = __require(realFileName);
86
- config = mod.default ?? mod;
87
- } catch {
88
- const bundle = await bundleConfigFile(filePath);
89
- dependencies = bundle.dependencies;
90
- try {
91
- config = await loadBundledFile(filePath, bundle.code);
92
- } catch {
93
- config = __require("node-eval")(bundle.code).default;
94
- }
95
- }
96
- done();
97
- return {
98
- config,
99
- dependencies
100
- };
101
- }
17
+ import { logger } from "@pandacss/logger";
102
18
 
103
19
  // src/merge-config.ts
104
20
  import { mergeAndConcat } from "merge-anything";
105
21
 
22
+ // src/bundle.ts
23
+ import { bundleNRequire } from "bundle-n-require";
24
+ async function bundle(filePath, cwd) {
25
+ const { mod: config, dependencies } = await bundleNRequire(filePath, { cwd });
26
+ return { config, dependencies };
27
+ }
28
+
106
29
  // src/utils.ts
107
30
  var isObject = (value) => {
108
31
  return Object.prototype.toString.call(value) === "[object Object]";
@@ -179,7 +102,7 @@ async function getResolvedConfig(config, cwd) {
179
102
  const configs2 = await Promise.all(
180
103
  presets.slice().reverse().map(async (preset) => {
181
104
  if (typeof preset === "string") {
182
- const presetModule = await bundleAndRequire(preset, cwd);
105
+ const presetModule = await bundle(preset, cwd);
183
106
  return getResolvedConfig(presetModule.config, cwd);
184
107
  } else {
185
108
  return getResolvedConfig(preset, cwd);
@@ -197,8 +120,8 @@ async function loadConfigFile(options) {
197
120
  if (!filePath) {
198
121
  throw new ConfigNotFoundError();
199
122
  }
200
- logger2.debug("config:path", filePath);
201
- const result = await bundleAndRequire(filePath, cwd);
123
+ logger.debug("config:path", filePath);
124
+ const result = await bundle(filePath, cwd);
202
125
  if (typeof result.config !== "object") {
203
126
  throw new ConfigError(`\u{1F4A5} Config must export or return an object.`);
204
127
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/config",
3
- "version": "0.0.0-dev-20230428204429",
3
+ "version": "0.0.0-dev-20230503105030",
4
4
  "description": "Find and load panda config",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -14,13 +14,12 @@
14
14
  "dist"
15
15
  ],
16
16
  "dependencies": {
17
+ "bundle-n-require": "^1.0.1",
17
18
  "merge-anything": "^5.1.4",
18
- "esbuild": "0.17.18",
19
19
  "escalade": "3.1.1",
20
- "node-eval": "2.0.0",
21
- "@pandacss/logger": "0.0.0-dev-20230428204429",
22
- "@pandacss/error": "0.0.0-dev-20230428204429",
23
- "@pandacss/types": "0.0.0-dev-20230428204429"
20
+ "@pandacss/logger": "0.0.0-dev-20230503105030",
21
+ "@pandacss/error": "0.0.0-dev-20230503105030",
22
+ "@pandacss/types": "0.0.0-dev-20230503105030"
24
23
  },
25
24
  "scripts": {
26
25
  "build": "pnpm tsup src/index.ts --format=esm,cjs --shims --dts",