@bamboocss/vite 1.55.2 → 1.55.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 +27 -4
- package/dist/index.mjs +27 -4
- package/package.json +10 -10
package/dist/index.cjs
CHANGED
|
@@ -304,6 +304,22 @@ const queryOf = (id) => {
|
|
|
304
304
|
const at = id.indexOf("?");
|
|
305
305
|
return at === -1 ? "" : id.slice(at);
|
|
306
306
|
};
|
|
307
|
+
/** `?url`, tested the way Vite's asset plugin tests it — the plugin a dev server leaves it to. */
|
|
308
|
+
const URL_QUERY = /(?:\?|&)url(?:&|$)/;
|
|
309
|
+
/**
|
|
310
|
+
* Where a dev server serves the stylesheet, spelled the way Vite writes the URL of any module with
|
|
311
|
+
* no file behind it: `/@id/`, then the resolved id with its NUL as `__x00__`, behind the server's
|
|
312
|
+
* `origin` and base.
|
|
313
|
+
*
|
|
314
|
+
* The base is taken decoded, so `encodeURI` applies its escapes exactly once, as Vite does for an
|
|
315
|
+
* asset's URL. Vite 6 and up carry it as `decodedBase`, which is missing from the published types,
|
|
316
|
+
* hence the cast; Vite 5 has only `base`, decoded here instead.
|
|
317
|
+
*/
|
|
318
|
+
const devStylesheetUrl = (config) => {
|
|
319
|
+
const join = (a, b) => a && b ? `${a.replace(/\/$/, "")}/${b.replace(/^\//, "")}` : a || b;
|
|
320
|
+
const base = config?.decodedBase ?? decodeURI(config?.base ?? "/");
|
|
321
|
+
return encodeURI(join(join(config?.server.origin ?? "", base), `@id/__x00__${VIRTUAL_CSS_ID}`));
|
|
322
|
+
};
|
|
307
323
|
/**
|
|
308
324
|
* A thrown value Vite can actually report.
|
|
309
325
|
*
|
|
@@ -744,6 +760,7 @@ const bamboocssCss = (options) => {
|
|
|
744
760
|
const query = queryOf(id);
|
|
745
761
|
if (id.slice(0, id.length - query.length) !== RESOLVED_ID) return null;
|
|
746
762
|
session.cssLoaded = true;
|
|
763
|
+
if (command === "serve" && URL_QUERY.test(query)) return `export default ${JSON.stringify(devStylesheetUrl(server?.config))}`;
|
|
747
764
|
const generationAtStart = changeGeneration;
|
|
748
765
|
if (command === "serve" && servedCss?.generation === generationAtStart) return servedCss.map ? {
|
|
749
766
|
code: servedCss.css,
|
|
@@ -804,6 +821,7 @@ const bamboocssCss = (options) => {
|
|
|
804
821
|
if (command !== "serve") return;
|
|
805
822
|
const query = queryOf(id);
|
|
806
823
|
if (id.slice(0, id.length - query.length) !== RESOLVED_ID) return;
|
|
824
|
+
if (URL_QUERY.test(query)) return;
|
|
807
825
|
if (this.addWatchFile) for (const file of session.extractedFiles) this.addWatchFile(file);
|
|
808
826
|
}
|
|
809
827
|
},
|
|
@@ -834,11 +852,16 @@ const bamboocssCss = (options) => {
|
|
|
834
852
|
host.noteSourceChange(absoluteFile, event, { needsConfigReload: changesConfigMembership });
|
|
835
853
|
changeGeneration++;
|
|
836
854
|
prebuilt = void 0;
|
|
837
|
-
const
|
|
838
|
-
|
|
855
|
+
const sheets = [RESOLVED_ID, `${RESOLVED_ID}?direct`].flatMap((sheetId) => {
|
|
856
|
+
const sheet = server?.moduleGraph.getModuleById(sheetId);
|
|
857
|
+
return sheet ? [sheet] : [];
|
|
858
|
+
});
|
|
859
|
+
if (!sheets.length) return;
|
|
839
860
|
if (wasExtracted && clientGraph.getModulesByFile(absoluteFile)?.size) return;
|
|
840
|
-
|
|
841
|
-
|
|
861
|
+
for (const sheet of sheets) {
|
|
862
|
+
server?.moduleGraph.invalidateModule(sheet);
|
|
863
|
+
server?.reloadModule(sheet);
|
|
864
|
+
}
|
|
842
865
|
_bamboocss_logger.logger.debug("vite", `styles invalidated by ${absoluteFile}`);
|
|
843
866
|
};
|
|
844
867
|
devServer.watcher.on("change", (file) => invalidate(file, "update"));
|
package/dist/index.mjs
CHANGED
|
@@ -299,6 +299,22 @@ const queryOf = (id) => {
|
|
|
299
299
|
const at = id.indexOf("?");
|
|
300
300
|
return at === -1 ? "" : id.slice(at);
|
|
301
301
|
};
|
|
302
|
+
/** `?url`, tested the way Vite's asset plugin tests it — the plugin a dev server leaves it to. */
|
|
303
|
+
const URL_QUERY = /(?:\?|&)url(?:&|$)/;
|
|
304
|
+
/**
|
|
305
|
+
* Where a dev server serves the stylesheet, spelled the way Vite writes the URL of any module with
|
|
306
|
+
* no file behind it: `/@id/`, then the resolved id with its NUL as `__x00__`, behind the server's
|
|
307
|
+
* `origin` and base.
|
|
308
|
+
*
|
|
309
|
+
* The base is taken decoded, so `encodeURI` applies its escapes exactly once, as Vite does for an
|
|
310
|
+
* asset's URL. Vite 6 and up carry it as `decodedBase`, which is missing from the published types,
|
|
311
|
+
* hence the cast; Vite 5 has only `base`, decoded here instead.
|
|
312
|
+
*/
|
|
313
|
+
const devStylesheetUrl = (config) => {
|
|
314
|
+
const join = (a, b) => a && b ? `${a.replace(/\/$/, "")}/${b.replace(/^\//, "")}` : a || b;
|
|
315
|
+
const base = config?.decodedBase ?? decodeURI(config?.base ?? "/");
|
|
316
|
+
return encodeURI(join(join(config?.server.origin ?? "", base), `@id/__x00__${VIRTUAL_CSS_ID}`));
|
|
317
|
+
};
|
|
302
318
|
/**
|
|
303
319
|
* A thrown value Vite can actually report.
|
|
304
320
|
*
|
|
@@ -739,6 +755,7 @@ const bamboocssCss = (options) => {
|
|
|
739
755
|
const query = queryOf(id);
|
|
740
756
|
if (id.slice(0, id.length - query.length) !== RESOLVED_ID) return null;
|
|
741
757
|
session.cssLoaded = true;
|
|
758
|
+
if (command === "serve" && URL_QUERY.test(query)) return `export default ${JSON.stringify(devStylesheetUrl(server?.config))}`;
|
|
742
759
|
const generationAtStart = changeGeneration;
|
|
743
760
|
if (command === "serve" && servedCss?.generation === generationAtStart) return servedCss.map ? {
|
|
744
761
|
code: servedCss.css,
|
|
@@ -799,6 +816,7 @@ const bamboocssCss = (options) => {
|
|
|
799
816
|
if (command !== "serve") return;
|
|
800
817
|
const query = queryOf(id);
|
|
801
818
|
if (id.slice(0, id.length - query.length) !== RESOLVED_ID) return;
|
|
819
|
+
if (URL_QUERY.test(query)) return;
|
|
802
820
|
if (this.addWatchFile) for (const file of session.extractedFiles) this.addWatchFile(file);
|
|
803
821
|
}
|
|
804
822
|
},
|
|
@@ -829,11 +847,16 @@ const bamboocssCss = (options) => {
|
|
|
829
847
|
host.noteSourceChange(absoluteFile, event, { needsConfigReload: changesConfigMembership });
|
|
830
848
|
changeGeneration++;
|
|
831
849
|
prebuilt = void 0;
|
|
832
|
-
const
|
|
833
|
-
|
|
850
|
+
const sheets = [RESOLVED_ID, `${RESOLVED_ID}?direct`].flatMap((sheetId) => {
|
|
851
|
+
const sheet = server?.moduleGraph.getModuleById(sheetId);
|
|
852
|
+
return sheet ? [sheet] : [];
|
|
853
|
+
});
|
|
854
|
+
if (!sheets.length) return;
|
|
834
855
|
if (wasExtracted && clientGraph.getModulesByFile(absoluteFile)?.size) return;
|
|
835
|
-
|
|
836
|
-
|
|
856
|
+
for (const sheet of sheets) {
|
|
857
|
+
server?.moduleGraph.invalidateModule(sheet);
|
|
858
|
+
server?.reloadModule(sheet);
|
|
859
|
+
}
|
|
837
860
|
logger.debug("vite", `styles invalidated by ${absoluteFile}`);
|
|
838
861
|
};
|
|
839
862
|
devServer.watcher.on("change", (file) => invalidate(file, "update"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/vite",
|
|
3
|
-
"version": "1.55.
|
|
3
|
+
"version": "1.55.3",
|
|
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.
|
|
46
|
-
"@bamboocss/
|
|
47
|
-
"@bamboocss/
|
|
48
|
-
"@bamboocss/
|
|
49
|
-
"@bamboocss/
|
|
50
|
-
"@bamboocss/shared": "1.55.
|
|
51
|
-
"@bamboocss/
|
|
52
|
-
"@bamboocss/
|
|
45
|
+
"@bamboocss/config": "1.55.3",
|
|
46
|
+
"@bamboocss/extractor": "1.55.3",
|
|
47
|
+
"@bamboocss/logger": "1.55.3",
|
|
48
|
+
"@bamboocss/node": "1.55.3",
|
|
49
|
+
"@bamboocss/core": "1.55.3",
|
|
50
|
+
"@bamboocss/shared": "1.55.3",
|
|
51
|
+
"@bamboocss/types": "1.55.3",
|
|
52
|
+
"@bamboocss/ts-ast": "1.55.3"
|
|
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.
|
|
58
|
+
"@bamboocss/fixture": "1.55.3"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"vite": ">=5"
|