From 0181578698da0d7ca9e96e05224acbbbf62fe64d Mon Sep 17 00:00:00 2001 From: Alexandre Date: Sat, 1 Aug 2020 00:23:02 +0200 Subject: [PATCH] :sparkles: auto-hmr --- js/src/index.js | 15 ++------------- ts/src/index.ts | 15 ++------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/js/src/index.js b/js/src/index.js index 33a4ffc..040339c 100644 --- a/js/src/index.js +++ b/js/src/index.js @@ -3,16 +3,5 @@ import { render } from "solid-js/dom"; import "./index.css"; import App from "./App"; -const rootEl = document.getElementById("root"); -const dispose = render(() => App, rootEl); - -// HMR stuff, this will be automatically removed during build -// /!\ You need to add "vite" in the "compilerOptions.types" of your tsconfig.json -// if you want to avoid type errors here -if (import.meta.hot) { - import.meta.hot.accept(); - import.meta.hot.dispose(() => { - dispose(); - rootEl.textContent = ""; - }); -} +export const rootEl = document.getElementById("root"); +export const dispose = render(() => App, rootEl); diff --git a/ts/src/index.ts b/ts/src/index.ts index 33a4ffc..040339c 100644 --- a/ts/src/index.ts +++ b/ts/src/index.ts @@ -3,16 +3,5 @@ import { render } from "solid-js/dom"; import "./index.css"; import App from "./App"; -const rootEl = document.getElementById("root"); -const dispose = render(() => App, rootEl); - -// HMR stuff, this will be automatically removed during build -// /!\ You need to add "vite" in the "compilerOptions.types" of your tsconfig.json -// if you want to avoid type errors here -if (import.meta.hot) { - import.meta.hot.accept(); - import.meta.hot.dispose(() => { - dispose(); - rootEl.textContent = ""; - }); -} +export const rootEl = document.getElementById("root"); +export const dispose = render(() => App, rootEl);