@bamboocss/node 1.48.0 → 1.48.1

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
@@ -30,6 +30,8 @@ let _bamboocss_shared = require("@bamboocss/shared");
30
30
  let node_crypto = require("node:crypto");
31
31
  let fs = require("fs");
32
32
  let path = require("path");
33
+ let picomatch = require("picomatch");
34
+ picomatch = __toESM(picomatch);
33
35
  let _bamboocss_plugin_svelte = require("@bamboocss/plugin-svelte");
34
36
  let _bamboocss_plugin_vue = require("@bamboocss/plugin-vue");
35
37
  let _bamboocss_core = require("@bamboocss/core");
@@ -53,8 +55,6 @@ let fast_glob = require("fast-glob");
53
55
  fast_glob = __toESM(fast_glob);
54
56
  let fs_extra = require("fs-extra");
55
57
  fs_extra = __toESM(fs_extra);
56
- let picomatch = require("picomatch");
57
- picomatch = __toESM(picomatch);
58
58
  let matcher = require("matcher");
59
59
  let _bamboocss_config_ts_path = require("@bamboocss/config/ts-path");
60
60
  let node_readline = require("node:readline");
@@ -3351,6 +3351,26 @@ var Builder = class {
3351
3351
  ]) for (const dependencies of readSets.values()) for (const dependency of dependencies) files.add(dependency);
3352
3352
  return Object.freeze([...files].sort());
3353
3353
  };
3354
+ /** @internal The inventory reconciled by the most recent extraction pass. */
3355
+ getSourceFiles = () => Object.freeze([...this.sourceInventory ?? []]);
3356
+ /** @internal Whether creating this path can change source or explicit-dependency membership. */
3357
+ isPotentialSourceFile = (filePath) => {
3358
+ const ctx = this.getContextOrThrow();
3359
+ const absolutePath = this.absOwner(ctx, filePath);
3360
+ const relativePath = this.sourcePath(ctx.runtime.path.relative(ctx.config.cwd, absolutePath));
3361
+ const sourcePatterns = ctx.config.include ?? [];
3362
+ const sourceMatcher = sourcePatterns.length ? (0, picomatch.default)(sourcePatterns, { ignore: globIgnore(ctx.config.exclude) }) : void 0;
3363
+ return sourceMatcher?.(relativePath) || sourceMatcher?.(absolutePath) || false;
3364
+ };
3365
+ /** @internal Whether creating or deleting this path can change a `dependencies` glob. */
3366
+ isPotentialConfigDependency = (filePath) => {
3367
+ const ctx = this.getContextOrThrow();
3368
+ const absolutePath = this.absOwner(ctx, filePath);
3369
+ const relativePath = this.sourcePath(ctx.runtime.path.relative(ctx.config.cwd, absolutePath));
3370
+ const patterns = ctx.config.dependencies ?? [];
3371
+ const matcher = patterns.length ? (0, picomatch.default)(patterns) : void 0;
3372
+ return matcher?.(relativePath) || matcher?.(absolutePath) || false;
3373
+ };
3354
3374
  /** @internal Exact local package/tsconfig files which can change semantic resolution. */
3355
3375
  getResolutionConfigurationFiles = () => {
3356
3376
  const files = /* @__PURE__ */ new Set();
@@ -3365,7 +3385,7 @@ var Builder = class {
3365
3385
  throw error;
3366
3386
  }
3367
3387
  };
3368
- changedResolutionConfigurations = () => this.getResolutionConfigurationFiles().filter((file) => this.resolutionConfigurationBytes.get(file) !== this.readResolutionConfiguration(file));
3388
+ changedResolutionConfigurations = (knownChanges) => this.getResolutionConfigurationFiles().filter((file) => (!knownChanges || knownChanges.has(this.sourcePath(file))) && this.resolutionConfigurationBytes.get(file) !== this.readResolutionConfiguration(file));
3369
3389
  snapshotResolutionConfigurations = () => {
3370
3390
  const current = new Set(this.getResolutionConfigurationFiles());
3371
3391
  for (const file of current) this.resolutionConfigurationBytes.set(file, this.readResolutionConfiguration(file));
@@ -3384,6 +3404,7 @@ var Builder = class {
3384
3404
  dev: options.dev
3385
3405
  });
3386
3406
  const ctx = this.getContextOrThrow();
3407
+ const previousExplicitDeps = [...ctx.explicitDeps];
3387
3408
  const previousTsconfigFiles = this.tsconfigResolutionFiles.length ? this.tsconfigResolutionFiles : ctx.diff.getResolutionConfigFiles();
3388
3409
  /**
3389
3410
  * Dev fast path: skip the config reload when nothing that can change the resolved config
@@ -3402,24 +3423,33 @@ var Builder = class {
3402
3423
  * preset external to the config bundle — and a one-shot build keeps paying the reload
3403
3424
  * rather than trading that recovery for a latency only watch mode feels.
3404
3425
  */
