@bamboocss/vite 1.36.2 → 1.36.3

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
@@ -150,6 +150,19 @@ const VIRTUAL_CSS_ID = "virtual:bamboo.css";
150
150
  * not to try reading it off disk.
151
151
  */
152
152
  const RESOLVED_ID = `\0${VIRTUAL_CSS_ID}`;
153
+ /**
154
+ * A thrown value Vite can actually report.
155
+ *
156
+ * `catch` binds `unknown`, and anything under compilation — a dependency, a config hook, a
157
+ * bare `throw 'string'` — may throw a primitive. Vite's dev error middleware puts what it is
158
+ * handed into a `WeakSet` to deduplicate it, which throws `TypeError: Invalid value used in
159
+ * weak set` for anything that is not an object, and the real failure is lost behind that.
160
+ *
161
+ * Shared by every hook that can throw while the dev server is serving, so the two cannot
162
+ * drift: a request for the stylesheet reaches `load`, and a request for a module reaches
163
+ * `transform`, and both are answered by the same middleware.
164
+ */
165
+ const asError = (error, context) => error instanceof Error ? error : new Error(`bamboocss: ${context}: ${String(error)}`, { cause: error });
153
166
  const INLINE_SOURCE_MAP = /\n?\/\/# sourceMappingURL=data:application\/json[^\n]*$/;
154
167
  /** Rewrite one generated chunk without invalidating all mappings after the changed string. */
155
168
  const replaceChunkReference = (chunk, bundle, previous, next, sourcemap) => {
@@ -308,7 +321,12 @@ const bamboocssCss = (options) => {
308
321
  },
309
322
  async load(id) {
310
323
  if (id !== RESOLVED_ID) return null;
311
- const css = await generate();
324
+ let css;
325
+ try {
326
+ css = await generate();
327
+ } catch (error) {
328
+ throw asError(error, `failed to generate ${VIRTUAL_CSS_ID}`);
329
+ }
312
330
  if (this.addWatchFile) for (const file of builder.context?.getFiles() ?? []) this.addWatchFile(builder.context.runtime.path.abs(builder.context.config.cwd, file));
313
331
  return css;
314
332
  },
@@ -2942,7 +2960,7 @@ const bamboocss = (options = {}) => {
2942
2960
  name: "compiler",
2943
2961
  reason: "compile-failed"
2944
2962
  });
2945
- if (command === "serve") throw error instanceof Error ? error : new Error(`bamboocss: failed to compile ${filePath}: ${String(error)}`, { cause: error });
2963
+ if (command === "serve") throw asError(error, `failed to compile ${filePath}`);
2946
2964
  return null;
2947
2965
  }
2948
2966
  totals.files++;
package/dist/index.mjs CHANGED
@@ -120,6 +120,19 @@ const VIRTUAL_CSS_ID = "virtual:bamboo.css";
120
120
  * not to try reading it off disk.
121
121
  */
122
122
  const RESOLVED_ID = `\0${VIRTUAL_CSS_ID}`;
123
+ /**
124
+ * A thrown value Vite can actually report.
125
+ *
126
+ * `catch` binds `unknown`, and anything under compilation — a dependency, a config hook, a
127
+ * bare `throw 'string'` — may throw a primitive. Vite's dev error middleware puts what it is
128
+ * handed into a `WeakSet` to deduplicate it, which throws `TypeError: Invalid value used in
129
+ * weak set` for anything that is not an object, and the real failure is lost behind that.
130
+ *
131
+ * Shared by every hook that can throw while the dev server is serving, so the two cannot
132
+ * drift: a request for the stylesheet reaches `load`, and a request for a module reaches
133
+ * `transform`, and both are answered by the same middleware.
134
+ */
135
+ const asError = (error, context) => error instanceof Error ? error : new Error(`bamboocss: ${context}: ${String(error)}`, { cause: error });
123
136
  const INLINE_SOURCE_MAP = /\n?\/\/# sourceMappingURL=data:application\/json[^\n]*$/;
124
137
  /** Rewrite one generated chunk without invalidating all mappings after the changed string. */
125
138
  const replaceChunkReference = (chunk, bundle, previous, next, sourcemap) => {
@@ -278,7 +291,12 @@ const bamboocssCss = (options) => {
278
291
  },
279
292
  async load(id) {
280
293
  if (id !== RESOLVED_ID) return null;
281
- const css = await generate();
294
+ let css;
295
+ try {
296
+ css = await generate();
297
+ } catch (error) {
298
+ throw asError(error, `failed to generate ${VIRTUAL_CSS_ID}`);
299
+ }
282
300
  if (this.addWatchFile) for (const file of builder.context?.getFiles() ?? []) this.addWatchFile(builder.context.runtime.path.abs(builder.context.config.cwd, file));
283
301
  return css;
284
302
  },
@@ -2912,7 +2930,7 @@ const bamboocss = (options = {}) => {
2912
2930
  name: "compiler",
2913
2931
  reason: "compile-failed"
2914
2932
  });
2915
- if (command === "serve") throw error instanceof Error ? error : new Error(`bamboocss: failed to compile ${filePath}: ${String(error)}`, { cause: error });
2933
+ if (command === "serve") throw asError(error, `failed to compile ${filePath}`);
2916
2934
  return null;
2917
2935
  }
2918
2936
  totals.files++;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bamboocss/vite",
3
- "version": "1.36.2",
3
+ "version": "1.36.3",
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/config": "1.36.2",
44
- "@bamboocss/core": "1.36.2",
45
- "@bamboocss/extractor": "1.36.2",
46
- "@bamboocss/node": "1.36.2",
47
- "@bamboocss/logger": "1.36.2",
48
- "@bamboocss/shared": "1.36.2",
49
- "@bamboocss/types": "1.36.2"
43
+ "@bamboocss/config": "1.36.3",
44
+ "@bamboocss/core": "1.36.3",
45
+ "@bamboocss/extractor": "1.36.3",
46
+ "@bamboocss/logger": "1.36.3",
47
+ "@bamboocss/node": "1.36.3",
48
+ "@bamboocss/shared": "1.36.3",
49
+ "@bamboocss/types": "1.36.3"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@jridgewell/trace-mapping": "^0.3.31",
53
53
  "vite": "7.2.6",
54
- "@bamboocss/fixture": "1.36.2"
54
+ "@bamboocss/fixture": "1.36.3"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "vite": ">=5"