@pandacss/config 1.11.1 → 1.11.3

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
@@ -46,7 +46,75 @@ module.exports = __toCommonJS(index_exports);
46
46
  // src/bundle-config.ts
47
47
  var import_logger = require("@pandacss/logger");
48
48
  var import_shared2 = require("@pandacss/shared");
49
- var import_bundle_n_require = require("bundle-n-require");
49
+
50
+ // src/bundle-n-require.ts
51
+ var import_node_fs = require("fs");
52
+ var import_node_module = require("module");
53
+ var import_node_path = require("path");
54
+ var import_esbuild = require("esbuild");
55
+ var ModuleInternals = import_node_module.Module;
56
+ async function bundleConfigFile(file, cwd, options) {
57
+ const result = await (0, import_esbuild.build)({
58
+ platform: "node",
59
+ format: "cjs",
60
+ mainFields: ["module", "main"],
61
+ ...options,
62
+ absWorkingDir: cwd,
63
+ entryPoints: [file],
64
+ outfile: "out.js",
65
+ write: false,
66
+ bundle: true,
67
+ sourcemap: false,
68
+ metafile: true
69
+ });
70
+ const { text } = result.outputFiles[0];
71
+ return {
72
+ code: text,
73
+ dependencies: result.metafile ? Object.keys(result.metafile.inputs) : []
74
+ };
75
+ }
76
+ function loadBundledFile(req, file, code) {
77
+ const extension = (0, import_node_path.extname)(file);
78
+ const realFileName = import_node_fs.realpathSync.native(file);
79
+ const loader = req.extensions[extension];
80
+ req.extensions[extension] = (mod, filename) => {
81
+ if (filename === realFileName) {
82
+ ;
83
+ mod._compile(code, filename);
84
+ } else {
85
+ loader?.(mod, filename);
86
+ }
87
+ };
88
+ try {
89
+ delete req.cache[req.resolve(file)];
90
+ const raw = req(file);
91
+ return raw?.default ?? raw;
92
+ } finally {
93
+ if (loader) req.extensions[extension] = loader;
94
+ else delete req.extensions[extension];
95
+ }
96
+ }
97
+ function evalBundledFile(file, code) {
98
+ const mod = new import_node_module.Module(file);
99
+ mod.filename = file;
100
+ mod.paths = ModuleInternals._nodeModulePaths((0, import_node_path.dirname)(file));
101
+ mod._compile(code, file);
102
+ const raw = mod.exports;
103
+ return raw?.default ?? raw;
104
+ }
105
+ async function bundleNRequire(file, opts = {}) {
106
+ const { cwd = process.cwd() } = opts;
107
+ const req = (0, import_node_module.createRequire)((0, import_node_path.join)(cwd, "index.js"));
108
+ const absPath = req.resolve(file);
109
+ const { code, dependencies } = await bundleConfigFile(absPath, cwd);
110
+ let mod;
111
+ try {
112
+ mod = loadBundledFile(req, absPath, code);
113
+ } catch {
114
+ mod = evalBundledFile(absPath, code);
115
+ }
116
+ return { mod, code, dependencies };
117
+ }
50
118
 
51
119
  // src/find-config.ts
52
120
  var import_shared = require("@pandacss/shared");
