@bamboocss/vite 1.55.1 → 1.55.2

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.
Files changed (3) hide show
  1. package/dist/index.cjs +41 -10
  2. package/dist/index.mjs +41 -10
  3. package/package.json +10 -10
package/dist/index.cjs CHANGED
@@ -532,7 +532,7 @@ const bamboocssCss = (options) => {
532
532
  * for the client graph and once for SSR — and each load used to run a complete extraction
533
533
  * and optimization pass to produce byte-identical CSS. The sheet is a function of the source
534
534
  * files alone, and the watcher below is the single point every event that can reach it
535
- * passes through — Vite's own propagation only arrives via the watch edges `load` registers,
535
+ * passes through — Vite's own propagation only arrives via the watch edges `transform` registers,
536
536
  * over the same extracted files the watcher checks. A monotonic counter bumped there is
537
537
  * therefore enough to know whether a build already reflects the world a load is asking about.
538
538
  *
@@ -745,13 +745,10 @@ const bamboocssCss = (options) => {
745
745
  if (id.slice(0, id.length - query.length) !== RESOLVED_ID) return null;
746
746
  session.cssLoaded = true;
747
747
  const generationAtStart = changeGeneration;
748
- if (command === "serve" && servedCss?.generation === generationAtStart) {
749
- if (this.addWatchFile) for (const file of session.extractedFiles) this.addWatchFile(file);
750
- return servedCss.map ? {
751
- code: servedCss.css,
752
- map: servedCss.map
753
- } : servedCss.css;
754
- }
748
+ if (command === "serve" && servedCss?.generation === generationAtStart) return servedCss.map ? {
749
+ code: servedCss.css,
750
+ map: servedCss.map
751
+ } : servedCss.css;
755
752
  let css;
756
753
  let map;
757
754
  try {
@@ -770,18 +767,52 @@ const bamboocssCss = (options) => {
770
767
  css,
771
768
  map
772
769
  };
773
- if (this.addWatchFile) for (const file of session.extractedFiles) this.addWatchFile(file);
770
+ if (command === "build" && this.addWatchFile) for (const file of session.extractedFiles) this.addWatchFile(file);
774
771
  return map ? {
775
772
  code: css,
776
773
  map
777
774
  } : css;
778
775
  },
776
+ /**
777
+ * Register every extracted file against the stylesheet, in the graph that just asked for it.
778
+ *
779
+ * In dev this has to happen here rather than in `load`. Vite attaches what `load` registers to
780
+ * the module's node in the graph, and a request for a module the graph has no node for yet runs
781
+ * `load` first and creates the node afterwards, so everything `load` registered is dropped
782
+ * without a word. `vite:css-analysis` then records no importer edges, Vite's own propagation
783
+ * never reaches the sheet in that environment, and the watcher below does not force a reload
784
+ * either, because the edited file does have a module there. The component repaints with a class
785
+ * whose rule never arrives, and stays that way until a restart.
786
+ *
787
+ * A browser's import never meets it, since the importer's analysis creates the node before the
788
+ * sheet is requested. A `transformRequest` that reaches the sheet first does. TanStack Start
789
+ * sends one on every page load when `__root.tsx` imports the stylesheet: its dev-only SSR style
790
+ * collection transforms the sheet in the client environment on the server, before the browser's
791
+ * import has put a node there.
792
+ *
793
+ * By `transform` the node exists, and the context is the one `vite:css-analysis` reads after
794
+ * every plugin has run, so the edges are recorded however the request arrived. From the
795
+ * session's set rather than `extractedSourceFiles()`, which re-globs the include patterns per
796
+ * call; every pass assigns the set from that same expression.
797
+ *
798
+ * Filtered by id, so a bundler that honours hook filters never calls in for any other module.
799
+ * The exact check stays for one that does not.
800
+ */
801
+ transform: {
802
+ filter: { id: /virtual:bamboo\.css/ },
803
+ handler(_code, id) {
804
+ if (command !== "serve") return;
805
+ const query = queryOf(id);
806
+ if (id.slice(0, id.length - query.length) !== RESOLVED_ID) return;
807
+ if (this.addWatchFile) for (const file of session.extractedFiles) this.addWatchFile(file);
808
+ }
809
+ },
779
810
  configureServer(devServer) {
780
811
  server = devServer;
781
812
  /**
782
813
  * The graph the stylesheet's own module lives in, which is the one that has to reach it.
783
814
  *
784
- * `load` registers every extracted file with `addWatchFile`, and `vite:css-analysis`
815
+ * `transform` registers every extracted file with `addWatchFile`, and `vite:css-analysis`
785
816
  * turns those into real importer edges — the virtual module ends up a direct importer of
786
817
  * each file the extractor read. So an edit to any of them propagates to the stylesheet on
787
818
  * Vite's own pass, in whichever environment holds that edge.
package/dist/index.mjs CHANGED
@@ -527,7 +527,7 @@ const bamboocssCss = (options) => {
527
527
  * for the client graph and once for SSR — and each load used to run a complete extraction
528
528
  * and optimization pass to produce byte-identical CSS. The sheet is a function of the source
529
529
  * files alone, and the watcher below is the single point every event that can reach it
530
- * passes through — Vite's own propagation only arrives via the watch edges `load` registers,
530
+ * passes through — Vite's own propagation only arrives via the watch edges `transform` registers,
531
531
  * over the same extracted files the watcher checks. A monotonic counter bumped there is
532
532
  * therefore enough to know whether a build already reflects the world a load is asking about.
533
533
  *
@@ -740,13 +740,10 @@ const bamboocssCss = (options) => {
740
740
  if (id.slice(0, id.length - query.length) !== RESOLVED_ID) return null;
741
741
  session.cssLoaded = true;
742
742
  const generationAtStart = changeGeneration;
743
- if (command === "serve" && servedCss?.generation === generationAtStart) {
744
- if (this.addWatchFile) for (const file of session.extractedFiles) this.addWatchFile(file);
745
- return servedCss.map ? {
746
- code: servedCss.css,
747
- map: servedCss.map
748
- } : servedCss.css;
749
- }
743
+ if (command === "serve" && servedCss?.generation === generationAtStart) return servedCss.map ? {
744
+ code: servedCss.css,
745
+ map: servedCss.map
746
+ } : servedCss.css;
750
747
  let css;
751
748
  let map;
752
749
  try {
@@ -765,18 +762,52 @@ const bamboocssCss = (options) => {
765
762
  css,
766
763
  map
767
764
  };
768
- if (this.addWatchFile) for (const file of session.extractedFiles) this.addWatchFile(file);
765
+ if (command === "build" && this.addWatchFile) for (const file of session.extractedFiles) this.addWatchFile(file);
769
766
  return map ? {
770
767
  code: css,
771
768
  map
772
769
  } : css;
773
770
  },
771
+ /**
772
+ * Register every extracted file against the stylesheet, in the graph that just asked for it.
773
+ *
774
+ * In dev this has to happen here rather than in `load`. Vite attaches what `load` registers to
775
+ * the module's node in the graph, and a request for a module the graph has no node for yet runs
776
+ * `load` first and creates the node afterwards, so everything `load` registered is dropped
777
+ * without a word. `vite:css-analysis` then records no importer edges, Vite's own propagation
778
+ * never reaches the sheet in that environment, and the watcher below does not force a reload
779
+ * either, because the edited file does have a module there. The component repaints with a class
780
+ * whose rule never arrives, and stays that way until a restart.
781
+ *
782
+ * A browser's import never meets it, since the importer's analysis creates the node before the
783
+ * sheet is requested. A `transformRequest` that reaches the sheet first does. TanStack Start
784
+ * sends one on every page load when `__root.tsx` imports the stylesheet: its dev-only SSR style
785
+ * collection transforms the sheet in the client environment on the server, before the browser's
786
+ * import has put a node there.
787
+ *
788
+ * By `transform` the node exists, and the context is the one `vite:css-analysis` reads after
789
+ * every plugin has run, so the edges are recorded however the request arrived. From the
790
+ * session's set rather than `extractedSourceFiles()`, which re-globs the include patterns per
791
+ * call; every pass assigns the set from that same expression.
792
+ *
793
+ * Filtered by id, so a bundler that honours hook filters never calls in for any other module.
794
+ * The exact check stays for one that does not.
795
+ */
796
+ transform: {
797
+ filter: { id: /virtual:bamboo\.css/ },
798
+ handler(_code, id) {
799
+ if (command !== "serve") return;
800
+ const query = queryOf(id);
801
+ if (id.slice(0, id.length - query.length) !== RESOLVED_ID) return;
802
+ if (this.addWatchFile) for (const file of session.extractedFiles) this.addWatchFile(file);
803
+ }
804
+ },
774
805
  configureServer(devServer) {
775
806
  server = devServer;
776
807
  /**
777
808
  * The graph the stylesheet's own module lives in, which is the one that has to reach it.
778
809
  *
779
- * `load` registers every extracted file with `addWatchFile`, and `vite:css-analysis`
810
+ * `transform` registers every extracted file with `addWatchFile`, and `vite:css-analysis`
780
811
  * turns those into real importer edges — the virtual module ends up a direct importer of
781
812
  * each file the extractor read. So an edit to any of them propagates to the stylesheet on
782
813
  * Vite's own pass, in whichever environment holds that edge.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bamboocss/vite",
3
- "version": "1.55.1",
3
+ "version": "1.55.2",
4
4
  "description": "Vite integration for Bamboo CSS",
5
5
  "homepage": "https://bamboocss.com",
6
6
  "license": "MIT",
@@ -42,20 +42,20 @@
42
42
  "magic-string": "0.30.21",
43
43
  "postcss": "8.5.26",
44
44
  "postcss-selector-parser": "7.1.5",
45
- "@bamboocss/config": "1.55.1",
46
- "@bamboocss/core": "1.55.1",
47
- "@bamboocss/extractor": "1.55.1",
48
- "@bamboocss/logger": "1.55.1",
49
- "@bamboocss/node": "1.55.1",
50
- "@bamboocss/ts-ast": "1.55.1",
51
- "@bamboocss/shared": "1.55.1",
52
- "@bamboocss/types": "1.55.1"
45
+ "@bamboocss/config": "1.55.2",
46
+ "@bamboocss/core": "1.55.2",
47
+ "@bamboocss/extractor": "1.55.2",
48
+ "@bamboocss/logger": "1.55.2",
49
+ "@bamboocss/node": "1.55.2",
50
+ "@bamboocss/shared": "1.55.2",
51
+ "@bamboocss/ts-ast": "1.55.2",
52
+ "@bamboocss/types": "1.55.2"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@jridgewell/trace-mapping": "^0.3.31",
56
56
  "@typescript/api": "npm:typescript@7.1.0-dev.20260826.1",
57
57
  "vite": "7.2.6",
58
- "@bamboocss/fixture": "1.55.1"
58
+ "@bamboocss/fixture": "1.55.2"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "vite": ">=5"