aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-09-06 03:37:17 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-09-06 03:37:17 -0700
commit01086954380a5266ddb988a344ff6251c9962386 (patch)
tree5b7e9db0b82f956bd5c6e1189cc91964a36e9f4d
parent34b55c33508d0e4dcf0fef0e21c19dfaba90ad6c (diff)
downloadbun-01086954380a5266ddb988a344ff6251c9962386.tar.gz
bun-01086954380a5266ddb988a344ff6251c9962386.tar.zst
bun-01086954380a5266ddb988a344ff6251c9962386.zip
Always store the list of stylesheets
Former-commit-id: 867ebf04348439c48037e4944fef6d48a33555bd
-rw-r--r--src/runtime/hmr.ts10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/runtime/hmr.ts b/src/runtime/hmr.ts
index 46b841b7a..2c4f8eb35 100644
--- a/src/runtime/hmr.ts
+++ b/src/runtime/hmr.ts
@@ -513,9 +513,11 @@ if (typeof window !== "undefined") {
}
}
+ static allImportedStyles = new Set();
static onCSSImport(event) {
+ HMRClient.allImportedStyles.add(event.detail);
+
if (globalThis["Bun_disableCSSImports"]) {
- document.removeEventListener("onimportcss", HMRClient.onCSSImport);
return;
}
@@ -551,7 +553,6 @@ if (typeof window !== "undefined") {
HMRClient.importCSS(
new Promise((resolve, reject) => {
if (globalThis["Bun_disableCSSImports"]) {
- document.removeEventListener("onimportcss", HMRClient.onCSSImport);
return;
}
@@ -587,7 +588,8 @@ if (typeof window !== "undefined") {
this.client = new HMRClient();
this.client.verbose = verbose;
this.client.start();
- globalThis["BUN_HMR"] = this.client;
+ globalThis["__BUN_HMR"] = this.client;
+ globalThis["__BUN"] = this;
}
handleBuildFailure(buffer: ByteBuffer, timestamp: number) {
@@ -1300,7 +1302,7 @@ if (typeof window !== "undefined") {
__FastRefreshModule = FastRefreshModule;
__HMRClient = HMRClient;
- if (!globalThis["Bun_disableCSSImports"] && "document" in globalThis) {
+ if ("document" in globalThis) {
document.addEventListener("onimportcss", HMRClient.onCSSImport, {
passive: true,
});