@bamboocss/parser 1.37.10 → 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
@@ -1497,7 +1497,31 @@ var Project = class {
1497
1497
  }
1498
1498
  };
1499
1499
  addSourceFile = (filePath, content) => {
1500
- this.invalidate(!(filePath.includes("/") && this.project.getSourceFile(filePath)));
1500
+ const existing = filePath.includes("/") ? this.project.getSourceFile(filePath) : void 0;
1501
+ /**
1502
+ * Re-adding a file the text it already holds is a no-op, and saying so is what makes the
1503
+ * bundler transform path affordable.
1504
+ *
1505
+ * That path adds every module before parsing it, handing back what the extractor already
1506
+ * read off disk — measured on a 6,307-file build, 6,001 of 6,001 `addSourceFile` calls
1507
+ * from the vite transform passed byte-identical content, with none differing and none
1508
+ * absent. Each paid twice: `createSourceFile` overwrites, which re-parses the file and
1509
+ * forgets every node previously taken from it, and `invalidate` drops both caches
1510
+ * memoized against *other* files' contents. The second is what actually hurt — the
1511
+ * imported-recipe walk runs one line later, in `parseSourceFile`, so emptying its memo
1512
+ * here meant every module re-walked the whole export closure of every barrel it imports.
1513
+ * On that build: 1,866,610 `walkExports` and 3,734,123 module resolutions, against 36,610
1514
+ * and 98,123 once the memo survives.
1515
+ *
1516
+ * Nothing changed, so nothing needs invalidating, and the file's existing tree is not
1517
+ * merely reusable but strictly better — a caller holding one of its nodes keeps it.
1518
+ *
1519
+ * Compared against `getFullText` rather than the bytes on disk, because `parseSourceFile`
1520
+ * may have replaced this file's text through a `parser:before` hook. Such a file no longer
1521
+ * matches its own source, falls through, and is overwritten exactly as before.
1522
+ */
1523
+ if (existing && existing.getFullText() === content) return existing;
1524
+ this.invalidate(!existing);
1501
1525
  return this.project.createSourceFile(filePath, content, {
1502
1526
  overwrite: true,
1503
1527
  scriptKind: scriptKindFor(filePath)
package/dist/index.mjs CHANGED
@@ -1496,7 +1496,31 @@ var Project = class {
1496
1496
  }
1497
1497
  };
1498
1498
  addSourceFile = (filePath, content) => {
1499
- this.invalidate(!(filePath.includes("/") && this.project.getSourceFile(filePath)));
1499
+ const existing = filePath.includes("/") ? this.project.getSourceFile(filePath) : void 0;
1500
+ /**
1501
+ * Re-adding a file the text it already holds is a no-op, and saying so is what makes the
1502
+ * bundler transform path affordable.
1503
+ *
1504
+ * That path adds every module before parsing it, handing back what the extractor already
1505
+ * read off disk — measured on a 6,307-file build, 6,001 of 6,001 `addSourceFile` calls
1506
+ * from the vite transform passed byte-identical content, with none differing and none
1507
+ * absent. Each paid twice: `createSourceFile` overwrites, which re-parses the file and
1508
+ * forgets every node previously taken from it, and `invalidate` drops both caches
1509
+ * memoized against *other* files' contents. The second is what actually hurt — the
1510
+ * imported-recipe walk runs one line later, in `parseSourceFile`, so emptying its memo
1511
+ * here meant every module re-walked the whole export closure of every barrel it imports.
1512
+ * On that build: 1,866,610 `walkExports` and 3,734,123 module resolutions, against 36,610
1513
+ * and 98,123 once the memo survives.
1514
+ *
1515
+ * Nothing changed, so nothing needs invalidating, and the file's existing tree is not
1516
+ * merely reusable but strictly better — a caller holding one of its nodes keeps it.
1517
+ *
1518
+ * Compared against `getFullText` rather than the bytes on disk, because `parseSourceFile`
1519
+ * may have replaced this file's text through a `parser:before` hook. Such a file no longer
1520
+ * matches its own source, falls through, and is overwritten exactly as before.
1521
+ */
1522
+ if (existing && existing.getFullText() === content) return existing;
1523
+ this.invalidate(!existing);
1500
1524
  return this.project.createSourceFile(filePath, content, {
1501
1525
  overwrite: true,
1502
1526
  scriptKind: scriptKindFor(filePath)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bamboocss/parser",
3
- "version": "1.37.10",
3
+ "version": "1.37.12",
4
4
  "description": "The static parser for bamboo css",
5
5
  "homepage": "https://bamboocss.com",
6
6
  "license": "MIT",
@@ -34,17 +34,17 @@
34
34
  "dependencies": {
35
35
  "ts-morph": "28.0.0",
36
36
  "ts-pattern": "5.9.0",
37
- "@bamboocss/config": "^1.37.10",
38
- "@bamboocss/core": "^1.37.10",
39
- "@bamboocss/extractor": "1.37.10",
40
- "@bamboocss/logger": "1.37.10",
41
- "@bamboocss/shared": "1.37.10",
42
- "@bamboocss/types": "1.37.10"
37
+ "@bamboocss/config": "^1.37.12",
38
+ "@bamboocss/core": "^1.37.12",
39
+ "@bamboocss/extractor": "1.37.12",
40
+ "@bamboocss/logger": "1.37.12",
41
+ "@bamboocss/shared": "1.37.12",
42
+ "@bamboocss/types": "1.37.12"
43
43
  },
44
44
  "devDependencies": {
45
- "@bamboocss/generator": "1.37.10",
46
- "@bamboocss/plugin-svelte": "1.37.10",
47
- "@bamboocss/plugin-vue": "1.37.10"
45
+ "@bamboocss/generator": "1.37.12",
46
+ "@bamboocss/plugin-svelte": "1.37.12",
47
+ "@bamboocss/plugin-vue": "1.37.12"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "tsdown src/index.ts --format=esm,cjs --dts",