@@ -83,10 +151,7 @@ function findConfig(options) {
83
151
 
84
152
  // src/bundle-config.ts
85
153
  async function bundle(filepath, cwd) {
86
- const { mod, dependencies } = await (0, import_bundle_n_require.bundleNRequire)(filepath, {
87
- cwd,
88
- interopDefault: true
89
- });
154
+ const { mod, dependencies } = await bundleNRequire(filepath, { cwd });
90
155
  const config = mod?.default ?? mod;
91
156
  return {
92
157
  config,
package/dist/index.mjs CHANGED
@@ -18,7 +18,75 @@ import {
18
18
  // src/bundle-config.ts
19
19
  import { logger } from "@pandacss/logger";
20
20
  import { PandaError as PandaError2 } from "@pandacss/shared";
21
- import { bundleNRequire } from "bundle-n-require";
21
+
22
+ // src/bundle-n-require.ts
23
+ import { realpathSync } from "fs";
24
+ import { createRequire, Module } from "module";
25
+ import { dirname, extname, join } from "path";
26
+ import { build } from "esbuild";
27
+ var ModuleInternals = Module;
28
+ async function bundleConfigFile(file, cwd, options) {
29
+ const result = await build({
30
+ platform: "node",
31
+ format: "cjs",
32
+ mainFields: ["module", "main"],
33
+ ...options,
34
+ absWorkingDir: cwd,
35
+ entryPoints: [file],
36
+ outfile: "out.js",
37
+ write: false,
38
+ bundle: true,
39
+ sourcemap: false,
40
+ metafile: true
41
+ });
42
+ const { text } = result.outputFiles[0];
43
+ return {
44
+ code: text,
45
+ dependencies: result.metafile ? Object.keys(result.metafile.inputs) : []
46
+ };
47
+ }
48
+ function loadBundledFile(req, file, code) {
49
+ const extension = extname(file);
50
+ const realFileName = realpathSync.native(file);
51
+ const loader = req.extensions[extension];
52
+ req.extensions[extension] = (mod, filename) => {
53
+ if (filename === realFileName) {
54
+ ;
55
+ mod._compile(code, filename);
56
+ } else {
57
+ loader?.(mod, filename);
58
+ }
59
+ };
60
+ try {
61
+ delete req.cache[req.resolve(file)];
62
+ const raw = req(file);
63
+ return raw?.default ?? raw;
64
+ } finally {
65
+ if (loader) req.extensions[extension] = loader;
66
+ else delete req.extensions[extension];
67
+ }
68
+ }
69
+ function evalBundledFile(file, code) {
70
+ const mod = new Module(file);
71
+ mod.filename = file;
72
+ mod.paths = ModuleInternals._nodeModulePaths(dirname(file));
73
+ mod._compile(code, file);
74
+ const raw = mod.exports;
75
+ return raw?.default ?? raw;
76
+ }
77
+ async function bundleNRequire(file, opts = {}) {
78
+ const { cwd = process.cwd() } = opts;
79
+ const req = createRequire(join(cwd, "index.js"));
80
+ const absPath = req.resolve(file);
81
+ const { code, dependencies } = await bundleConfigFile(absPath, cwd);
82
+ let mod;
83
+ try {
84
+ mod = loadBundledFile(req, absPath, code);
85
+ } catch {
86
+ mod = evalBundledFile(absPath, code);
87
+ }
88
+ return { mod, code, dependencies };
89
+ }
22
90
 
23
91
  // src/find-config.ts
24
92
  import { PandaError } from "@pandacss/shared";
@@ -55,10 +123,7 @@ function findConfig(options) {
55
123
 
56
124
  // src/bundle-config.ts
57
125
  async function bundle(filepath, cwd) {
58
- const { mod, dependencies } = await bundleNRequire(filepath, {
59
- cwd,
60
- interopDefault: true
61
- });
126
+ const { mod, dependencies } = await bundleNRequire(filepath, { cwd });
62
127
  const config = mod?.default ?? mod;
63
128
  return {
64
129
  config,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/config",
3
- "version": "1.11.1",
3
+ "version": "1.11.3",
4
4
  "description": "Find and load panda config",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -69,19 +69,22 @@
69
69
  "dist"
70
70
  ],
71
71
  "dependencies": {
72
- "bundle-n-require": "1.1.2",
72
+ "esbuild": "0.25.12",
73
73
  "escalade": "3.2.0",
74
74
  "microdiff": "1.5.0",
75
75
  "typescript": "6.0.2",
76
- "@pandacss/logger": "1.11.1",
77
- "@pandacss/preset-base": "1.11.1",
78
- "@pandacss/preset-panda": "1.11.1",
79
- "@pandacss/shared": "1.11.1",
80
- "@pandacss/types": "1.11.1"
76
+ "@pandacss/logger": "1.11.3",
77
+ "@pandacss/preset-base": "1.11.3",
78
+ "@pandacss/preset-panda": "1.11.3",
79
+ "@pandacss/shared": "1.11.3",
80
+ "@pandacss/types": "1.11.3"
81
81
  },
82
82
  "devDependencies": {
83
83
  "pkg-types": "2.3.0"
84
84
  },
85
+ "engines": {
86
+ "node": ">=20"
87
+ },
85
88
  "scripts": {
86
89
  "build": "tsup --tsconfig tsconfig.build.json --dts",
87
90
  "build-fast": "tsup --no-dts",