@bamboocss/vite 1.37.11 → 1.37.12

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
@@ -2562,7 +2562,21 @@ const foldSource = (options) => {
2562
2562
  const sourceFile = ownSourceFile ?? candidates[0]?.node.getSourceFile() ?? recipeDefinitions[0]?.call.getSourceFile();
2563
2563
  if (!sourceFile) return;
2564
2564
  const importedRecipeBindings = new Set(parserResult.importedRecipes?.keys() ?? []);
2565
- const identifiers = identifierIndex(sourceFile);
2565
+ /**
2566
+ * Every identifier in the module, grouped by the name it spells — built at most once per
2567
+ * pass, and only when something below has a name to look up.
2568
+ *
2569
+ * One index answers for every binding, rather than a walk per binding. Built here rather
2570
+ * than cached across passes: it holds nodes, and a node does not outlive its source file
2571
+ * being replaced.
2572
+ *
2573
+ * Deferred because most modules in an app neither declare nor import a recipe, and the
2574
+ * walk is not cheap — `getDescendantsOfKind` wraps every identifier in the file in a
2575
+ * ts-morph node to answer a question those modules never ask. It was 11% of a 6,307-file
2576
+ * build, most of it spent producing an index nothing read.
2577
+ */
2578
+ let identifiers;
2579
+ const identifiersByName = () => identifiers ??= identifierIndex(sourceFile);
2566
2580
  for (const binding of new Set([...recipeConfigs.keys(), ...importedRecipeBindings])) {
2567
2581
  const entry = recipeConfigs.get(binding);
2568
2582
  if (entry === AMBIGUOUS) continue;
@@ -2570,7 +2584,7 @@ const foldSource = (options) => {
2570
2584
  const definition = entry?.box?.getNode?.();
2571
2585
  const nameNode = definition?.getSourceFile() === sourceFile ? definition?.getFirstAncestorByKind(ts_morph.SyntaxKind.VariableDeclaration)?.getNameNode() : importSpecifierFor(sourceFile, binding);
2572
2586
  if (!nameNode || !ts_morph.Node.isIdentifier(nameNode)) continue;
2573
- const references = localReferencesTo(identifiers, binding, nameNode);
2587
+ const references = localReferencesTo(identifiersByName(), binding, nameNode);
2574
2588
  if (skipped.filter((item) => SURVIVES_TO_RUNTIME.has(item.reason) && item.end > item.start).some((item) => references.some((ref) => ref.getStart() >= item.start && ref.getStart() < item.end))) continue;
2575
2589
  const survivor = references.find((ref) => !applied.some(([from, to]) => ref.getStart() >= from && ref.getStart() < to));
2576
2590
  if (!survivor) continue;
@@ -2671,25 +2685,24 @@ const foldSource = (options) => {
2671
2685
  }
2672
2686
  if (watched.size === 0) return;
2673
2687
  const declined = skipped.filter((entry) => SURVIVES_TO_RUNTIME.has(entry.reason) && entry.end > entry.start).map((entry) => [entry.start, entry.end]);
2674
- const reported = /* @__PURE__ */ new Set();
2675
- for (const identifier of sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.Identifier)) {
2676
- const local = identifier.getText();
2677
- const imported = watched.get(local);
2678
- if (imported === void 0 || reported.has(local)) continue;
2688
+ const survivors = [];
2689
+ for (const [local, imported] of watched) for (const identifier of identifiersByName().get(local) ?? []) {
2679
2690
  const start = identifier.getStart();
2680
2691
  if (identifier.getFirstAncestorByKind(ts_morph.SyntaxKind.ImportDeclaration)) continue;
2681
2692
  if (applied.some(([from, to]) => start >= from && start < to)) continue;
2682
2693
  if (declined.some(([from, to]) => start >= from && start < to)) continue;
2683
2694
  if (!isValueReference(identifier)) continue;
2684
2695
  if (isShadowed(identifier, local)) continue;
2685
- reported.add(local);
2686
- skipped.push({
2696
+ survivors.push({
2687
2697
  name: imported,
2688
2698
  reason: "runtime-binding",
2689
2699
  start,
2690
2700
  end: identifier.getEnd()
2691
2701
  });
2702
+ break;
2692
2703
  }
2704
+ survivors.sort((a, b) => a.start - b.start);
2705
+ skipped.push(...survivors);
2693
2706
  }
2694
2707
  if (reportSurvivors) reportRuntimeBindings();
2695
2708
  if (folded.length === 0) return {
package/dist/index.mjs CHANGED
@@ -2532,7 +2532,21 @@ const foldSource = (options) => {
2532
2532
  const sourceFile = ownSourceFile ?? candidates[0]?.node.getSourceFile() ?? recipeDefinitions[0]?.call.getSourceFile();
2533
2533
  if (!sourceFile) return;
2534
2534
  const importedRecipeBindings = new Set(parserResult.importedRecipes?.keys() ?? []);
2535
- const identifiers = identifierIndex(sourceFile);
2535
+ /**
2536
+ * Every identifier in the module, grouped by the name it spells — built at most once per
2537
+ * pass, and only when something below has a name to look up.
2538
+ *
2539
+ * One index answers for every binding, rather than a walk per binding. Built here rather
2540
+ * than cached across passes: it holds nodes, and a node does not outlive its source file
2541
+ * being replaced.
2542
+ *
2543
+ * Deferred because most modules in an app neither declare nor import a recipe, and the
2544
+ * walk is not cheap — `getDescendantsOfKind` wraps every identifier in the file in a
2545
+ * ts-morph node to answer a question those modules never ask. It was 11% of a 6,307-file
2546
+ * build, most of it spent producing an index nothing read.
2547
+ */
2548
+ let identifiers;
2549
+ const identifiersByName = () => identifiers ??= identifierIndex(sourceFile);
2536
2550
  for (const binding of new Set([...recipeConfigs.keys(), ...importedRecipeBindings])) {
2537
2551
  const entry = recipeConfigs.get(binding);
2538
2552
  if (entry === AMBIGUOUS) continue;
@@ -2540,7 +2554,7 @@ const foldSource = (options) => {
2540
2554
  const definition = entry?.box?.getNode?.();
2541
2555
  const nameNode = definition?.getSourceFile() === sourceFile ? definition?.getFirstAncestorByKind(SyntaxKind.VariableDeclaration)?.getNameNode() : importSpecifierFor(sourceFile, binding);
2542
2556
  if (!nameNode || !Node.isIdentifier(nameNode)) continue;
2543
- const references = localReferencesTo(identifiers, binding, nameNode);
2557
+ const references = localReferencesTo(identifiersByName(), binding, nameNode);
2544
2558
  if (skipped.filter((item) => SURVIVES_TO_RUNTIME.has(item.reason) && item.end > item.start).some((item) => references.some((ref) => ref.getStart() >= item.start && ref.getStart() < item.end))) continue;
2545
2559
  const survivor = references.find((ref) => !applied.some(([from, to]) => ref.getStart() >= from && ref.getStart() < to));
2546
2560
  if (!survivor) continue;
@@ -2641,25 +2655,24 @@ const foldSource = (options) => {
2641
2655
  }
2642
2656
  if (watched.size === 0) return;
2643
2657
  const declined = skipped.filter((entry) => SURVIVES_TO_RUNTIME.has(entry.reason) && entry.end > entry.start).map((entry) => [entry.start, entry.end]);
2644
- const reported = /* @__PURE__ */ new Set();
2645
- for (const identifier of sourceFile.getDescendantsOfKind(SyntaxKind.Identifier)) {
2646
- const local = identifier.getText();
2647
- const imported = watched.get(local);
2648
- if (imported === void 0 || reported.has(local)) continue;
2658
+ const survivors = [];
2659
+ for (const [local, imported] of watched) for (const identifier of identifiersByName().get(local) ?? []) {
2649
2660
  const start = identifier.getStart();
2650
2661
  if (identifier.getFirstAncestorByKind(SyntaxKind.ImportDeclaration)) continue;
2651
2662
  if (applied.some(([from, to]) => start >= from && start < to)) continue;
2652
2663
  if (declined.some(([from, to]) => start >= from && start < to)) continue;
2653
2664
  if (!isValueReference(identifier)) continue;
2654
2665
  if (isShadowed(identifier, local)) continue;
2655
- reported.add(local);
2656
- skipped.push({
2666
+ survivors.push({
2657
2667
  name: imported,
2658
2668
  reason: "runtime-binding",
2659
2669
  start,
2660
2670
  end: identifier.getEnd()
2661
2671
  });
2672
+ break;
2662
2673
  }
2674
+ survivors.sort((a, b) => a.start - b.start);
2675
+ skipped.push(...survivors);
2663
2676
  }
2664
2677
  if (reportSurvivors) reportRuntimeBindings();
2665
2678
  if (folded.length === 0) return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bamboocss/vite",
3
- "version": "1.37.11",
3
+ "version": "1.37.12",
4
4
  "description": "Vite integration for Bamboo CSS",
5
5
  "homepage": "https://bamboocss.com",
6
6
  "license": "MIT",
@@ -40,18 +40,18 @@
40
40
  "postcss": "8.5.26",
41
41
  "postcss-selector-parser": "7.1.5",
42
42
  "ts-morph": "28.0.0",
43
- "@bamboocss/logger": "1.37.11",
44
- "@bamboocss/node": "1.37.11",
45
- "@bamboocss/extractor": "1.37.11",
46
- "@bamboocss/core": "1.37.11",
47
- "@bamboocss/config": "1.37.11",
48
- "@bamboocss/shared": "1.37.11",
49
- "@bamboocss/types": "1.37.11"
43
+ "@bamboocss/config": "1.37.12",
44
+ "@bamboocss/core": "1.37.12",
45
+ "@bamboocss/extractor": "1.37.12",
46
+ "@bamboocss/logger": "1.37.12",
47
+ "@bamboocss/node": "1.37.12",
48
+ "@bamboocss/shared": "1.37.12",
49
+ "@bamboocss/types": "1.37.12"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@jridgewell/trace-mapping": "^0.3.31",
53
53
  "vite": "7.2.6",
54
- "@bamboocss/fixture": "1.37.11"
54
+ "@bamboocss/fixture": "1.37.12"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "vite": ">=5"