@@ -4,7 +4,7 @@ import { log } from './log';
4
4
import { loadSvelteConfig } from './load-svelte-config' ;
5
5
import { SVELTE_HMR_IMPORTS , SVELTE_IMPORTS , SVELTE_RESOLVE_MAIN_FIELDS } from './constants' ;
6
6
// eslint-disable-next-line node/no-missing-import
7
- import { CompileOptions } from 'svelte/types/compiler/interfaces' ;
7
+ import { CompileOptions , Warning } from 'svelte/types/compiler/interfaces' ;
8
8
import {
9
9
MarkupPreprocessor ,
10
10
Preprocessor ,
@@ -23,7 +23,6 @@ const knownOptions = new Set([
23
23
'onwarn' ,
24
24
'preprocess' ,
25
25
'hot' ,
26
- 'disableCssHmr' ,
27
26
'ignorePluginPreprocessors' ,
28
27
'experimental'
29
28
] ) ;
@@ -261,132 +260,11 @@ export interface Options {
261
260
* YOU HAVE BEEN WARNED
262
261
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
263
262
*
263
+ * set to object to pass custom options to svelte-hmr, see https://github.com/rixo/svelte-hmr#options
264
+ *
264
265
* @default true for development, always false for production
265
266
*/
266
- hot ?:
267
- | undefined
268
- | boolean
269
- | {
270
- // svelte-hmr options
271
- /**
272
- * preserve all local state
273
- * @default false
274
- */
275
- preserveLocalState ?: boolean ;
276
-
277
- /**
278
- * escape hatchs from preservation of local state
279
- * disable preservation of state for this component
280
- *
281
- * @default ['\@hmr:reset', '\@!hmr']
282
- */
283
- noPreserveStateKey ?: string [ ] ;
284
-
285
- /**
286
- * enable preservation of state for all variables in this component
287
- *
288
- * @default '\@hmr:keep-all'
289
- */
290
- preserveAllLocalStateKey ?: string ;
291
-
292
- /**
293
- * enable preservation of state for a given variable (must be inline or
294
- * above the target variable or variables; can be repeated)
295
- *
296
- * @default '\@hmr:keep'
297
- */
298
- preserveLocalStateKey ?: string ;
299
-
300
- /**
301
- * don't reload on fatal error
302
- *
303
- * @default false
304
- */
305
- noReload ?: boolean ;
306
-
307
- /**
308
- * try to recover after runtime errors during component init
309
- *
310
- * @default true
311
- */
312
- optimistic ?: boolean ;
313
- /**
314
- * auto accept modules of components that have named exports (i.e. exports
315
- * from context="module")
316
- *
317
- * @default true
318
- */
319
- acceptNamedExports ?: boolean ;
320
-
321
- /**
322
- * auto accept modules of components have accessors (either accessors compile
323
- * option, or \<svelte:option accessors=\{true\} /\>) -- this means that if you
324
- * set accessors compile option globally, you must also set this option to
325
- * true, or no component will be hot reloaded (but there are a lot of edge
326
- * cases that HMR can't support correctly with accessors)
327
- *
328
- * @default true
329
- */
330
- acceptAccessors ?: boolean ;
331
-
332
- /**
333
- * only inject CSS instead of recreating components when only CSS changes
334
- *
335
- * @default true, but vite-plugin-svelte configures this automatically according to emitCss requirements
336
- */
337
- injectCss ?: boolean ;
338
-
339
- /**
340
- * to mitigate FOUC between dispose (remove stylesheet) and accept
341
- *
342
- * note: has no effect when emitCss is true (vite-plugin-svelte default)
343
- * @default 100
344
- */
345
- cssEjectDelay ?: number ;
346
-
347
- //
348
- /**
349
- * Svelte Native mode
350
- *
351
- * @default false
352
- */
353
- native ?: boolean ;
354
-
355
- /**
356
- * name of the adapter import binding
357
- *
358
- * @default '___SVELTE_HMR_HOT_API_PROXY_ADAPTER'
359
- */
360
- importAdapterName ?: string ;
361
- /**
362
- * use absolute file paths to import runtime deps of svelte-hmr
363
- * (see https://github.com/rixo/svelte-hmr/issues/11)
364
- *
365
- * @default true
366
- */
367
- absoluteImports ?: boolean ;
368
-
369
- /**
370
- * disable runtime error overlay
371
- *
372
- * @default false
373
- */
374
- noOverlay ?: boolean ;
375
-
376
- /**
377
- * custom import path for hotApi
378
- */
379
- hotApi ?: string ;
380
- /**
381
- * custom path for adapter
382
- */
383
- adapter ?: string ;
384
- } ;
385
- /**
386
- * disable separate hmr update for css files via vite
387
- * @default false
388
- */
389
- disableCssHmr ?: boolean ;
267
+ hot ?: boolean | { injectCss ?: boolean ; [ key : string ] : any } ;
390
268
391
269
/**
392
270
* vite plugins can contribute additional preprocessors by defining api.sveltePreprocess.
@@ -429,28 +307,17 @@ export interface ResolvedOptions extends Options {
429
307
server ?: ViteDevServer ;
430
308
}
431
309
432
- export type { CompileOptions , Processed , MarkupPreprocessor , Preprocessor , PreprocessorGroup } ;
310
+ export type {
311
+ CompileOptions ,
312
+ Processed ,
313
+ MarkupPreprocessor ,
314
+ Preprocessor ,
315
+ PreprocessorGroup ,
316
+ Warning
317
+ } ;
433
318
434
319
export type ModuleFormat = NonNullable < CompileOptions [ 'format' ] > ;
435
320
436
321
export type CssHashGetter = NonNullable < CompileOptions [ 'cssHash' ] > ;
437
322
438
323
export type Arrayable < T > = T | T [ ] ;
439
-
440
- export interface Warning {
441
- start ?: {
442
- line : number ;
443
- column : number ;
444
- pos ?: number ;
445
- } ;
446
- end ?: {
447
- line : number ;
448
- column : number ;
449
- } ;
450
- pos ?: number ;
451
- code : string ;
452
- message : string ;
453
- filename ?: string ;
454
- frame ?: string ;
455
- toString : ( ) => string ;
456
- }
0 commit comments