From e1b2d29edad7ecd57c2189254f947fc31faf5d71 Mon Sep 17 00:00:00 2001 From: Dominic Gannaway Date: Wed, 10 Apr 2024 20:45:01 +0100 Subject: [PATCH] chore: add hmr compiler flag (#11112) * chore: add hmr compiler flag * lint --- packages/svelte/src/compiler/types/index.d.ts | 7 +++++++ packages/svelte/src/compiler/validate-options.js | 2 ++ packages/svelte/types/index.d.ts | 12 ++++++++++++ 3 files changed, 21 insertions(+) diff --git a/packages/svelte/src/compiler/types/index.d.ts b/packages/svelte/src/compiler/types/index.d.ts index ddd2ef6cd7..2d87299898 100644 --- a/packages/svelte/src/compiler/types/index.d.ts +++ b/packages/svelte/src/compiler/types/index.d.ts @@ -178,6 +178,12 @@ export interface CompileOptions extends ModuleCompileOptions { * @default null */ cssOutputFilename?: string; + /** + * If `true`, compiles components with hot reloading support. + * + * @default false + */ + hmr?: boolean; } export interface ModuleCompileOptions { @@ -225,6 +231,7 @@ export type ValidatedCompileOptions = ValidatedModuleCompileOptions & legacy: Required['legacy']>; runes: CompileOptions['runes']; customElementOptions: SvelteOptions['customElement']; + hmr: CompileOptions['hmr']; }; export type DeclarationKind = diff --git a/packages/svelte/src/compiler/validate-options.js b/packages/svelte/src/compiler/validate-options.js index 1151ad0dc1..6c12a43e2b 100644 --- a/packages/svelte/src/compiler/validate-options.js +++ b/packages/svelte/src/compiler/validate-options.js @@ -95,6 +95,8 @@ export const validate_component_options = runes: boolean(undefined), + hmr: boolean(false), + sourcemap: validator(undefined, (input) => { // Source maps can take on a variety of values, including string, JSON, map objects from magic-string and source-map, // so there's no good way to check type validity here diff --git a/packages/svelte/types/index.d.ts b/packages/svelte/types/index.d.ts index fa84d846cc..fb90150af7 100644 --- a/packages/svelte/types/index.d.ts +++ b/packages/svelte/types/index.d.ts @@ -670,6 +670,12 @@ declare module 'svelte/compiler' { * @default null */ cssOutputFilename?: string; + /** + * If `true`, compiles components with hot reloading support. + * + * @default false + */ + hmr?: boolean; } interface ModuleCompileOptions { @@ -2449,6 +2455,12 @@ declare module 'svelte/types/compiler/interfaces' { * @default null */ cssOutputFilename?: string; + /** + * If `true`, compiles components with hot reloading support. + * + * @default false + */ + hmr?: boolean; } interface ModuleCompileOptions {