@@ -3,6 +3,15 @@ import { ConfigEnv, UserConfig, ViteDevServer } from 'vite';
33import { log } from './log' ;
44import { loadSvelteConfig } from './load-svelte-config' ;
55import { SVELTE_HMR_IMPORTS , SVELTE_IMPORTS , SVELTE_RESOLVE_MAIN_FIELDS } from './constants' ;
6+ // eslint-disable-next-line node/no-missing-import
7+ import { CompileOptions } from 'svelte/types/compiler/interfaces' ;
8+ import {
9+ MarkupPreprocessor ,
10+ Preprocessor ,
11+ PreprocessorGroup ,
12+ Processed
13+ // eslint-disable-next-line node/no-missing-import
14+ } from 'svelte/types/compiler/preprocess' ;
615
716const knownOptions = new Set ( [
817 'configFile' ,
@@ -420,63 +429,11 @@ export interface ResolvedOptions extends Options {
420429 server ?: ViteDevServer ;
421430}
422431
423- // TODO import from appropriate places
424- export declare type ModuleFormat = 'esm' | 'cjs' ;
432+ export type { CompileOptions , Processed , MarkupPreprocessor , Preprocessor , PreprocessorGroup } ;
425433
426- export interface CompileOptions {
427- format ?: ModuleFormat ;
428- name ?: string ;
429- filename ?: string ;
430- generate ?: 'dom' | 'ssr' | false ;
431- sourcemap ?: object | string ;
432- outputFilename ?: string ;
433- cssOutputFilename ?: string ;
434- sveltePath ?: string ;
435- dev ?: boolean ;
436- accessors ?: boolean ;
437- immutable ?: boolean ;
438- hydratable ?: boolean ;
439- legacy ?: boolean ;
440- customElement ?: boolean ;
441- tag ?: string ;
442- css ?: boolean ;
443- loopGuardTimeout ?: number ;
444- namespace ?: string ;
445- preserveComments ?: boolean ;
446- preserveWhitespace ?: boolean ;
447- cssHash ?: CssHashGetter ;
448- }
449-
450- export interface Processed {
451- code : string ;
452- map ?: string | object ;
453- dependencies ?: string [ ] ;
454- toString ?: ( ) => string ;
455- }
456-
457- export declare type CssHashGetter = ( args : {
458- name : string ;
459- filename : string | undefined ;
460- css : string ;
461- hash : ( input : string ) => string ;
462- } ) => string ;
463-
464- export declare type MarkupPreprocessor = ( options : {
465- content : string ;
466- filename : string ;
467- } ) => Processed | Promise < Processed > ;
468-
469- export declare type Preprocessor = ( options : {
470- content : string ;
471- attributes : Record < string , string | boolean > ;
472- filename ?: string ;
473- } ) => Processed | Promise < Processed > ;
434+ export type ModuleFormat = NonNullable < CompileOptions [ 'format' ] > ;
474435
475- export interface PreprocessorGroup {
476- markup ?: MarkupPreprocessor ;
477- style ?: Preprocessor ;
478- script ?: Preprocessor ;
479- }
436+ export type CssHashGetter = NonNullable < CompileOptions [ 'cssHash' ] > ;
480437
481438export type Arrayable < T > = T | T [ ] ;
482439
0 commit comments