@bamboocss/node 1.64.2 → 1.64.4

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.cjs CHANGED
@@ -49,13 +49,11 @@ let chokidar = require("chokidar");
49
49
  chokidar = __toESM(chokidar);
50
50
  let fast_glob = require("fast-glob");
51
51
  fast_glob = __toESM(fast_glob);
52
- let fs_extra = require("fs-extra");
53
- fs_extra = __toESM(fs_extra);
52
+ let node_fs_promises = require("node:fs/promises");
54
53
  let picomatch = require("picomatch");
55
54
  picomatch = __toESM(picomatch);
56
55
  let node_readline = require("node:readline");
57
56
  node_readline = __toESM(node_readline);
58
- let node_fs_promises = require("node:fs/promises");
59
57
  let node_zlib = require("node:zlib");
60
58
  let look_it_up = require("look-it-up");
61
59
  let outdent = require("outdent");
@@ -3570,6 +3568,24 @@ const byOwnBase = (task, cwd) => {
3570
3568
  if (task.base !== "." || task.positive.length < 2) return [task.positive];
3571
3569
  return [...byWalk(task.positive, cwd).values()];
3572
3570
  };
3571
+ /**
3572
+ * Empty `dir` and keep it, creating it when it is not there — what `fs-extra`'s `emptyDirSync`
3573
+ * did. `node:fs` does the rest of what this file needed `fs-extra` for, and `fs-extra` cost every
3574
+ * build about 4 ms to load.
3575
+ */
3576
+ const emptyDirSync = (dir) => {
3577
+ let entries;
3578
+ try {
3579
+ entries = (0, node_fs.readdirSync)(dir);
3580
+ } catch {
3581
+ (0, node_fs.mkdirSync)(dir, { recursive: true });
3582
+ return;
3583
+ }
3584
+ for (const entry of entries) (0, node_fs.rmSync)((0, node_path.join)(dir, entry), {
3585
+ recursive: true,
3586
+ force: true
3587
+ });
3588
+ };
3573
3589
  const nodeRuntime = {
3574
3590
  cwd() {
3575
3591
  return process.cwd();
@@ -3590,9 +3606,9 @@ const nodeRuntime = {
3590
3606
  }
3591
3607
  },
3592
3608
  fs: {
3593
- existsSync: fs_extra.default.existsSync,
3609
+ existsSync: node_fs.existsSync,
3594
3610
  readFileSync(filePath) {
3595
- return fs_extra.default.readFileSync(filePath, "utf8");
3611
+ return (0, node_fs.readFileSync)(filePath, "utf8");
3596
3612
  },
3597
3613
  glob(opts) {
3598
3614
  if (!opts.include) return [];
@@ -3612,16 +3628,21 @@ const nodeRuntime = {
3612
3628
  const files = sortSources(walks.length === 1 ? walks[0] : walks.flat());
3613
3629
  return walks.length > 1 ? files.filter((file, index) => index === 0 || file !== files[index - 1]) : files;
3614
3630
  },
3615
- writeFile: fs_extra.default.writeFile,
3616
- writeFileSync: fs_extra.default.writeFileSync,
3617
- readDirSync: fs_extra.default.readdirSync,
3631
+ writeFile: node_fs_promises.writeFile,
3632
+ writeFileSync: node_fs.writeFileSync,
3633
+ readDirSync: node_fs.readdirSync,
3618
3634
  isDirSync(path) {
3619
- return fs_extra.default.statSync(path, { throwIfNoEntry: false })?.isDirectory() ?? false;
3635
+ return (0, node_fs.statSync)(path, { throwIfNoEntry: false })?.isDirectory() ?? false;
3636
+ },
3637
+ rmDirSync: emptyDirSync,
3638
+ rmFileSync(path) {
3639
+ (0, node_fs.rmSync)(path, {
3640
+ recursive: true,
3641
+ force: true
3642
+ });
3620
3643
  },
3621
- rmDirSync: fs_extra.default.emptyDirSync,
3622
- rmFileSync: fs_extra.default.removeSync,
3623
3644
  ensureDirSync(path) {
3624
- return fs_extra.default.ensureDirSync(path);
3645
+ (0, node_fs.mkdirSync)(path, { recursive: true });
3625
3646
  },
3626
3647
  watch(options) {
3627
3648
  const { include, exclude, cwd, poll } = options;
@@ -5664,6 +5685,48 @@ var Builder = class {
5664
5685
  const bases = this.includeBases(ctx);
5665
5686
  return this.sourcePathsOf(absolutePath).some((source) => bases.some((base) => source === base.path || source.startsWith(base.prefix)) && isSource(this.sourcePath(ctx.runtime.path.relative(ctx.config.cwd, source))));
5666
5687
  };
5688
+ /** The packages the inventory holds files of, by name, for one inventory. @see isSourcePackage */
5689
+ sourcePackages;
5690
+ /**
5691
+ * @internal Whether a package is one the inventory holds files of — a workspace package `include`
5692
+ * reaches, such as a design system imported as `@acme/ds`. `true` before an inventory exists.
5693
+ *
5694
+ * What the Vite compiler asks of a module importing a package by name. A published package ships
5695
+ * its own output, but a call into this one folds against its source, and the compiled source no
5696
+ * longer defines what a module left uncompiled would call. Named as a workspace links a package:
5697
+ * by the nearest `package.json` above each file that has a name.
5698
+ */
5699
+ isSourcePackage = (name) => {
5700
+ const ctx = this.getContextOrThrow();
5701
+ const inventory = this.sourceInventory;
5702
+ if (!inventory) return true;
5703
+ if (this.sourcePackages?.inventory !== inventory) {
5704
+ const nameByDirectory = /* @__PURE__ */ new Map();
5705
+ const packageNameOf = (directory) => {
5706
+ if (nameByDirectory.has(directory)) return nameByDirectory.get(directory);
5707
+ let packageName;
5708
+ const manifest = (0, node_path.resolve)(directory, "package.json");
5709
+ if ((0, node_fs.existsSync)(manifest)) try {
5710
+ const parsed = JSON.parse((0, node_fs.readFileSync)(manifest, "utf8"));
5711
+ if (typeof parsed.name === "string") packageName = parsed.name;
5712
+ } catch {}
5713
+ const parent = (0, node_path.dirname)(directory);
5714
+ if (packageName === void 0 && parent !== directory) packageName = packageNameOf(parent);
5715
+ nameByDirectory.set(directory, packageName);
5716
+ return packageName;
5717
+ };
5718
+ const names = /* @__PURE__ */ new Set();
5719
+ for (const file of inventory) {
5720
+ const packageName = packageNameOf((0, node_path.dirname)(this.absOwner(ctx, file)));
5721
+ if (packageName) names.add(packageName);
5722
+ }
5723
+ this.sourcePackages = {
5724
+ inventory,
5725
+ names
5726
+ };
5727
+ }
5728
+ return this.sourcePackages.names.has(name);
5729
+ };
5667
5730
  /** The folders each context's `include` is globbed from. @see isPotentialSourceFile */
5668
5731
  includeBaseCache = /* @__PURE__ */ new WeakMap();
5669
5732
  includeBases = (ctx) => {
@@ -6411,6 +6474,8 @@ async function debug(ctx, options) {
6411
6474
  const archive = options.zip && outdir ? `${path.resolve(outdir)}.zip` : void 0;
6412
6475
  const entries = [];
6413
6476
  const writes = [];
6477
+ const { default: pLimit } = await import("p-limit");
6478
+ const limit = pLimit(20);
6414
6479
  const write = (name, content) => {
6415
6480
  if (options.zip) {
6416
6481
  entries.push({
@@ -6420,7 +6485,7 @@ async function debug(ctx, options) {
6420
6485
  return;
6421
6486
  }
6422
6487
  _bamboocss_logger.logger.info("cli", `Writing ${_bamboocss_logger.colors.bold(`${outdir}/${name}`)}`);
6423
- writes.push(fs.writeFile(`${outdir}${path.sep}${name}`, content));
6488
+ writes.push(limit(() => fs.writeFile(`${outdir}${path.sep}${name}`, content)));
6424
6489
  };
6425
6490
  const finish = async () => {
6426
6491
  const failed = (await Promise.allSettled(writes)).flatMap((write) => write.status === "rejected" ? [write.reason] : []);
@@ -6798,7 +6863,7 @@ strictValues: ${JSON.stringify(strictValues)},\n` : ""}
6798
6863
  })
6799
6864
  `;
6800
6865
  const filePath = (0, node_path.join)(cwd, file);
6801
- await fs_extra.default.writeFile(filePath, content);
6866
+ await (0, node_fs_promises.writeFile)(filePath, content);
6802
6867
  try {
6803
6868
  (0, node_child_process.execFileSync)("oxfmt", [filePath], { stdio: "ignore" });
6804
6869
  } catch {}
package/dist/index.d.cts CHANGED
@@ -950,6 +950,18 @@ declare class Builder {
950
950
  * compiling it is wasted — and with the TypeScript 7 backend, far from free.
951
951
  */
952
952
  isPotentialSourceFile: (filePath: string) => boolean;
953
+ /** The packages the inventory holds files of, by name, for one inventory. @see isSourcePackage */
954
+ private sourcePackages;
955
+ /**
956
+ * @internal Whether a package is one the inventory holds files of — a workspace package `include`
957
+ * reaches, such as a design system imported as `@acme/ds`. `true` before an inventory exists.
958
+ *
959
+ * What the Vite compiler asks of a module importing a package by name. A published package ships
960
+ * its own output, but a call into this one folds against its source, and the compiled source no
961
+ * longer defines what a module left uncompiled would call. Named as a workspace links a package:
962
+ * by the nearest `package.json` above each file that has a name.
963
+ */
964
+ isSourcePackage: (name: string) => boolean;
953
965
  /** The folders each context's `include` is globbed from. @see isPotentialSourceFile */
954
966
  private includeBaseCache;
955
967
  private includeBases;
package/dist/index.d.mts CHANGED
@@ -950,6 +950,18 @@ declare class Builder {
950
950
  * compiling it is wasted — and with the TypeScript 7 backend, far from free.
951
951
  */
952
952
  isPotentialSourceFile: (filePath: string) => boolean;
953
+ /** The packages the inventory holds files of, by name, for one inventory. @see isSourcePackage */
954
+ private sourcePackages;
955
+ /**
956
+ * @internal Whether a package is one the inventory holds files of — a workspace package `include`
957
+ * reaches, such as a design system imported as `@acme/ds`. `true` before an inventory exists.
958
+ *
959
+ * What the Vite compiler asks of a module importing a package by name. A published package ships
960
+ * its own output, but a call into this one folds against its source, and the compiled source no
961
+ * longer defines what a module left uncompiled would call. Named as a workspace links a package:
962
+ * by the nearest `package.json` above each file that has a name.
963
+ */
964
+ isSourcePackage: (name: string) => boolean;
953
965
  /** The folders each context's `include` is globbed from. @see isPotentialSourceFile */
954
966
  private includeBaseCache;
955
967
  private includeBases;
package/dist/index.mjs CHANGED
@@ -4,7 +4,7 @@ import { colors, logger, quote } from "@bamboocss/logger";
4
4
  import { checkNamingAgreement, formatNamingDisagreement, messages, prunesPreflight } from "@bamboocss/core";
5
5
  import { BambooError, cssVarRefs, getOrCreateSet, groupBy, truncateList, uniq } from "@bamboocss/shared";
6
6
  import { isMatch } from "matcher";
7
- import fs, { appendFileSync, existsSync, readFileSync, readdirSync, realpathSync, statSync, writeFileSync } from "node:fs";
7
+ import fs, { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
8
8
  import { changesEveryArtifact, convertTsPathsToRegexes, diffConfigs, filesReadBy, findConfig, getConfigDependencies, loadConfig, mergeHooks } from "@bamboocss/config";
9
9
  import path, { basename, dirname, extname, isAbsolute, join, normalize, parse, posix, relative, resolve, sep } from "node:path";
10
10
  import { pluginSvelte } from "@bamboocss/plugin-svelte";
@@ -18,10 +18,9 @@ import tty from "node:tty";
18
18
  import { declaresAliases, findClosestTsconfig, globBase, includesUnder, isSolutionTsconfig, isSourceFileIncludedInTsconfig, readTsconfigGraph, resolveDirectTsconfigJson, resolvePathsBase } from "@bamboocss/config/tsconfig";
19
19
  import chokidar from "chokidar";
20
20
  import glob from "fast-glob";
21
- import fsExtra from "fs-extra";
21
+ import { writeFile } from "node:fs/promises";
22
22
  import picomatch from "picomatch";
23
23
  import readline from "node:readline";
24
- import { writeFile } from "node:fs/promises";
25
24
  import { crc32, deflateRawSync } from "node:zlib";
26
25
  import { lookItUpSync } from "look-it-up";
27
26
  import outdent$1, { outdent } from "outdent";
@@ -3558,6 +3557,24 @@ const byOwnBase = (task, cwd) => {
3558
3557
  if (task.base !== "." || task.positive.length < 2) return [task.positive];
3559
3558
  return [...byWalk(task.positive, cwd).values()];
3560
3559
  };
3560
+ /**
3561
+ * Empty `dir` and keep it, creating it when it is not there — what `fs-extra`'s `emptyDirSync`
3562
+ * did. `node:fs` does the rest of what this file needed `fs-extra` for, and `fs-extra` cost every
3563
+ * build about 4 ms to load.
3564
+ */
3565
+ const emptyDirSync = (dir) => {
3566
+ let entries;
3567
+ try {
3568
+ entries = readdirSync(dir);
3569
+ } catch {
3570
+ mkdirSync(dir, { recursive: true });
3571
+ return;
3572
+ }
3573
+ for (const entry of entries) rmSync(join(dir, entry), {
3574
+ recursive: true,
3575
+ force: true
3576
+ });
3577
+ };
3561
3578
  const nodeRuntime = {
3562
3579
  cwd() {
3563
3580
  return process.cwd();
@@ -3578,9 +3595,9 @@ const nodeRuntime = {
3578
3595
  }
3579
3596
  },
3580
3597
  fs: {
3581
- existsSync: fsExtra.existsSync,
3598
+ existsSync,
3582
3599
  readFileSync(filePath) {
3583
- return fsExtra.readFileSync(filePath, "utf8");
3600
+ return readFileSync(filePath, "utf8");
3584
3601
  },
3585
3602
  glob(opts) {
3586
3603
  if (!opts.include) return [];
@@ -3600,16 +3617,21 @@ const nodeRuntime = {
3600
3617
  const files = sortSources(walks.length === 1 ? walks[0] : walks.flat());
3601
3618
  return walks.length > 1 ? files.filter((file, index) => index === 0 || file !== files[index - 1]) : files;
3602
3619
  },
3603
- writeFile: fsExtra.writeFile,
3604
- writeFileSync: fsExtra.writeFileSync,
3605
- readDirSync: fsExtra.readdirSync,
3620
+ writeFile,
3621
+ writeFileSync,
3622
+ readDirSync: readdirSync,
3606
3623
  isDirSync(path) {
3607
- return fsExtra.statSync(path, { throwIfNoEntry: false })?.isDirectory() ?? false;
3624
+ return statSync(path, { throwIfNoEntry: false })?.isDirectory() ?? false;
3625
+ },
3626
+ rmDirSync: emptyDirSync,
3627
+ rmFileSync(path) {
3628
+ rmSync(path, {
3629
+ recursive: true,
3630
+ force: true
3631
+ });
3608
3632
  },
3609
- rmDirSync: fsExtra.emptyDirSync,
3610
- rmFileSync: fsExtra.removeSync,
3611
3633
  ensureDirSync(path) {
3612
- return fsExtra.ensureDirSync(path);
3634
+ mkdirSync(path, { recursive: true });
3613
3635
  },
3614
3636
  watch(options) {
3615
3637
  const { include, exclude, cwd, poll } = options;
@@ -5652,6 +5674,48 @@ var Builder = class {
5652
5674
  const bases = this.includeBases(ctx);
5653
5675
  return this.sourcePathsOf(absolutePath).some((source) => bases.some((base) => source === base.path || source.startsWith(base.prefix)) && isSource(this.sourcePath(ctx.runtime.path.relative(ctx.config.cwd, source))));
5654
5676
  };
5677
+ /** The packages the inventory holds files of, by name, for one inventory. @see isSourcePackage */
5678
+ sourcePackages;
5679
+ /**
5680
+ * @internal Whether a package is one the inventory holds files of — a workspace package `include`
5681
+ * reaches, such as a design system imported as `@acme/ds`. `true` before an inventory exists.
5682
+ *
5683
+ * What the Vite compiler asks of a module importing a package by name. A published package ships
5684
+ * its own output, but a call into this one folds against its source, and the compiled source no
5685
+ * longer defines what a module left uncompiled would call. Named as a workspace links a package:
5686
+ * by the nearest `package.json` above each file that has a name.
5687
+ */
5688
+ isSourcePackage = (name) => {
5689
+ const ctx = this.getContextOrThrow();
5690
+ const inventory = this.sourceInventory;
5691
+ if (!inventory) return true;
5692
+ if (this.sourcePackages?.inventory !== inventory) {
5693
+ const nameByDirectory = /* @__PURE__ */ new Map();
5694
+ const packageNameOf = (directory) => {
5695
+ if (nameByDirectory.has(directory)) return nameByDirectory.get(directory);
5696
+ let packageName;
5697
+ const manifest = resolve(directory, "package.json");
5698
+ if (existsSync(manifest)) try {
5699
+ const parsed = JSON.parse(readFileSync(manifest, "utf8"));
5700
+ if (typeof parsed.name === "string") packageName = parsed.name;
5701
+ } catch {}
5702
+ const parent = dirname(directory);
5703
+ if (packageName === void 0 && parent !== directory) packageName = packageNameOf(parent);
5704
+ nameByDirectory.set(directory, packageName);
5705
+ return packageName;
5706
+ };
5707
+ const names = /* @__PURE__ */ new Set();
5708
+ for (const file of inventory) {
5709
+ const packageName = packageNameOf(dirname(this.absOwner(ctx, file)));
5710
+ if (packageName) names.add(packageName);
5711
+ }
5712
+ this.sourcePackages = {
5713
+ inventory,
5714
+ names
5715
+ };
5716
+ }
5717
+ return this.sourcePackages.names.has(name);
5718
+ };
5655
5719
  /** The folders each context's `include` is globbed from. @see isPotentialSourceFile */
5656
5720
  includeBaseCache = /* @__PURE__ */ new WeakMap();
5657
5721
  includeBases = (ctx) => {
@@ -6399,6 +6463,8 @@ async function debug(ctx, options) {
6399
6463
  const archive = options.zip && outdir ? `${path.resolve(outdir)}.zip` : void 0;
6400
6464
  const entries = [];
6401
6465
  const writes = [];
6466
+ const { default: pLimit } = await import("p-limit");
6467
+ const limit = pLimit(20);
6402
6468
  const write = (name, content) => {
6403
6469
  if (options.zip) {
6404
6470
  entries.push({
@@ -6408,7 +6474,7 @@ async function debug(ctx, options) {
6408
6474
  return;
6409
6475
  }
6410
6476
  logger.info("cli", `Writing ${colors.bold(`${outdir}/${name}`)}`);
6411
- writes.push(fs.writeFile(`${outdir}${path.sep}${name}`, content));
6477
+ writes.push(limit(() => fs.writeFile(`${outdir}${path.sep}${name}`, content)));
6412
6478
  };
6413
6479
  const finish = async () => {
6414
6480
  const failed = (await Promise.allSettled(writes)).flatMap((write) => write.status === "rejected" ? [write.reason] : []);
@@ -6786,7 +6852,7 @@ strictValues: ${JSON.stringify(strictValues)},\n` : ""}
6786
6852
  })
6787
6853
  `;
6788
6854
  const filePath = join(cwd, file);
6789
- await fsExtra.writeFile(filePath, content);
6855
+ await writeFile(filePath, content);
6790
6856
  try {
6791
6857
  execFileSync("oxfmt", [filePath], { stdio: "ignore" });
6792
6858
  } catch {}
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bamboocss/node",
3
- "version": "1.64.2",
3
+ "version": "1.64.4",
4
4
  "description": "The core css bamboo library",
5
5
  "homepage": "https://bamboocss.com",
6
6
  "license": "MIT",
@@ -48,7 +48,6 @@
48
48
  "dependencies": {
49
49
  "chokidar": "5.0.0",
50
50
  "fast-glob": "3.3.3",
51
- "fs-extra": "11.3.2",
52
51
  "lodash.merge": "4.6.2",
53
52
  "look-it-up": "2.1.0",
54
53
  "matcher": "6.0.0",
@@ -60,24 +59,23 @@
60
59
  "pkg-types": "2.3.0",
61
60
  "pluralize": "8.0.0",
62
61
  "ts-pattern": "5.9.0",
63
- "@bamboocss/config": "1.64.2",
64
- "@bamboocss/core": "1.64.2",
65
- "@bamboocss/generator": "1.64.2",
66
- "@bamboocss/logger": "1.64.2",
67
- "@bamboocss/plugin-svelte": "1.64.2",
68
- "@bamboocss/plugin-vue": "1.64.2",
69
- "@bamboocss/reporter": "1.64.2",
70
- "@bamboocss/shared": "1.64.2",
71
- "@bamboocss/token-dictionary": "1.64.2",
72
- "@bamboocss/types": "1.64.2"
62
+ "@bamboocss/config": "1.64.4",
63
+ "@bamboocss/core": "1.64.4",
64
+ "@bamboocss/generator": "1.64.4",
65
+ "@bamboocss/logger": "1.64.4",
66
+ "@bamboocss/plugin-svelte": "1.64.4",
67
+ "@bamboocss/plugin-vue": "1.64.4",
68
+ "@bamboocss/reporter": "1.64.4",
69
+ "@bamboocss/shared": "1.64.4",
70
+ "@bamboocss/token-dictionary": "1.64.4",
71
+ "@bamboocss/types": "1.64.4"
73
72
  },
74
73
  "devDependencies": {
75
74
  "@astrojs/compiler": "3.0.1",
76
75
  "@astrojs/compiler-rs": "0.5.1",
77
- "@types/fs-extra": "11.0.4",
78
76
  "@types/picomatch": "4.0.2",
79
77
  "boxen": "8.0.1",
80
- "@bamboocss/native-extractor": "1.64.2"
78
+ "@bamboocss/native-extractor": "1.64.4"
81
79
  },
82
80
  "peerDependencies": {
83
81
  "@astrojs/compiler": ">=2",