@pandacss/node 0.0.0-dev-20230530140607 → 0.0.0-dev-20230530153916

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.ts CHANGED
@@ -204,6 +204,7 @@ declare class Builder {
204
204
  registerDependency(fn: (dep: Message) => void): void;
205
205
  }
206
206
 
207
+ declare function findConfig(): string | undefined;
207
208
  declare function loadConfigAndCreateContext(options?: {
208
209
  cwd?: string;
209
210
  config?: Config;
@@ -217,12 +218,15 @@ declare function debugFiles(ctx: PandaContext, options: {
217
218
 
218
219
  declare function execCommand(cmd: string, cwd: string): Promise<void>;
219
220
 
221
+ declare function extractFile(ctx: PandaContext, file: string): string | undefined;
220
222
  declare function emitArtifacts(ctx: PandaContext): Promise<string>;
221
223
  declare function emitAndExtract(ctx: PandaContext): Promise<string>;
222
224
  declare function extractCss(ctx: PandaContext): Promise<string>;
223
225
 
224
226
  declare function generate(config: Config, configPath?: string): Promise<void>;
225
227
 
228
+ declare function parseDependency(fileOrGlob: string): Message | null;
229
+
226
230
  declare function setupGitIgnore({ config: { outdir, gitignore } }: PandaContext): void;
227
231
 
228
232
  type SetupOptions = {
@@ -234,4 +238,4 @@ declare function setupPostcss(cwd: string): Promise<void>;
234
238
 
235
239
  declare function shipFiles(ctx: PandaContext, outfile: string): Promise<void>;
236
240
 
237
- export { Builder, analyzeTokens, createContext, debugFiles, emitAndExtract, emitArtifacts, execCommand, extractCss, generate, loadConfigAndCreateContext, setupConfig, setupGitIgnore, setupPostcss, shipFiles, writeAnalyzeJSON };
241
+ export { Builder, PandaContext, analyzeTokens, createContext, debugFiles, emitAndExtract, emitArtifacts, execCommand, extractCss, extractFile, findConfig, generate, loadConfigAndCreateContext, parseDependency, setupConfig, setupGitIgnore, setupPostcss, shipFiles, writeAnalyzeJSON };
package/dist/index.js CHANGED
@@ -33,9 +33,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
33
33
  ));
34
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
35
 
36
- // ../../node_modules/.pnpm/tsup@6.7.0_typescript@5.0.4/node_modules/tsup/assets/cjs_shims.js
36
+ // ../../node_modules/.pnpm/tsup@6.7.0_postcss@8.4.24_typescript@5.0.4/node_modules/tsup/assets/cjs_shims.js
37
37
  var init_cjs_shims = __esm({
38
- "../../node_modules/.pnpm/tsup@6.7.0_typescript@5.0.4/node_modules/tsup/assets/cjs_shims.js"() {
38
+ "../../node_modules/.pnpm/tsup@6.7.0_postcss@8.4.24_typescript@5.0.4/node_modules/tsup/assets/cjs_shims.js"() {
39
39
  }
40
40
  });
41
41
 
@@ -484,8 +484,11 @@ __export(src_exports, {
484
484
  emitArtifacts: () => emitArtifacts,
485
485
  execCommand: () => execCommand,
486
486
  extractCss: () => extractCss,
487
+ extractFile: () => extractFile,
488
+ findConfig: () => findConfig,
487
489
  generate: () => generate,
488
490
  loadConfigAndCreateContext: () => loadConfigAndCreateContext,
491
+ parseDependency: () => parseDependency,
489
492
  setupConfig: () => setupConfig,
490
493
  setupGitIgnore: () => setupGitIgnore,
491
494
  setupPostcss: () => setupPostcss,
@@ -864,9 +867,9 @@ init_cjs_shims();
864
867
  var import_core2 = require("@pandacss/core");
865
868
  var import_error = require("@pandacss/error");
866
869
  var import_logger4 = require("@pandacss/logger");
867
- var import_fs2 = require("fs");
870
+ var import_fs = require("fs");
868
871
  var import_fs_extra2 = require("fs-extra");
869
- var import_path4 = require("path");
872
+ var import_path3 = require("path");
870
873
 
871
874
  // src/config.ts
872
875
  init_cjs_shims();
@@ -882,18 +885,18 @@ var import_lil_fp = require("lil-fp");
882
885
  // src/chunk-engine.ts
883
886
  init_cjs_shims();
884
887
  var import_core = require("@pandacss/core");
885
- var getChunkEngine = ({ paths, config, runtime: { path: path4, fs: fs3 } }) => ({
886
- dir: path4.join(...paths.chunk),
888
+ var getChunkEngine = ({ paths, config, runtime: { path: path3, fs: fs2 } }) => ({
889
+ dir: path3.join(...paths.chunk),
887
890
  readFile(file) {
888
- const fileName = path4.join(...paths.chunk, this.format(file));
889
- return fs3.existsSync(fileName) ? fs3.readFileSync(fileName) : "";
891
+ const fileName = path3.join(...paths.chunk, this.format(file));
892
+ return fs2.existsSync(fileName) ? fs2.readFileSync(fileName) : "";
890
893
  },
891
894
  getFiles() {
892
- const files = fs3.existsSync(this.dir) ? fs3.readDirSync(this.dir) : [];
893
- return files.map((file) => fs3.readFileSync(path4.join(this.dir, file)));
895
+ const files = fs2.existsSync(this.dir) ? fs2.readDirSync(this.dir) : [];
896
+ return files.map((file) => fs2.readFileSync(path3.join(this.dir, file)));
894
897
  },
895
898
  format(file) {
896
- return path4.relative(config.cwd, file).replaceAll(path4.sep, "__").replace(path4.extname(file), ".css");
899
+ return path3.relative(config.cwd, file).replaceAll(path3.sep, "__").replace(path3.extname(file), ".css");
897
900
  },
898
901
  getArtifact(file, css) {
899
902
  const fileName = this.format(file);
@@ -904,10 +907,10 @@ var getChunkEngine = ({ paths, config, runtime: { path: path4, fs: fs3 } }) => (
904
907
  };
905
908
  },
906
909
  rm(file) {
907
- return fs3.rmFileSync(path4.join(...paths.chunk, this.format(file)));
910
+ return fs2.rmFileSync(path3.join(...paths.chunk, this.format(file)));
908
911
  },
909
912
  empty() {
910
- return fs3.rmDirSync(this.dir);
913
+ return fs2.rmDirSync(this.dir);
911
914
  },
912
915
  get glob() {
913
916
  return [`${this.dir}/**/*.css`];
@@ -954,8 +957,8 @@ var nodeRuntime = {
954
957
  readDirSync: import_fs_extra.readdirSync,
955
958
  rmDirSync: import_fs_extra.emptyDirSync,
956
959
  rmFileSync: import_fs_extra.removeSync,
957
- ensureDirSync(path4) {
958
- return (0, import_fs_extra.ensureDirSync)(path4);
960
+ ensureDirSync(path3) {
961
+ return (0, import_fs_extra.ensureDirSync)(path3);
959
962
  },
960
963
  watch(options) {
961
964
  const { include, exclude, cwd, poll } = options;
@@ -986,20 +989,20 @@ process.on("uncaughtException", (reason) => {
986
989
 
987
990
  // src/output-engine.ts
988
991
  init_cjs_shims();
989
- var getOutputEngine = ({ paths, runtime: { path: path4, fs: fs3 } }) => ({
992
+ var getOutputEngine = ({ paths, runtime: { path: path3, fs: fs2 } }) => ({
990
993
  empty() {
991
- fs3.rmDirSync(path4.join(...paths.root));
994
+ fs2.rmDirSync(path3.join(...paths.root));
992
995
  },
993
996
  async write(output) {
994
997
  if (!output)
995
998
  return;
996
999
  const { dir = paths.root, files } = output;
997
- fs3.ensureDirSync(path4.join(...dir));
1000
+ fs2.ensureDirSync(path3.join(...dir));
998
1001
  return Promise.all(
999
1002
  files.map(async ({ file, code }) => {
1000
- const absPath = path4.join(...dir, file);
1003
+ const absPath = path3.join(...dir, file);
1001
1004
  if (code) {
1002
- return fs3.writeFile(absPath, code);
1005
+ return fs2.writeFile(absPath, code);
1003
1006
  }
1004
1007
  })
1005
1008
  );
@@ -1014,14 +1017,14 @@ var createContext = (conf) => (0, import_lil_fp.pipe)(
1014
1017
  (0, import_lil_fp.tap)(({ config, runtime }) => {
1015
1018
  config.cwd ||= runtime.cwd();
1016
1019
  }),
1017
- import_lil_fp.Obj.bind("getFiles", ({ config, runtime: { fs: fs3 } }) => () => {
1020
+ import_lil_fp.Obj.bind("getFiles", ({ config, runtime: { fs: fs2 } }) => () => {
1018
1021
  const { include, exclude, cwd } = config;
1019
- return fs3.glob({ include, exclude, cwd });
1022
+ return fs2.glob({ include, exclude, cwd });
1020
1023
  }),
1021
- import_lil_fp.Obj.bind("project", ({ getFiles, runtime: { fs: fs3 }, parserOptions }) => {
1024
+ import_lil_fp.Obj.bind("project", ({ getFiles, runtime: { fs: fs2 }, parserOptions }) => {
1022
1025
  return (0, import_parser.createProject)({
1023
1026
  getFiles,
1024
- readFile: fs3.readFileSync,
1027
+ readFile: fs2.readFileSync,
1025
1028
  parserOptions
1026
1029
  });
1027
1030
  }),
@@ -2355,8 +2358,8 @@ async function bundleChunks(ctx) {
2355
2358
  });
2356
2359
  }
2357
2360
  async function writeFileChunk(ctx, file) {
2358
- const { path: path4 } = ctx.runtime;
2359
- import_logger3.logger.debug("chunk:write", `File: ${path4.relative(ctx.config.cwd, file)}`);
2361
+ const { path: path3 } = ctx.runtime;
2362
+ import_logger3.logger.debug("chunk:write", `File: ${path3.relative(ctx.config.cwd, file)}`);
2360
2363
  const css = extractFile(ctx, file);
2361
2364
  if (!css)
2362
2365
  return;
@@ -2365,18 +2368,18 @@ async function writeFileChunk(ctx, file) {
2365
2368
  }
2366
2369
  function extractFile(ctx, file) {
2367
2370
  const {
2368
- runtime: { path: path4, fs: fs3 },
2371
+ runtime: { path: path3, fs: fs2 },
2369
2372
  config: { cwd }
2370
2373
  } = ctx;
2371
2374
  return (0, import_lil_fp2.pipe)(
2372
- { file: path4.abs(cwd, file) },
2375
+ { file: path3.abs(cwd, file) },
2373
2376
  (0, import_lil_fp2.tap)(() => import_logger3.logger.debug("file:extract", file)),
2374
2377
  import_lil_fp2.Obj.bind("measure", () => import_logger3.logger.time.debug(`Extracted ${file}`)),
2375
2378
  import_lil_fp2.Obj.bind(
2376
2379
  "result",
2377
2380
  (0, import_lil_fp2.tryCatch)(
2378
2381
  ({ file: file2 }) => {
2379
- return file2.endsWith(".json") ? import_parser2.ParserResult.fromJson(fs3.readFileSync(file2)) : ctx.project.parseSourceFile(file2);
2382
+ return file2.endsWith(".json") ? import_parser2.ParserResult.fromJson(fs2.readFileSync(file2)) : ctx.project.parseSourceFile(file2);
2380
2383
  },
2381
2384
  (error) => import_logger3.logger.error("file:parse", error)
2382
2385
  )
@@ -2413,62 +2416,10 @@ async function extractCss(ctx) {
2413
2416
  return ctx.messages.buildComplete(ctx.getFiles().length);
2414
2417
  }
2415
2418
 
2416
- // src/get-mod-deps.ts
2417
- init_cjs_shims();
2418
- var import_fs = __toESM(require("fs"));
2419
- var import_path2 = __toESM(require("path"));
2420
- var jsExtensions = [".js", ".cjs", ".mjs"];
2421
- var jsResolutionOrder = ["", ".js", ".cjs", ".mjs", ".ts", ".cts", ".mts", ".jsx", ".tsx"];
2422
- var tsResolutionOrder = ["", ".ts", ".cts", ".mts", ".tsx", ".js", ".cjs", ".mjs", ".jsx"];
2423
- function resolveWithExtension(file, extensions) {
2424
- for (const ext of extensions) {
2425
- const full = `${file}${ext}`;
2426
- if (import_fs.default.existsSync(full) && import_fs.default.statSync(full).isFile()) {
2427
- return full;
2428
- }
2429
- }
2430
- for (const ext of extensions) {
2431
- const full = `${file}/index${ext}`;
2432
- if (import_fs.default.existsSync(full)) {
2433
- return full;
2434
- }
2435
- }
2436
- return null;
2437
- }
2438
- function* getDeps(filename, base, seen, ext = import_path2.default.extname(filename)) {
2439
- const absoluteFile = resolveWithExtension(
2440
- import_path2.default.resolve(base, filename),
2441
- jsExtensions.includes(ext) ? jsResolutionOrder : tsResolutionOrder
2442
- );
2443
- if (absoluteFile === null)
2444
- return;
2445
- if (seen.has(absoluteFile))
2446
- return;
2447
- seen.add(absoluteFile);
2448
- yield absoluteFile;
2449
- base = import_path2.default.dirname(absoluteFile);
2450
- ext = import_path2.default.extname(absoluteFile);
2451
- const contents = import_fs.default.readFileSync(absoluteFile, "utf-8");
2452
- for (const match2 of [
2453
- ...contents.matchAll(/import[\s\S]*?['"](.{3,}?)['"]/gi),
2454
- ...contents.matchAll(/import[\s\S]*from[\s\S]*?['"](.{3,}?)['"]/gi),
2455
- ...contents.matchAll(/require\(['"`](.+)['"`]\)/gi)
2456
- ]) {
2457
- if (!match2[1].startsWith("."))
2458
- continue;
2459
- yield* getDeps(match2[1], base, seen, ext);
2460
- }
2461
- }
2462
- function getModuleDependencies(filePath) {
2463
- if (filePath === null)
2464
- return /* @__PURE__ */ new Set();
2465
- return new Set(getDeps(filePath, import_path2.default.dirname(filePath), /* @__PURE__ */ new Set()));
2466
- }
2467
-
2468
2419
  // src/parse-dependency.ts
2469
2420
  init_cjs_shims();
2470
2421
  var import_is_glob = __toESM(require("is-glob"));
2471
- var import_path3 = require("path");
2422
+ var import_path2 = require("path");
2472
2423
 
2473
2424
  // src/parse-glob.ts
2474
2425
  init_cjs_shims();
@@ -2499,9 +2450,9 @@ function parseDependency(fileOrGlob) {
2499
2450
  let message = null;
2500
2451
  if ((0, import_is_glob.default)(fileOrGlob)) {
2501
2452
  const { base, glob: glob2 } = parseGlob(fileOrGlob);
2502
- message = { type: "dir-dependency", dir: (0, import_path3.resolve)(base), glob: glob2 };
2453
+ message = { type: "dir-dependency", dir: (0, import_path2.resolve)(base), glob: glob2 };
2503
2454
  } else {
2504
- message = { type: "dependency", file: (0, import_path3.resolve)(fileOrGlob) };
2455
+ message = { type: "dependency", file: (0, import_path2.resolve)(fileOrGlob) };
2505
2456
  }
2506
2457
  if (message.type === "dir-dependency" && process.env.ROLLUP_WATCH === "true") {
2507
2458
  message = { type: "dependency", file: message.dir };
@@ -2510,6 +2461,7 @@ function parseDependency(fileOrGlob) {
2510
2461
  }
2511
2462
 
2512
2463
  // src/builder.ts
2464
+ var import_config3 = require("@pandacss/config");
2513
2465
  var configCache = /* @__PURE__ */ new Map();
2514
2466
  var contentFilesCache = /* @__PURE__ */ new WeakMap();
2515
2467
  var setupCount = 0;
@@ -2554,7 +2506,7 @@ var Builder = class {
2554
2506
  }
2555
2507
  async setup() {
2556
2508
  const configPath = this.getConfigPath();
2557
- const configDeps = getModuleDependencies(configPath);
2509
+ const configDeps = (0, import_config3.getConfigDependencies)(configPath);
2558
2510
  const deps = this.checkConfigDeps(configPath, configDeps);
2559
2511
  if (deps.isModified) {
2560
2512
  return this.setupContext({
@@ -2582,7 +2534,7 @@ var Builder = class {
2582
2534
  }
2583
2535
  configCache.set(configPath, {
2584
2536
  context: this.context,
2585
- deps: new Set(this.context.configDependencies),
2537
+ deps: new Set(this.context.dependencies ?? []),
2586
2538
  depsModifiedMap
2587
2539
  });
2588
2540
  contentFilesCache.set(this.context, {
@@ -2605,7 +2557,7 @@ var Builder = class {
2605
2557
  return contentFilesCache.get(ctx).fileCssMap;
2606
2558
  }
2607
2559
  async extractFile(ctx, file) {
2608
- const mtime = (0, import_fs2.existsSync)(file) ? (0, import_fs_extra2.statSync)(file).mtimeMs : -Infinity;
2560
+ const mtime = (0, import_fs.existsSync)(file) ? (0, import_fs_extra2.statSync)(file).mtimeMs : -Infinity;
2609
2561
  const isUnchanged = this.fileModifiedMap.has(file) && mtime === this.fileModifiedMap.get(file);
2610
2562
  if (isUnchanged)
2611
2563
  return;
@@ -2659,7 +2611,7 @@ var Builder = class {
2659
2611
  }
2660
2612
  }
2661
2613
  for (const file of ctx.dependencies) {
2662
- fn({ type: "dependency", file: (0, import_path4.resolve)(file) });
2614
+ fn({ type: "dependency", file: (0, import_path3.resolve)(file) });
2663
2615
  }
2664
2616
  }
2665
2617
  };
@@ -2668,7 +2620,7 @@ var Builder = class {
2668
2620
  init_cjs_shims();
2669
2621
  var import_logger5 = require("@pandacss/logger");
2670
2622
  var import_promises2 = require("fs/promises");
2671
- var path2 = __toESM(require("path"));
2623
+ var path = __toESM(require("path"));
2672
2624
  async function debugFiles(ctx, options) {
2673
2625
  const files = ctx.getFiles();
2674
2626
  const measureTotal = import_logger5.logger.time.debug(`Done parsing ${files.length} files`);
@@ -2708,10 +2660,10 @@ async function debugFiles(ctx, options) {
2708
2660
  }
2709
2661
  if (options.outdir) {
2710
2662
  filesWithCss.push(file);
2711
- const parsedPath = path2.parse(file);
2712
- const relative4 = path2.relative(ctx.config.cwd, parsedPath.dir);
2713
- const astJsonPath = `${relative4}/${parsedPath.name}.ast.json`.replaceAll(path2.sep, "__");
2714
- const cssPath = `${relative4}/${parsedPath.name}.css`.replaceAll(path2.sep, "__");
2663
+ const parsedPath = path.parse(file);
2664
+ const relative4 = path.relative(ctx.config.cwd, parsedPath.dir);
2665
+ const astJsonPath = `${relative4}/${parsedPath.name}.ast.json`.replaceAll(path.sep, "__");
2666
+ const cssPath = `${relative4}/${parsedPath.name}.css`.replaceAll(path.sep, "__");
2715
2667
  import_logger5.logger.info("cli", `Writing ${import_logger5.colors.bold(`${options.outdir}/${astJsonPath}`)}`);
2716
2668
  import_logger5.logger.info("cli", `Writing ${import_logger5.colors.bold(`${options.outdir}/${cssPath}`)}`);
2717
2669
  return Promise.all([
@@ -2779,22 +2731,22 @@ async function generate(config, configPath) {
2779
2731
  const ctx = ctxRef.current;
2780
2732
  await build(ctx);
2781
2733
  const {
2782
- runtime: { fs: fs3, path: path4 },
2734
+ runtime: { fs: fs2, path: path3 },
2783
2735
  dependencies,
2784
2736
  config: { cwd }
2785
2737
  } = ctx;
2786
2738
  if (ctx.config.watch) {
2787
- const configWatcher = fs3.watch({ include: dependencies });
2739
+ const configWatcher = fs2.watch({ include: dependencies });
2788
2740
  configWatcher.on("change", async () => {
2789
2741
  import_logger7.logger.info("config:change", "Config changed, restarting...");
2790
2742
  await loadCtx();
2791
2743
  return build(ctxRef.current);
2792
2744
  });
2793
- const contentWatcher = fs3.watch(ctx.config);
2745
+ const contentWatcher = fs2.watch(ctx.config);
2794
2746
  contentWatcher.on("all", async (event, file) => {
2795
2747
  import_logger7.logger.info(`file:${event}`, file);
2796
2748
  (0, import_ts_pattern.match)(event).with("unlink", () => {
2797
- ctx.project.removeSourceFile(path4.abs(cwd, file));
2749
+ ctx.project.removeSourceFile(path3.abs(cwd, file));
2798
2750
  ctx.chunks.rm(file);
2799
2751
  }).with("change", async () => {
2800
2752
  ctx.project.reloadSourceFile(file);
@@ -2812,7 +2764,7 @@ async function generate(config, configPath) {
2812
2764
 
2813
2765
  // src/git-ignore.ts
2814
2766
  init_cjs_shims();
2815
- var import_fs3 = require("fs");
2767
+ var import_fs2 = require("fs");
2816
2768
  var import_look_it_up2 = require("look-it-up");
2817
2769
  var import_outdent = __toESM(require("outdent"));
2818
2770
  function setupGitIgnore({ config: { outdir, gitignore = true } }) {
@@ -2824,11 +2776,11 @@ function setupGitIgnore({ config: { outdir, gitignore = true } }) {
2824
2776
  `;
2825
2777
  const file = (0, import_look_it_up2.lookItUpSync)(".gitignore");
2826
2778
  if (!file) {
2827
- return (0, import_fs3.writeFileSync)(".gitignore", txt);
2779
+ return (0, import_fs2.writeFileSync)(".gitignore", txt);
2828
2780
  }
2829
- const content = (0, import_fs3.readFileSync)(file, "utf-8");
2781
+ const content = (0, import_fs2.readFileSync)(file, "utf-8");
2830
2782
  if (!content.includes(outdir)) {
2831
- (0, import_fs3.appendFileSync)(file, txt);
2783
+ (0, import_fs2.appendFileSync)(file, txt);
2832
2784
  }
2833
2785
  }
2834
2786
 
@@ -2839,7 +2791,7 @@ var import_generator2 = require("@pandacss/generator");
2839
2791
  var import_fs_extra3 = require("fs-extra");
2840
2792
  var import_look_it_up3 = require("look-it-up");
2841
2793
  var import_outdent2 = require("outdent");
2842
- var import_path5 = require("path");
2794
+ var import_path4 = require("path");
2843
2795
  var import_preferred_pm2 = __toESM(require("preferred-pm"));
2844
2796
  async function setupConfig(cwd, opts = {}) {
2845
2797
  const { force, outExtension } = opts;
@@ -2872,7 +2824,7 @@ outExtension: '${outExtension}',` : ""}
2872
2824
  outdir: "styled-system",
2873
2825
  })
2874
2826
  `;
2875
- await (0, import_fs_extra3.writeFile)((0, import_path5.join)(cwd, file), content);
2827
+ await (0, import_fs_extra3.writeFile)((0, import_path4.join)(cwd, file), content);
2876
2828
  import_logger8.logger.log(import_generator2.messages.thankYou());
2877
2829
  }
2878
2830
  }
@@ -2885,7 +2837,7 @@ async function setupPostcss(cwd) {
2885
2837
  },
2886
2838
  }
2887
2839
  `;
2888
- await (0, import_fs_extra3.writeFile)((0, import_path5.join)(cwd, "postcss.config.cjs"), content);
2840
+ await (0, import_fs_extra3.writeFile)((0, import_path4.join)(cwd, "postcss.config.cjs"), content);
2889
2841
  }
2890
2842
 
2891
2843
  // src/ship-files.ts
@@ -2893,7 +2845,7 @@ init_cjs_shims();
2893
2845
  var import_logger9 = require("@pandacss/logger");
2894
2846
  var import_parser3 = require("@pandacss/parser");
2895
2847
  var import_promises3 = require("fs/promises");
2896
- var path3 = __toESM(require("path"));
2848
+ var path2 = __toESM(require("path"));
2897
2849
  async function shipFiles(ctx, outfile) {
2898
2850
  const files = ctx.getFiles();
2899
2851
  const extractResult = (0, import_parser3.createParserResult)();
@@ -2906,7 +2858,7 @@ async function shipFiles(ctx, outfile) {
2906
2858
  if (!css)
2907
2859
  return;
2908
2860
  extractResult.merge(result);
2909
- filesWithCss.push(path3.relative(ctx.config.cwd, file));
2861
+ filesWithCss.push(path2.relative(ctx.config.cwd, file));
2910
2862
  });
2911
2863
  import_logger9.logger.info("cli", `Found ${import_logger9.colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
2912
2864
  const minify = ctx.config.minify;
@@ -2926,8 +2878,11 @@ async function shipFiles(ctx, outfile) {
2926
2878
  emitArtifacts,
2927
2879
  execCommand,
2928
2880
  extractCss,
2881
+ extractFile,
2882
+ findConfig,
2929
2883
  generate,
2930
2884
  loadConfigAndCreateContext,
2885
+ parseDependency,
2931
2886
  setupConfig,
2932
2887
  setupGitIgnore,
2933
2888
  setupPostcss,
package/dist/index.mjs CHANGED
@@ -34,9 +34,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
34
34
  mod
35
35
  ));
36
36
 
37
- // ../../node_modules/.pnpm/tsup@6.7.0_typescript@5.0.4/node_modules/tsup/assets/esm_shims.js
37
+ // ../../node_modules/.pnpm/tsup@6.7.0_postcss@8.4.24_typescript@5.0.4/node_modules/tsup/assets/esm_shims.js
38
38
  var init_esm_shims = __esm({
39
- "../../node_modules/.pnpm/tsup@6.7.0_typescript@5.0.4/node_modules/tsup/assets/esm_shims.js"() {
39
+ "../../node_modules/.pnpm/tsup@6.7.0_postcss@8.4.24_typescript@5.0.4/node_modules/tsup/assets/esm_shims.js"() {
40
40
  }
41
41
  });
42
42
 
@@ -861,18 +861,18 @@ import { Obj, pipe, tap } from "lil-fp";
861
861
  // src/chunk-engine.ts
862
862
  init_esm_shims();
863
863
  import { mergeCss } from "@pandacss/core";
864
- var getChunkEngine = ({ paths, config, runtime: { path: path4, fs: fs2 } }) => ({
865
- dir: path4.join(...paths.chunk),
864
+ var getChunkEngine = ({ paths, config, runtime: { path: path3, fs } }) => ({
865
+ dir: path3.join(...paths.chunk),
866
866
  readFile(file) {
867
- const fileName = path4.join(...paths.chunk, this.format(file));
868
- return fs2.existsSync(fileName) ? fs2.readFileSync(fileName) : "";
867
+ const fileName = path3.join(...paths.chunk, this.format(file));
868
+ return fs.existsSync(fileName) ? fs.readFileSync(fileName) : "";
869
869
  },
870
870
  getFiles() {
871
- const files = fs2.existsSync(this.dir) ? fs2.readDirSync(this.dir) : [];
872
- return files.map((file) => fs2.readFileSync(path4.join(this.dir, file)));
871
+ const files = fs.existsSync(this.dir) ? fs.readDirSync(this.dir) : [];
872
+ return files.map((file) => fs.readFileSync(path3.join(this.dir, file)));
873
873
  },
874
874
  format(file) {
875
- return path4.relative(config.cwd, file).replaceAll(path4.sep, "__").replace(path4.extname(file), ".css");
875
+ return path3.relative(config.cwd, file).replaceAll(path3.sep, "__").replace(path3.extname(file), ".css");
876
876
  },
877
877
  getArtifact(file, css) {
878
878
  const fileName = this.format(file);
@@ -883,10 +883,10 @@ var getChunkEngine = ({ paths, config, runtime: { path: path4, fs: fs2 } }) => (
883
883
  };
884
884
  },
885
885
  rm(file) {
886
- return fs2.rmFileSync(path4.join(...paths.chunk, this.format(file)));
886
+ return fs.rmFileSync(path3.join(...paths.chunk, this.format(file)));
887
887
  },
888
888
  empty() {
889
- return fs2.rmDirSync(this.dir);
889
+ return fs.rmDirSync(this.dir);
890
890
  },
891
891
  get glob() {
892
892
  return [`${this.dir}/**/*.css`];
@@ -942,8 +942,8 @@ var nodeRuntime = {
942
942
  readDirSync: readdirSync,
943
943
  rmDirSync: emptyDirSync,
944
944
  rmFileSync: removeSync,
945
- ensureDirSync(path4) {
946
- return ensureDirSync(path4);
945
+ ensureDirSync(path3) {
946
+ return ensureDirSync(path3);
947
947
  },
948
948
  watch(options) {
949
949
  const { include, exclude, cwd, poll } = options;
@@ -974,20 +974,20 @@ process.on("uncaughtException", (reason) => {
974
974
 
975
975
  // src/output-engine.ts
976
976
  init_esm_shims();
977
- var getOutputEngine = ({ paths, runtime: { path: path4, fs: fs2 } }) => ({
977
+ var getOutputEngine = ({ paths, runtime: { path: path3, fs } }) => ({
978
978
  empty() {
979
- fs2.rmDirSync(path4.join(...paths.root));
979
+ fs.rmDirSync(path3.join(...paths.root));
980
980
  },
981
981
  async write(output) {
982
982
  if (!output)
983
983
  return;
984
984
  const { dir = paths.root, files } = output;
985
- fs2.ensureDirSync(path4.join(...dir));
985
+ fs.ensureDirSync(path3.join(...dir));
986
986
  return Promise.all(
987
987
  files.map(async ({ file, code }) => {
988
- const absPath = path4.join(...dir, file);
988
+ const absPath = path3.join(...dir, file);
989
989
  if (code) {
990
- return fs2.writeFile(absPath, code);
990
+ return fs.writeFile(absPath, code);
991
991
  }
992
992
  })
993
993
  );
@@ -1002,14 +1002,14 @@ var createContext = (conf) => pipe(
1002
1002
  tap(({ config, runtime }) => {
1003
1003
  config.cwd ||= runtime.cwd();
1004
1004
  }),
1005
- Obj.bind("getFiles", ({ config, runtime: { fs: fs2 } }) => () => {
1005
+ Obj.bind("getFiles", ({ config, runtime: { fs } }) => () => {
1006
1006
  const { include, exclude, cwd } = config;
1007
- return fs2.glob({ include, exclude, cwd });
1007
+ return fs.glob({ include, exclude, cwd });
1008
1008
  }),
1009
- Obj.bind("project", ({ getFiles, runtime: { fs: fs2 }, parserOptions }) => {
1009
+ Obj.bind("project", ({ getFiles, runtime: { fs }, parserOptions }) => {
1010
1010
  return createProject({
1011
1011
  getFiles,
1012
- readFile: fs2.readFileSync,
1012
+ readFile: fs.readFileSync,
1013
1013
  parserOptions
1014
1014
  });
1015
1015
  }),
@@ -2343,8 +2343,8 @@ async function bundleChunks(ctx) {
2343
2343
  });
2344
2344
  }
2345
2345
  async function writeFileChunk(ctx, file) {
2346
- const { path: path4 } = ctx.runtime;
2347
- logger3.debug("chunk:write", `File: ${path4.relative(ctx.config.cwd, file)}`);
2346
+ const { path: path3 } = ctx.runtime;
2347
+ logger3.debug("chunk:write", `File: ${path3.relative(ctx.config.cwd, file)}`);
2348
2348
  const css = extractFile(ctx, file);
2349
2349
  if (!css)
2350
2350
  return;
@@ -2353,18 +2353,18 @@ async function writeFileChunk(ctx, file) {
2353
2353
  }
2354
2354
  function extractFile(ctx, file) {
2355
2355
  const {
2356
- runtime: { path: path4, fs: fs2 },
2356
+ runtime: { path: path3, fs },
2357
2357
  config: { cwd }
2358
2358
  } = ctx;
2359
2359
  return pipe2(
2360
- { file: path4.abs(cwd, file) },
2360
+ { file: path3.abs(cwd, file) },
2361
2361
  tap2(() => logger3.debug("file:extract", file)),
2362
2362
  Obj2.bind("measure", () => logger3.time.debug(`Extracted ${file}`)),
2363
2363
  Obj2.bind(
2364
2364
  "result",
2365
2365
  tryCatch(
2366
2366
  ({ file: file2 }) => {
2367
- return file2.endsWith(".json") ? ParserResult.fromJson(fs2.readFileSync(file2)) : ctx.project.parseSourceFile(file2);
2367
+ return file2.endsWith(".json") ? ParserResult.fromJson(fs.readFileSync(file2)) : ctx.project.parseSourceFile(file2);
2368
2368
  },
2369
2369
  (error) => logger3.error("file:parse", error)
2370
2370
  )
@@ -2401,58 +2401,6 @@ async function extractCss(ctx) {
2401
2401
  return ctx.messages.buildComplete(ctx.getFiles().length);
2402
2402
  }
2403
2403
 
2404
- // src/get-mod-deps.ts
2405
- init_esm_shims();
2406
- import fs from "fs";
2407
- import path from "path";
2408
- var jsExtensions = [".js", ".cjs", ".mjs"];
2409
- var jsResolutionOrder = ["", ".js", ".cjs", ".mjs", ".ts", ".cts", ".mts", ".jsx", ".tsx"];
2410
- var tsResolutionOrder = ["", ".ts", ".cts", ".mts", ".tsx", ".js", ".cjs", ".mjs", ".jsx"];
2411
- function resolveWithExtension(file, extensions) {
2412
- for (const ext of extensions) {
2413
- const full = `${file}${ext}`;
2414
- if (fs.existsSync(full) && fs.statSync(full).isFile()) {
2415
- return full;
2416
- }
2417
- }
2418
- for (const ext of extensions) {
2419
- const full = `${file}/index${ext}`;
2420
- if (fs.existsSync(full)) {
2421
- return full;
2422
- }
2423
- }
2424
- return null;
2425
- }
2426
- function* getDeps(filename, base, seen, ext = path.extname(filename)) {
2427
- const absoluteFile = resolveWithExtension(
2428
- path.resolve(base, filename),
2429
- jsExtensions.includes(ext) ? jsResolutionOrder : tsResolutionOrder
2430
- );
2431
- if (absoluteFile === null)
2432
- return;
2433
- if (seen.has(absoluteFile))
2434
- return;
2435
- seen.add(absoluteFile);
2436
- yield absoluteFile;
2437
- base = path.dirname(absoluteFile);
2438
- ext = path.extname(absoluteFile);
2439
- const contents = fs.readFileSync(absoluteFile, "utf-8");
2440
- for (const match2 of [
2441
- ...contents.matchAll(/import[\s\S]*?['"](.{3,}?)['"]/gi),
2442
- ...contents.matchAll(/import[\s\S]*from[\s\S]*?['"](.{3,}?)['"]/gi),
2443
- ...contents.matchAll(/require\(['"`](.+)['"`]\)/gi)
2444
- ]) {
2445
- if (!match2[1].startsWith("."))
2446
- continue;
2447
- yield* getDeps(match2[1], base, seen, ext);
2448
- }
2449
- }
2450
- function getModuleDependencies(filePath) {
2451
- if (filePath === null)
2452
- return /* @__PURE__ */ new Set();
2453
- return new Set(getDeps(filePath, path.dirname(filePath), /* @__PURE__ */ new Set()));
2454
- }
2455
-
2456
2404
  // src/parse-dependency.ts
2457
2405
  init_esm_shims();
2458
2406
  import isGlob from "is-glob";
@@ -2498,6 +2446,7 @@ function parseDependency(fileOrGlob) {
2498
2446
  }
2499
2447
 
2500
2448
  // src/builder.ts
2449
+ import { getConfigDependencies } from "@pandacss/config";
2501
2450
  var configCache = /* @__PURE__ */ new Map();
2502
2451
  var contentFilesCache = /* @__PURE__ */ new WeakMap();
2503
2452
  var setupCount = 0;
@@ -2542,7 +2491,7 @@ var Builder = class {
2542
2491
  }
2543
2492
  async setup() {
2544
2493
  const configPath = this.getConfigPath();
2545
- const configDeps = getModuleDependencies(configPath);
2494
+ const configDeps = getConfigDependencies(configPath);
2546
2495
  const deps = this.checkConfigDeps(configPath, configDeps);
2547
2496
  if (deps.isModified) {
2548
2497
  return this.setupContext({
@@ -2570,7 +2519,7 @@ var Builder = class {
2570
2519
  }
2571
2520
  configCache.set(configPath, {
2572
2521
  context: this.context,
2573
- deps: new Set(this.context.configDependencies),
2522
+ deps: new Set(this.context.dependencies ?? []),
2574
2523
  depsModifiedMap
2575
2524
  });
2576
2525
  contentFilesCache.set(this.context, {
@@ -2656,7 +2605,7 @@ var Builder = class {
2656
2605
  init_esm_shims();
2657
2606
  import { colors, logger as logger5 } from "@pandacss/logger";
2658
2607
  import { mkdir, writeFile as writeFile3 } from "fs/promises";
2659
- import * as path2 from "path";
2608
+ import * as path from "path";
2660
2609
  async function debugFiles(ctx, options) {
2661
2610
  const files = ctx.getFiles();
2662
2611
  const measureTotal = logger5.time.debug(`Done parsing ${files.length} files`);
@@ -2696,10 +2645,10 @@ async function debugFiles(ctx, options) {
2696
2645
  }
2697
2646
  if (options.outdir) {
2698
2647
  filesWithCss.push(file);
2699
- const parsedPath = path2.parse(file);
2700
- const relative4 = path2.relative(ctx.config.cwd, parsedPath.dir);
2701
- const astJsonPath = `${relative4}/${parsedPath.name}.ast.json`.replaceAll(path2.sep, "__");
2702
- const cssPath = `${relative4}/${parsedPath.name}.css`.replaceAll(path2.sep, "__");
2648
+ const parsedPath = path.parse(file);
2649
+ const relative4 = path.relative(ctx.config.cwd, parsedPath.dir);
2650
+ const astJsonPath = `${relative4}/${parsedPath.name}.ast.json`.replaceAll(path.sep, "__");
2651
+ const cssPath = `${relative4}/${parsedPath.name}.css`.replaceAll(path.sep, "__");
2703
2652
  logger5.info("cli", `Writing ${colors.bold(`${options.outdir}/${astJsonPath}`)}`);
2704
2653
  logger5.info("cli", `Writing ${colors.bold(`${options.outdir}/${cssPath}`)}`);
2705
2654
  return Promise.all([
@@ -2767,22 +2716,22 @@ async function generate(config, configPath) {
2767
2716
  const ctx = ctxRef.current;
2768
2717
  await build(ctx);
2769
2718
  const {
2770
- runtime: { fs: fs2, path: path4 },
2719
+ runtime: { fs, path: path3 },
2771
2720
  dependencies,
2772
2721
  config: { cwd }
2773
2722
  } = ctx;
2774
2723
  if (ctx.config.watch) {
2775
- const configWatcher = fs2.watch({ include: dependencies });
2724
+ const configWatcher = fs.watch({ include: dependencies });
2776
2725
  configWatcher.on("change", async () => {
2777
2726
  logger7.info("config:change", "Config changed, restarting...");
2778
2727
  await loadCtx();
2779
2728
  return build(ctxRef.current);
2780
2729
  });
2781
- const contentWatcher = fs2.watch(ctx.config);
2730
+ const contentWatcher = fs.watch(ctx.config);
2782
2731
  contentWatcher.on("all", async (event, file) => {
2783
2732
  logger7.info(`file:${event}`, file);
2784
2733
  match(event).with("unlink", () => {
2785
- ctx.project.removeSourceFile(path4.abs(cwd, file));
2734
+ ctx.project.removeSourceFile(path3.abs(cwd, file));
2786
2735
  ctx.chunks.rm(file);
2787
2736
  }).with("change", async () => {
2788
2737
  ctx.project.reloadSourceFile(file);
@@ -2881,7 +2830,7 @@ init_esm_shims();
2881
2830
  import { colors as colors2, logger as logger9 } from "@pandacss/logger";
2882
2831
  import { createParserResult } from "@pandacss/parser";
2883
2832
  import { writeFile as writeFile5 } from "fs/promises";
2884
- import * as path3 from "path";
2833
+ import * as path2 from "path";
2885
2834
  async function shipFiles(ctx, outfile) {
2886
2835
  const files = ctx.getFiles();
2887
2836
  const extractResult = createParserResult();
@@ -2894,7 +2843,7 @@ async function shipFiles(ctx, outfile) {
2894
2843
  if (!css)
2895
2844
  return;
2896
2845
  extractResult.merge(result);
2897
- filesWithCss.push(path3.relative(ctx.config.cwd, file));
2846
+ filesWithCss.push(path2.relative(ctx.config.cwd, file));
2898
2847
  });
2899
2848
  logger9.info("cli", `Found ${colors2.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`);
2900
2849
  const minify = ctx.config.minify;
@@ -2913,8 +2862,11 @@ export {
2913
2862
  emitArtifacts,
2914
2863
  execCommand,
2915
2864
  extractCss,
2865
+ extractFile,
2866
+ findConfig,
2916
2867
  generate,
2917
2868
  loadConfigAndCreateContext,
2869
+ parseDependency,
2918
2870
  setupConfig,
2919
2871
  setupGitIgnore,
2920
2872
  setupPostcss,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/node",
3
- "version": "0.0.0-dev-20230530140607",
3
+ "version": "0.0.0-dev-20230530153916",
4
4
  "description": "The core css panda library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -32,17 +32,17 @@
32
32
  "preferred-pm": "^3.0.3",
33
33
  "ts-morph": "18.0.0",
34
34
  "ts-pattern": "4.3.0",
35
- "@pandacss/config": "0.0.0-dev-20230530140607",
36
- "@pandacss/core": "0.0.0-dev-20230530140607",
37
- "@pandacss/error": "0.0.0-dev-20230530140607",
38
- "@pandacss/extractor": "0.0.0-dev-20230530140607",
39
- "@pandacss/generator": "0.0.0-dev-20230530140607",
40
- "@pandacss/is-valid-prop": "0.0.0-dev-20230530140607",
41
- "@pandacss/logger": "0.0.0-dev-20230530140607",
42
- "@pandacss/parser": "0.0.0-dev-20230530140607",
43
- "@pandacss/shared": "0.0.0-dev-20230530140607",
44
- "@pandacss/token-dictionary": "0.0.0-dev-20230530140607",
45
- "@pandacss/types": "0.0.0-dev-20230530140607"
35
+ "@pandacss/config": "0.0.0-dev-20230530153916",
36
+ "@pandacss/core": "0.0.0-dev-20230530153916",
37
+ "@pandacss/error": "0.0.0-dev-20230530153916",
38
+ "@pandacss/extractor": "0.0.0-dev-20230530153916",
39
+ "@pandacss/generator": "0.0.0-dev-20230530153916",
40
+ "@pandacss/is-valid-prop": "0.0.0-dev-20230530153916",
41
+ "@pandacss/logger": "0.0.0-dev-20230530153916",
42
+ "@pandacss/parser": "0.0.0-dev-20230530153916",
43
+ "@pandacss/shared": "0.0.0-dev-20230530153916",
44
+ "@pandacss/token-dictionary": "0.0.0-dev-20230530153916",
45
+ "@pandacss/types": "0.0.0-dev-20230530153916"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/fs-extra": "11.0.1",
@@ -52,7 +52,7 @@
52
52
  "@types/pluralize": "0.0.29",
53
53
  "boxen": "^7.1.0",
54
54
  "gzip-size": "^7.0.0",
55
- "@pandacss/fixture": "0.0.0-dev-20230530140607"
55
+ "@pandacss/fixture": "0.0.0-dev-20230530153916"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "tsup src/index.ts --format=cjs,esm --shims --dts",