3405
- if (options.dev && this.configGraphUnchanged(configPath)) {
3426
+ if (options.dev && this.configGraphUnchanged(configPath, options.sourceChanges)) {
3406
3427
  this.affecteds = {
3407
3428
  artifacts: /* @__PURE__ */ new Set(),
3408
3429
  hasConfigChanged: false,
3409
3430
  diffs: []
3410
3431
  };
3411
3432
  this.explicitDepsMeta = this.checkFilesChanged(this.context.explicitDeps);
3412
- this.refreshSourceState(ctx, previousTsconfigFiles);
3433
+ this.refreshSourceState(ctx, previousTsconfigFiles, options.sourceChanges);
3413
3434
  return;
3414
3435
  }
3415
3436
  this.affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
3416
3437
  this.context = new BambooContext(conf);
3417
3438
  });
3418
3439
  const nextContext = this.getContextOrThrow();
3440
+ if (options.sourceChanges?.needsConfigReload) {
3441
+ const { cwd: configCwd, dependencies } = nextContext.config;
3442
+ nextContext.explicitDeps = dependencies ? nextContext.runtime.fs.glob({
3443
+ include: dependencies,
3444
+ cwd: configCwd
3445
+ }) : [];
3446
+ }
3419
3447
  this.recordConfigDependencies(nextContext, options.cwd);
3420
3448
  this.tsconfigResolutionFiles = nextContext.diff.getResolutionConfigFiles();
3421
3449
  _bamboocss_logger.logger.debug("builder", this.affecteds);
