feat: add auto reload on restart (#70)

This commit adds support for auto reloading open pages when fresh
restarts. This is particularly useful when `deno run` is used with
`--watch`.
This commit is contained in:
Luca Casonato
2021-10-27 01:19:01 +02:00
committed by GitHub
parent f0b96b80c8
commit 95289380f3
4 changed files with 46 additions and 3 deletions
+5 -1
View File
@@ -7,6 +7,7 @@ import { Page, Renderer } from "./types.ts";
import { PageProps } from "../runtime/types.ts";
import { SUSPENSE_CONTEXT } from "../runtime/suspense.ts";
import { HEAD_CONTEXT } from "../runtime/head.ts";
import { REFRESH_JS_URL } from "./constants.ts";
export interface RenderOptions {
page: Page;
@@ -172,7 +173,10 @@ export async function* render(opts: RenderOptions): AsyncIterable<string> {
// If this is a static render (runtimeJS is false), then we don't need to
// render the props into the template.
if (opts.imports.length === 0) {
if (
opts.imports.length === 0 ||
(opts.imports.length === 1 && opts.imports[0] === REFRESH_JS_URL)
) {
templateProps = undefined;
}