3422
- this.explicitDepsMeta = this.checkFilesChanged(this.context.explicitDeps);
3450
+ const explicitDeps = options.sourceChanges?.needsConfigReload ? (0, _bamboocss_shared.uniq)([...previousExplicitDeps, ...this.context.explicitDeps]) : this.context.explicitDeps;
3451
+ const knownChanges = options.sourceChanges ? new Set(options.sourceChanges.files.map((file) => this.absOwner(this.context, file))) : void 0;
3452
+ this.explicitDepsMeta = this.checkFilesChanged(explicitDeps, knownChanges);
3423
3453
  if (this.explicitDepsMeta.hasFilesChanged) {
3424
3454
  this.explicitDepsMeta.changes.forEach((meta, file) => {
3425
3455
  fileModifiedMap.set(file, meta.mtime);
@@ -3449,7 +3479,7 @@ var Builder = class {
3449
3479
  this.snapshotConfigGraphMtimes(configPath);
3450
3480
  return;
3451
3481
  }
3452
- this.refreshSourceState(ctx, previousTsconfigFiles);
3482
+ this.refreshSourceState(ctx, previousTsconfigFiles, options.sourceChanges);
3453
3483
  this.snapshotConfigGraphMtimes(configPath);
3454
3484
  };
3455
3485
  /** Every file whose content participates in the resolved config, for the dev fast path. */
@@ -3459,10 +3489,13 @@ var Builder = class {
3459
3489
  ...this.tsconfigResolutionFiles,
3460
3490
  ...this.context?.explicitDeps ?? []
3461
3491
  ].map(path.normalize));
3462
- configGraphUnchanged = (configPath) => {
3492
+ configGraphUnchanged = (configPath, sourceChanges) => {
3463
3493
  const snapshot = this.configGraphMtimes;
3464
3494
  if (!snapshot) return false;
3495
+ if (sourceChanges?.needsConfigReload) return false;
3496
+ const changed = sourceChanges ? new Set(sourceChanges.files.map((file) => this.sourcePath((0, path.resolve)(this.context?.config.cwd ?? "", file)))) : void 0;
3465
3497
  for (const file of this.configGraphFiles(configPath)) {
3498
+ if (changed?.has(this.sourcePath((0, path.resolve)(this.context?.config.cwd ?? "", file)))) return false;
3466
3499
  const recorded = snapshot.get(file);
3467
3500
  if (recorded === void 0 || recorded !== this.getFileMeta(file).mtime) return false;
3468
3501
  }
@@ -3474,8 +3507,9 @@ var Builder = class {
3474
3507
  this.configGraphMtimes = snapshot;
3475
3508
  };
3476
3509
  /** The per-pass source bookkeeping every setup ends with, config reload or not. */
3477
- refreshSourceState = (ctx, previousTsconfigFiles) => {
3478
- const changedResolutionConfigurations = this.changedResolutionConfigurations();
3510
+ refreshSourceState = (ctx, previousTsconfigFiles, sourceChanges) => {
3511
+ const knownChanges = sourceChanges ? new Set(sourceChanges.files.map((file) => this.absOwner(ctx, file))) : void 0;
3512
+ const changedResolutionConfigurations = this.changedResolutionConfigurations(knownChanges);
3479
3513
  const changedResolutionSet = new Set(changedResolutionConfigurations);
3480
3514
  const resolutionAffected = /* @__PURE__ */ new Set();
3481
3515
  const resolutionLedger = this.capturedLedger ?? (changedResolutionConfigurations.length ? ctx.project.getResolutionLedger() : void 0);
@@ -3487,14 +3521,21 @@ var Builder = class {
3487
3521
  const replaceCompilerOptions = changedResolutionConfigurations.some((file) => tsconfigCandidates.has(file));
3488
3522
  ctx.project.refreshResolutionConfiguration(ctx.conf.tsconfig?.compilerOptions, this.tsconfigResolutionFiles, replaceCompilerOptions);
3489
3523
  }
3490
- const inventory = ctx.getFiles();
3491
- const tracked = (0, _bamboocss_shared.uniq)([
3524
+ const needsInventoryScan = !sourceChanges || sourceChanges.needsInventoryScan || this.sourceInventory === void 0;
3525
+ const inventory = needsInventoryScan ? ctx.getFiles() : [...this.sourceInventory];
3526
+ const allTracked = (0, _bamboocss_shared.uniq)([
3492
3527
  ...this.sourceInventory ?? inventory,
3493
3528
  ...inventory,
3494
3529
  ...this.getResolutionReadFiles()
3495
3530
  ]);
3496
- this.filesMeta = this.checkFilesChanged(tracked);
3497
- if (this.filesMeta.hasFilesChanged) {
3531
+ const trackedPaths = new Set(allTracked.map((file) => this.absOwner(ctx, file)));
3532
+ const tracked = knownChanges && !needsInventoryScan ? [...knownChanges].filter((file) => trackedPaths.has(file)) : allTracked;
3533
+ this.filesMeta = tracked.length ? this.checkFilesChanged(tracked, knownChanges) : changedResolutionConfigurations.length ? {
3534
+ changes: /* @__PURE__ */ new Map(),
3535
+ hasFilesChanged: false
3536
+ } : void 0;
3537
+ for (const [file, meta] of this.filesMeta?.changes ?? []) if (!meta.isUnchanged) this.sourceScanCache.entries.delete(this.absOwner(ctx, file));
3538
+ if (this.filesMeta?.hasFilesChanged) {
3498
3539
  _bamboocss_logger.logger.debug("builder", "Files changed, invalidating them");
3499
3540
  this.invalidateChangedSources(ctx, inventory, resolutionAffected, resolutionLedger);
3500
3541
  } else if (changedResolutionConfigurations.length) {
@@ -3672,11 +3713,12 @@ var Builder = class {
3672
3713
  isUnchanged: fileModifiedMap.has(file) && mtime === fileModifiedMap.get(file)
3673
3714
  };
3674
3715
  };
3675
- checkFilesChanged(files) {
3716
+ checkFilesChanged(files, knownChanges) {
3676
3717
  const changes = /* @__PURE__ */ new Map();
3677
3718
  let hasFilesChanged = false;
3678
3719
  for (const file of files) {
3679
3720
  const meta = this.getFileMeta(file);
3721
+ if (knownChanges?.has(this.sourcePath(file))) meta.isUnchanged = false;
3680
3722
  changes.set(file, meta);
3681
3723
  if (!meta.isUnchanged) hasFilesChanged = true;
3682
3724
  }
@@ -3769,7 +3811,10 @@ var Builder = class {
3769
3811
  for (const file of filesToExtract) this.extractFile(ctx, file);
3770
3812
  done();
3771
3813
  this.sourceInventory = [...files];
3772
- for (const file of (0, _bamboocss_shared.uniq)([...files, ...this.getResolutionReadFiles()])) fileModifiedMap.set(file, this.getFileMeta(file).mtime);
3814
+ for (const file of (0, _bamboocss_shared.uniq)([...files, ...this.getResolutionReadFiles()])) {
3815
+ const mtime = this.filesMeta?.changes.get(file)?.mtime ?? fileModifiedMap.get(file) ?? this.getFileMeta(file).mtime;
3816
+ fileModifiedMap.set(file, mtime);
3817
+ }
3773
3818
  this.snapshotResolutionConfigurations();
3774
3819
  this.affectedFiles = void 0;
3775
3820
  this.extractionOrder = void 0;
@@ -3789,7 +3834,7 @@ var Builder = class {
3789
3834
  const sheet = assembleExtractedSheet(ctx, {
3790
3835
  layerParams,
3791
3836
  sourceScanCache: this.sourceScanCache,
3792
- mtimeOf: (filePath) => this.filesMeta?.changes.get(filePath)?.mtime,
3837
+ mtimeOf: (filePath) => this.filesMeta?.changes.get(filePath)?.mtime ?? fileModifiedMap.get(filePath),
3793
3838
  sourceInventory: this.sourceInventory
3794
3839
  });
3795
3840
  return ctx.getCss(sheet);
package/dist/index.d.cts CHANGED
@@ -216,6 +216,22 @@ declare function analyze(ctx: BambooContext, options?: AnalysisOptions): {
216
216
  declare function buildInfo(ctx: BambooContext, outfile: string): Promise<void>;
217
217
  //#endregion
218
218
  //#region src/builder.d.ts
219
+ /** Files a watcher knows moved since the previous setup. Omit this to retain filesystem discovery. */
220
+ interface BuilderSourceChanges {
221
+ /** Absolute or cwd-relative paths. An empty list authoritatively means no source moved. */
222
+ files: readonly string[];
223
+ /** Additions and deletions can change glob membership, so they still reconcile the inventory. */
224
+ needsInventoryScan?: boolean;
225
+ /** A `dependencies` glob gained or lost a member and must be expanded before config diffing. */
226
+ needsConfigReload?: boolean;
227
+ }
228
+ interface BuilderSetupOptions {
229
+ configPath?: string;
230
+ cwd?: string;
231
+ dev?: boolean;
232
+ /** A watcher-owned change journal. Without one, Builder performs its standalone filesystem scan. */
233
+ sourceChanges?: BuilderSourceChanges;
234
+ }
219
235
  declare class Builder {
220
236
  /**
221
237
  * The current bamboo context
@@ -281,17 +297,19 @@ declare class Builder {
281
297
  private captureResolutionLedger;
282
298
  /** @internal Current and missing resolver paths which can change the stylesheet. */
283
299
  getResolutionReadFiles: () => readonly string[];
300
+ /** @internal The inventory reconciled by the most recent extraction pass. */
301
+ getSourceFiles: () => readonly string[];
302
+ /** @internal Whether creating this path can change source or explicit-dependency membership. */
303
+ isPotentialSourceFile: (filePath: string) => boolean;
304
+ /** @internal Whether creating or deleting this path can change a `dependencies` glob. */
305
+ isPotentialConfigDependency: (filePath: string) => boolean;
284
306
  /** @internal Exact local package/tsconfig files which can change semantic resolution. */
285
307
  getResolutionConfigurationFiles: () => readonly string[];
286
308
  private readResolutionConfiguration;
287
309
  private changedResolutionConfigurations;
288
310
  private snapshotResolutionConfigurations;
289
311
  private recordConfigDependencies;
290
- setup: (options?: {
291
- configPath?: string;
292
- cwd?: string;
293
- dev?: boolean;
294
- }) => Promise<BambooContext | undefined>;
312
+ setup: (options?: BuilderSetupOptions) => Promise<BambooContext | undefined>;
295
313
  /** Every file whose content participates in the resolved config, for the dev fast path. */
296
314
  private configGraphFiles;
297
315
  private configGraphUnchanged;
@@ -348,7 +366,7 @@ declare class Builder {
348
366
  mtime: number;
349
367
  isUnchanged: boolean;
350
368
  };
351
- checkFilesChanged(files: string[]): {
369
+ checkFilesChanged(files: readonly string[], knownChanges?: ReadonlySet<string>): {
352
370
  changes: Map<string, FileMeta>;
353
371
  hasFilesChanged: boolean;
354
372
  };
@@ -463,4 +481,4 @@ declare const hasUncompilableSources: (options: {
463
481
  include?: readonly string[];
464
482
  }) => boolean;
465
483
  //#endregion
466
- export { BambooContext, Builder, type CssGenOptions, analyze, buildInfo, codegen, cssgen, debug, findViteConfig, generate, generatePackageExports, hasUncompilableSources, isStaticCompilerActive, loadConfigAndCreateContext, markStaticCompilerActive, setLogStream, setupConfig, setupGitIgnore, spec, startProfiling };
484
+ export { BambooContext, Builder, type BuilderSetupOptions, type BuilderSourceChanges, type CssGenOptions, analyze, buildInfo, codegen, cssgen, debug, findViteConfig, generate, generatePackageExports, hasUncompilableSources, isStaticCompilerActive, loadConfigAndCreateContext, markStaticCompilerActive, setLogStream, setupConfig, setupGitIgnore, spec, startProfiling };
package/dist/index.d.mts CHANGED
@@ -216,6 +216,22 @@ declare function analyze(ctx: BambooContext, options?: AnalysisOptions): {
216
216
  declare function buildInfo(ctx: BambooContext, outfile: string): Promise<void>;
217
217
  //#endregion
218
218
  //#region src/builder.d.ts
219
+ /** Files a watcher knows moved since the previous setup. Omit this to retain filesystem discovery. */
220
+ interface BuilderSourceChanges {
221
+ /** Absolute or cwd-relative paths. An empty list authoritatively means no source moved. */
222
+ files: readonly string[];
223
+ /** Additions and deletions can change glob membership, so they still reconcile the inventory. */
224
+ needsInventoryScan?: boolean;
225
+ /** A `dependencies` glob gained or lost a member and must be expanded before config diffing. */
226
+ needsConfigReload?: boolean;
227
+ }
228
+ interface BuilderSetupOptions {
229
+ configPath?: string;
230
+ cwd?: string;
231
+ dev?: boolean;
232
+ /** A watcher-owned change journal. Without one, Builder performs its standalone filesystem scan. */
233
+ sourceChanges?: BuilderSourceChanges;
234
+ }
219
235
  declare class Builder {
220
236
  /**
221
237
  * The current bamboo context
@@ -281,17 +297,19 @@ declare class Builder {
281
297
  private captureResolutionLedger;
282
298
  /** @internal Current and missing resolver paths which can change the stylesheet. */
283
299
  getResolutionReadFiles: () => readonly string[];
300
+ /** @internal The inventory reconciled by the most recent extraction pass. */
301
+ getSourceFiles: () => readonly string[];
302
+ /** @internal Whether creating this path can change source or explicit-dependency membership. */
303
+ isPotentialSourceFile: (filePath: string) => boolean;
304
+ /** @internal Whether creating or deleting this path can change a `dependencies` glob. */
305
+ isPotentialConfigDependency: (filePath: string) => boolean;
284
306
  /** @internal Exact local package/tsconfig files which can change semantic resolution. */
285
307
  getResolutionConfigurationFiles: () => readonly string[];
286
308
  private readResolutionConfiguration;
287
309
  private changedResolutionConfigurations;
288
310
  private snapshotResolutionConfigurations;
289
311
  private recordConfigDependencies;
290
- setup: (options?: {
291
- configPath?: string;
292
- cwd?: string;
293
- dev?: boolean;
294
- }) => Promise<BambooContext | undefined>;
312
+ setup: (options?: BuilderSetupOptions) => Promise<BambooContext | undefined>;
295
313
  /** Every file whose content participates in the resolved config, for the dev fast path. */
296
314
  private configGraphFiles;
297
315
  private configGraphUnchanged;
@@ -348,7 +366,7 @@ declare class Builder {
348
366
  mtime: number;
349
367
  isUnchanged: boolean;
350
368
  };
351
- checkFilesChanged(files: string[]): {
369
+ checkFilesChanged(files: readonly string[], knownChanges?: ReadonlySet<string>): {
352
370
  changes: Map<string, FileMeta>;
353
371
  hasFilesChanged: boolean;
354
372
  };
@@ -463,4 +481,4 @@ declare const hasUncompilableSources: (options: {
463
481
  include?: readonly string[];
464
482
  }) => boolean;
465
483
  //#endregion
466
- export { BambooContext, Builder, type CssGenOptions, analyze, buildInfo, codegen, cssgen, debug, findViteConfig, generate, generatePackageExports, hasUncompilableSources, isStaticCompilerActive, loadConfigAndCreateContext, markStaticCompilerActive, setLogStream, setupConfig, setupGitIgnore, spec, startProfiling };
484
+ export { BambooContext, Builder, type BuilderSetupOptions, type BuilderSourceChanges, type CssGenOptions, analyze, buildInfo, codegen, cssgen, debug, findViteConfig, generate, generatePackageExports, hasUncompilableSources, isStaticCompilerActive, loadConfigAndCreateContext, markStaticCompilerActive, setLogStream, setupConfig, setupGitIgnore, spec, startProfiling };
package/dist/index.mjs CHANGED
@@ -6,6 +6,7 @@ import { BambooError, cssVarRefs, groupBy, truncateList, uniq } from "@bamboocss
6
6
  import { createHash } from "node:crypto";
7
7
  import { appendFileSync, existsSync, readFileSync, statSync, writeFileSync } from "fs";
8
8
  import { dirname, extname, isAbsolute, join, normalize, parse, relative, resolve, sep } from "path";
9
+ import picomatch from "picomatch";
9
10
  import { pluginSvelte } from "@bamboocss/plugin-svelte";
10
11
  import { pluginVue } from "@bamboocss/plugin-vue";
11
12
  import { checkNamingAgreement, formatNamingDisagreement, messages, prunesPreflight } from "@bamboocss/core";
@@ -21,7 +22,6 @@ import { Node, SyntaxKind, ts } from "ts-morph";
21
22
  import chokidar from "chokidar";
22
23
  import glob from "fast-glob";
23
24
  import fsExtra from "fs-extra";
24
- import picomatch from "picomatch";
25
25
  import { isMatch } from "matcher";
26
26
  import { resolveTsPathPattern } from "@bamboocss/config/ts-path";
27
27
  import readline from "node:readline";
@@ -3339,6 +3339,26 @@ var Builder = class {
3339
3339
  ]) for (const dependencies of readSets.values()) for (const dependency of dependencies) files.add(dependency);
3340
3340
  return Object.freeze([...files].sort());
3341
3341
  };
3342
+ /** @internal The inventory reconciled by the most recent extraction pass. */
3343
+ getSourceFiles = () => Object.freeze([...this.sourceInventory ?? []]);
3344
+ /** @internal Whether creating this path can change source or explicit-dependency membership. */
3345
+ isPotentialSourceFile = (filePath) => {
3346
+ const ctx = this.getContextOrThrow();
3347
+ const absolutePath = this.absOwner(ctx, filePath);
3348
+ const relativePath = this.sourcePath(ctx.runtime.path.relative(ctx.config.cwd, absolutePath));
3349
+ const sourcePatterns = ctx.config.include ?? [];
3350
+ const sourceMatcher = sourcePatterns.length ? picomatch(sourcePatterns, { ignore: globIgnore(ctx.config.exclude) }) : void 0;
3351
+ return sourceMatcher?.(relativePath) || sourceMatcher?.(absolutePath) || false;
3352
+ };
3353
+ /** @internal Whether creating or deleting this path can change a `dependencies` glob. */
3354
+ isPotentialConfigDependency = (filePath) => {
3355
+ const ctx = this.getContextOrThrow();
3356
+ const absolutePath = this.absOwner(ctx, filePath);
3357
+ const relativePath = this.sourcePath(ctx.runtime.path.relative(ctx.config.cwd, absolutePath));
3358
+ const patterns = ctx.config.dependencies ?? [];
3359
+ const matcher = patterns.length ? picomatch(patterns) : void 0;
3360
+ return matcher?.(relativePath) || matcher?.(absolutePath) || false;
3361
+ };
3342
3362
  /** @internal Exact local package/tsconfig files which can change semantic resolution. */
3343
3363
  getResolutionConfigurationFiles = () => {
3344
3364
  const files = /* @__PURE__ */ new Set();
@@ -3353,7 +3373,7 @@ var Builder = class {
3353
3373
  throw error;
3354
3374
  }
3355
3375
  };
3356
- changedResolutionConfigurations = () => this.getResolutionConfigurationFiles().filter((file) => this.resolutionConfigurationBytes.get(file) !== this.readResolutionConfiguration(file));
3376
+ changedResolutionConfigurations = (knownChanges) => this.getResolutionConfigurationFiles().filter((file) => (!knownChanges || knownChanges.has(this.sourcePath(file))) && this.resolutionConfigurationBytes.get(file) !== this.readResolutionConfiguration(file));
3357
3377
  snapshotResolutionConfigurations = () => {
3358
3378
  const current = new Set(this.getResolutionConfigurationFiles());
3359
3379
  for (const file of current) this.resolutionConfigurationBytes.set(file, this.readResolutionConfiguration(file));
@@ -3372,6 +3392,7 @@ var Builder = class {
3372
3392
  dev: options.dev
3373
3393
  });
3374
3394
  const ctx = this.getContextOrThrow();
3395
+ const previousExplicitDeps = [...ctx.explicitDeps];
3375
3396
  const previousTsconfigFiles = this.tsconfigResolutionFiles.length ? this.tsconfigResolutionFiles : ctx.diff.getResolutionConfigFiles();
3376
3397
  /**
3377
3398
  * Dev fast path: skip the config reload when nothing that can change the resolved config
@@ -3390,24 +3411,33 @@ var Builder = class {
3390
3411
  * preset external to the config bundle — and a one-shot build keeps paying the reload
3391
3412
  * rather than trading that recovery for a latency only watch mode feels.
3392
3413
  */
3393
- if (options.dev && this.configGraphUnchanged(configPath)) {
3414
+ if (options.dev && this.configGraphUnchanged(configPath, options.sourceChanges)) {
3394
3415
  this.affecteds = {
3395
3416
  artifacts: /* @__PURE__ */ new Set(),
3396
3417
  hasConfigChanged: false,
3397
3418
  diffs: []
3398
3419
  };
3399
3420
  this.explicitDepsMeta = this.checkFilesChanged(this.context.explicitDeps);
3400
- this.refreshSourceState(ctx, previousTsconfigFiles);
3421
+ this.refreshSourceState(ctx, previousTsconfigFiles, options.sourceChanges);
3401
3422
  return;
3402
3423
  }
3403
3424
  this.affecteds = await ctx.diff.reloadConfigAndRefreshContext((conf) => {
3404
3425
  this.context = new BambooContext(conf);
3405
3426
  });
3406
3427
  const nextContext = this.getContextOrThrow();
3428
+ if (options.sourceChanges?.needsConfigReload) {
3429
+ const { cwd: configCwd, dependencies } = nextContext.config;
3430
+ nextContext.explicitDeps = dependencies ? nextContext.runtime.fs.glob({
3431
+ include: dependencies,
3432
+ cwd: configCwd
3433
+ }) : [];
3434
+ }
3407
3435
  this.recordConfigDependencies(nextContext, options.cwd);
3408
3436
  this.tsconfigResolutionFiles = nextContext.diff.getResolutionConfigFiles();
3409
3437
  logger.debug("builder", this.affecteds);
3410
- this.explicitDepsMeta = this.checkFilesChanged(this.context.explicitDeps);
3438
+ const explicitDeps = options.sourceChanges?.needsConfigReload ? uniq([...previousExplicitDeps, ...this.context.explicitDeps]) : this.context.explicitDeps;
3439
+ const knownChanges = options.sourceChanges ? new Set(options.sourceChanges.files.map((file) => this.absOwner(this.context, file))) : void 0;
3440
+ this.explicitDepsMeta = this.checkFilesChanged(explicitDeps, knownChanges);
3411
3441
  if (this.explicitDepsMeta.hasFilesChanged) {
3412
3442
  this.explicitDepsMeta.changes.forEach((meta, file) => {
3413
3443
  fileModifiedMap.set(file, meta.mtime);
@@ -3437,7 +3467,7 @@ var Builder = class {
3437
3467
  this.snapshotConfigGraphMtimes(configPath);
3438
3468
  return;
3439
3469
  }
3440
- this.refreshSourceState(ctx, previousTsconfigFiles);
3470
+ this.refreshSourceState(ctx, previousTsconfigFiles, options.sourceChanges);
3441
3471
  this.snapshotConfigGraphMtimes(configPath);
3442
3472
  };
3443
3473
  /** Every file whose content participates in the resolved config, for the dev fast path. */
@@ -3447,10 +3477,13 @@ var Builder = class {
3447
3477
  ...this.tsconfigResolutionFiles,
3448
3478
  ...this.context?.explicitDeps ?? []
3449
3479
  ].map(normalize));
3450
- configGraphUnchanged = (configPath) => {
3480
+ configGraphUnchanged = (configPath, sourceChanges) => {
3451
3481
  const snapshot = this.configGraphMtimes;
3452
3482
  if (!snapshot) return false;
3483
+ if (sourceChanges?.needsConfigReload) return false;
3484
+ const changed = sourceChanges ? new Set(sourceChanges.files.map((file) => this.sourcePath(resolve(this.context?.config.cwd ?? "", file)))) : void 0;
3453
3485
  for (const file of this.configGraphFiles(configPath)) {
3486
+ if (changed?.has(this.sourcePath(resolve(this.context?.config.cwd ?? "", file)))) return false;
3454
3487
  const recorded = snapshot.get(file);
3455
3488
  if (recorded === void 0 || recorded !== this.getFileMeta(file).mtime) return false;
3456
3489
  }
@@ -3462,8 +3495,9 @@ var Builder = class {
3462
3495
  this.configGraphMtimes = snapshot;
3463
3496
  };
3464
3497
  /** The per-pass source bookkeeping every setup ends with, config reload or not. */
3465
- refreshSourceState = (ctx, previousTsconfigFiles) => {
3466
- const changedResolutionConfigurations = this.changedResolutionConfigurations();
3498
+ refreshSourceState = (ctx, previousTsconfigFiles, sourceChanges) => {
3499
+ const knownChanges = sourceChanges ? new Set(sourceChanges.files.map((file) => this.absOwner(ctx, file))) : void 0;
3500
+ const changedResolutionConfigurations = this.changedResolutionConfigurations(knownChanges);
3467
3501
  const changedResolutionSet = new Set(changedResolutionConfigurations);
3468
3502
  const resolutionAffected = /* @__PURE__ */ new Set();
3469
3503
  const resolutionLedger = this.capturedLedger ?? (changedResolutionConfigurations.length ? ctx.project.getResolutionLedger() : void 0);
@@ -3475,14 +3509,21 @@ var Builder = class {
3475
3509
  const replaceCompilerOptions = changedResolutionConfigurations.some((file) => tsconfigCandidates.has(file));
3476
3510
  ctx.project.refreshResolutionConfiguration(ctx.conf.tsconfig?.compilerOptions, this.tsconfigResolutionFiles, replaceCompilerOptions);
3477
3511
  }
3478
- const inventory = ctx.getFiles();
3479
- const tracked = uniq([
3512
+ const needsInventoryScan = !sourceChanges || sourceChanges.needsInventoryScan || this.sourceInventory === void 0;
3513
+ const inventory = needsInventoryScan ? ctx.getFiles() : [...this.sourceInventory];
3514
+ const allTracked = uniq([
3480
3515
  ...this.sourceInventory ?? inventory,
3481
3516
  ...inventory,
3482
3517
  ...this.getResolutionReadFiles()
3483
3518
  ]);
3484
- this.filesMeta = this.checkFilesChanged(tracked);
3485
- if (this.filesMeta.hasFilesChanged) {
3519
+ const trackedPaths = new Set(allTracked.map((file) => this.absOwner(ctx, file)));
3520
+ const tracked = knownChanges && !needsInventoryScan ? [...knownChanges].filter((file) => trackedPaths.has(file)) : allTracked;
3521
+ this.filesMeta = tracked.length ? this.checkFilesChanged(tracked, knownChanges) : changedResolutionConfigurations.length ? {
3522
+ changes: /* @__PURE__ */ new Map(),
3523
+ hasFilesChanged: false
3524
+ } : void 0;
3525
+ for (const [file, meta] of this.filesMeta?.changes ?? []) if (!meta.isUnchanged) this.sourceScanCache.entries.delete(this.absOwner(ctx, file));
3526
+ if (this.filesMeta?.hasFilesChanged) {
3486
3527
  logger.debug("builder", "Files changed, invalidating them");
3487
3528
  this.invalidateChangedSources(ctx, inventory, resolutionAffected, resolutionLedger);
3488
3529
  } else if (changedResolutionConfigurations.length) {
@@ -3660,11 +3701,12 @@ var Builder = class {
3660
3701
  isUnchanged: fileModifiedMap.has(file) && mtime === fileModifiedMap.get(file)
3661
3702
  };
3662
3703
  };
3663
- checkFilesChanged(files) {
3704
+ checkFilesChanged(files, knownChanges) {
3664
3705
  const changes = /* @__PURE__ */ new Map();
3665
3706
  let hasFilesChanged = false;
3666
3707
  for (const file of files) {
3667
3708
  const meta = this.getFileMeta(file);
3709
+ if (knownChanges?.has(this.sourcePath(file))) meta.isUnchanged = false;
3668
3710
  changes.set(file, meta);
3669
3711
  if (!meta.isUnchanged) hasFilesChanged = true;
3670
3712
  }
@@ -3757,7 +3799,10 @@ var Builder = class {
3757
3799
  for (const file of filesToExtract) this.extractFile(ctx, file);
3758
3800
  done();
3759
3801
  this.sourceInventory = [...files];
3760
- for (const file of uniq([...files, ...this.getResolutionReadFiles()])) fileModifiedMap.set(file, this.getFileMeta(file).mtime);
3802
+ for (const file of uniq([...files, ...this.getResolutionReadFiles()])) {
3803
+ const mtime = this.filesMeta?.changes.get(file)?.mtime ?? fileModifiedMap.get(file) ?? this.getFileMeta(file).mtime;
3804
+ fileModifiedMap.set(file, mtime);
3805
+ }
3761
3806
  this.snapshotResolutionConfigurations();
3762
3807
  this.affectedFiles = void 0;
3763
3808
  this.extractionOrder = void 0;
@@ -3777,7 +3822,7 @@ var Builder = class {
3777
3822
  const sheet = assembleExtractedSheet(ctx, {
3778
3823
  layerParams,
3779
3824
  sourceScanCache: this.sourceScanCache,
3780
- mtimeOf: (filePath) => this.filesMeta?.changes.get(filePath)?.mtime,
3825
+ mtimeOf: (filePath) => this.filesMeta?.changes.get(filePath)?.mtime ?? fileModifiedMap.get(filePath),
3781
3826
  sourceInventory: this.sourceInventory
3782
3827
  });
3783
3828
  return ctx.getCss(sheet);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bamboocss/node",
3
- "version": "1.48.0",
3
+ "version": "1.48.1",
4
4
  "description": "The core css bamboo library",
5
5
  "homepage": "https://bamboocss.com",
6
6
  "license": "MIT",
@@ -62,17 +62,17 @@
62
62
  "pluralize": "8.0.0",
63
63
  "ts-morph": "28.0.0",
64
64
  "ts-pattern": "5.9.0",
65
- "@bamboocss/config": "1.48.0",
66
- "@bamboocss/core": "1.48.0",
67
- "@bamboocss/generator": "1.48.0",
68
- "@bamboocss/logger": "1.48.0",
69
- "@bamboocss/parser": "1.48.0",
70
- "@bamboocss/plugin-svelte": "1.48.0",
71
- "@bamboocss/plugin-vue": "1.48.0",
72
- "@bamboocss/reporter": "1.48.0",
73
- "@bamboocss/shared": "1.48.0",
74
- "@bamboocss/token-dictionary": "1.48.0",
75
- "@bamboocss/types": "1.48.0"
65
+ "@bamboocss/config": "1.48.1",
66
+ "@bamboocss/core": "1.48.1",
67
+ "@bamboocss/generator": "1.48.1",
68
+ "@bamboocss/logger": "1.48.1",
69
+ "@bamboocss/parser": "1.48.1",
70
+ "@bamboocss/plugin-svelte": "1.48.1",
71
+ "@bamboocss/plugin-vue": "1.48.1",
72
+ "@bamboocss/reporter": "1.48.1",
73
+ "@bamboocss/shared": "1.48.1",
74
+ "@bamboocss/token-dictionary": "1.48.1",
75
+ "@bamboocss/types": "1.48.1"
76
76
  },
77
77
  "devDependencies": {
78
78
  "@types/fs-extra": "11.0.4",