@sveltejs/vite-plugin-svelte 1.0.0-next.9 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,214 +1,231 @@
1
- import { Plugin as Plugin_2 } from 'vite';
2
-
3
- export declare type Arrayable<T> = T | T[];
4
-
5
- export declare interface CompileOptions {
6
- format?: ModuleFormat;
7
- name?: string;
8
- filename?: string;
9
- generate?: 'dom' | 'ssr' | false;
10
- sourcemap?: object | string;
11
- outputFilename?: string;
12
- cssOutputFilename?: string;
13
- sveltePath?: string;
14
- dev?: boolean;
15
- accessors?: boolean;
16
- immutable?: boolean;
17
- hydratable?: boolean;
18
- legacy?: boolean;
19
- customElement?: boolean;
20
- tag?: string;
21
- css?: boolean;
22
- loopGuardTimeout?: number;
23
- namespace?: string;
24
- preserveComments?: boolean;
25
- preserveWhitespace?: boolean;
26
- cssHash?: CssHashGetter;
27
- }
28
-
29
- export declare type CssHashGetter = (args: {
30
- name: string;
31
- filename: string | undefined;
32
- css: string;
33
- hash: (input: string) => string;
34
- }) => string;
35
-
36
- export declare type MarkupPreprocessor = (options: {
37
- content: string;
38
- filename: string;
39
- }) => Processed | Promise<Processed>;
40
-
41
- export declare type ModuleFormat = 'esm' | 'cjs';
42
-
43
- export declare interface Options {
44
- /** path to svelte config file, either absolute or relative to vite root*/
45
- configFile?: string;
46
- /** One or more minimatch patterns */
47
- include?: Arrayable<string>;
48
- /** One or more minimatch patterns */
49
- exclude?: Arrayable<string>;
50
- /**
51
- * By default, all ".svelte" files are compiled
52
- * @default ['.svelte']
53
- */
54
- extensions?: string[];
55
- /**
56
- * Optionally, preprocess components with svelte.preprocess:
57
- * \@see https://svelte.dev/docs#svelte_preprocess
58
- */
59
- preprocess?: Arrayable<PreprocessorGroup>;
60
- /** Emit Svelte styles as virtual CSS files for other plugins to process.
61
- * @default true
62
- */
63
- emitCss?: boolean;
64
- /** Options passed to `svelte.compile` method. */
65
- compilerOptions: Partial<CompileOptions>;
66
- onwarn?: undefined | false | ((warning: any, defaultHandler?: any) => void);
67
- /**
68
- * enable/disable hmr. You want this enabled.
69
- *
70
- * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
71
- * DO NOT CUSTOMIZE SVELTE-HMR OPTIONS UNLESS YOU KNOW EXACTLY WHAT YOU ARE DOING
72
- *
73
- * YOU HAVE BEEN WARNED
74
- * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
75
- *
76
- * @default true for development, always false for production
77
- */
78
- hot?: undefined | boolean | {
79
- /**
80
- * preserve all local state
81
- * @default false
82
- */
83
- preserveLocalState?: boolean;
84
- /**
85
- * escape hatchs from preservation of local state
86
- * disable preservation of state for this component
87
- *
88
- * @default ['\@hmr:reset', '\@!hmr']
89
- */
90
- noPreserveStateKey?: string[];
91
- /**
92
- * enable preservation of state for all variables in this component
93
- *
94
- * @default '\@hmr:keep-all'
95
- */
96
- preserveAllLocalStateKey?: string;
97
- /**
98
- * enable preservation of state for a given variable (must be inline or
99
- * above the target variable or variables; can be repeated)
100
- *
101
- * @default '\@hmr:keep'
102
- */
103
- preserveLocalStateKey?: string;
104
- /**
105
- * don't reload on fatal error
106
- *
107
- * @default false
108
- */
109
- noReload?: boolean;
110
- /**
111
- * try to recover after runtime errors during component init
112
- *
113
- * @default true
114
- */
115
- optimistic?: boolean;
116
- /**
117
- * auto accept modules of components that have named exports (i.e. exports
118
- * from context="module")
119
- *
120
- * @default true
121
- */
122
- acceptNamedExports?: boolean;
123
- /**
124
- * auto accept modules of components have accessors (either accessors compile
125
- * option, or \<svelte:option accessors=\{true\} /\>) -- this means that if you
126
- * set accessors compile option globally, you must also set this option to
127
- * true, or no component will be hot reloaded (but there are a lot of edge
128
- * cases that HMR can't support correctly with accessors)
129
- *
130
- * @default true
131
- */
132
- acceptAccessors?: boolean;
133
- /**
134
- * only inject CSS instead of recreating components when only CSS changes
135
- *
136
- * @default true, but vite-plugin-svelte configures this automatically according to emitCss requirements
137
- */
138
- injectCss?: boolean;
139
- /**
140
- * to mitigate FOUC between dispose (remove stylesheet) and accept
141
- *
142
- * note: has no effect when emitCss is true (vite-plugin-svelte default)
143
- * @default 100
144
- */
145
- cssEjectDelay?: number;
146
- /**
147
- * Svelte Native mode
148
- *
149
- * @default false
150
- */
151
- native?: boolean;
152
- /**
153
- * name of the adapter import binding
154
- *
155
- * @default '___SVELTE_HMR_HOT_API_PROXY_ADAPTER'
156
- */
157
- importAdapterName?: string;
158
- /**
159
- * use absolute file paths to import runtime deps of svelte-hmr
160
- * (see https://github.com/rixo/svelte-hmr/issues/11)
161
- *
162
- * @default true
163
- */
164
- absoluteImports?: boolean;
165
- /**
166
- * disable runtime error overlay
167
- *
168
- * @default false
169
- */
170
- noOverlay?: boolean;
171
- /**
172
- * custom import path for hotApi
173
- */
174
- hotApi?: string;
175
- /**
176
- * custom path for adapter
177
- */
178
- adapter?: string;
179
- };
180
- /**
181
- * disable separate hmr update for css files via vite
182
- * @default false
183
- */
184
- disableCssHmr?: boolean;
185
- /**
186
- * use vite as extra css preprocessor EXPERIMENTAL!
187
- * @default false
188
- */
189
- useVitePreprocess?: boolean;
190
- }
191
-
192
- export declare type Preprocessor = (options: {
193
- content: string;
194
- attributes: Record<string, string | boolean>;
195
- filename?: string;
196
- }) => Processed | Promise<Processed>;
197
-
198
- export declare interface PreprocessorGroup {
199
- markup?: MarkupPreprocessor;
200
- style?: Preprocessor;
201
- script?: Preprocessor;
202
- }
203
-
204
- export declare interface Processed {
205
- code: string;
206
- map?: string | object;
207
- dependencies?: string[];
208
- toString?: () => string;
209
- }
210
-
211
- declare function vitePluginSvelte(inlineOptions?: Partial<Options>): Plugin_2;
212
- export default vitePluginSvelte;
213
-
214
- export { }
1
+ import { UserConfig, Plugin } from 'vite';
2
+ import { CompileOptions, Warning } from 'svelte/types/compiler/interfaces';
3
+ export { CompileOptions, Warning } from 'svelte/types/compiler/interfaces';
4
+ import { PreprocessorGroup } from 'svelte/types/compiler/preprocess';
5
+ export { MarkupPreprocessor, Preprocessor, PreprocessorGroup, Processed } from 'svelte/types/compiler/preprocess';
6
+
7
+ declare type Options = Omit<SvelteOptions, 'vitePlugin'> & PluginOptionsInline;
8
+ interface PluginOptionsInline extends PluginOptions {
9
+ /**
10
+ * Path to a svelte config file, either absolute or relative to Vite root
11
+ *
12
+ * set to `false` to ignore the svelte config file
13
+ *
14
+ * @see https://vitejs.dev/config/#root
15
+ */
16
+ configFile?: string | false;
17
+ }
18
+ interface PluginOptions {
19
+ /**
20
+ * A `picomatch` pattern, or array of patterns, which specifies the files the plugin should
21
+ * operate on. By default, all svelte files are included.
22
+ *
23
+ * @see https://github.com/micromatch/picomatch
24
+ */
25
+ include?: Arrayable<string>;
26
+ /**
27
+ * A `picomatch` pattern, or array of patterns, which specifies the files to be ignored by the
28
+ * plugin. By default, no files are ignored.
29
+ *
30
+ * @see https://github.com/micromatch/picomatch
31
+ */
32
+ exclude?: Arrayable<string>;
33
+ /**
34
+ * Emit Svelte styles as virtual CSS files for Vite and other plugins to process
35
+ *
36
+ * @default true
37
+ */
38
+ emitCss?: boolean;
39
+ /**
40
+ * Enable or disable Hot Module Replacement.
41
+ *
42
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
43
+ *
44
+ * DO NOT CUSTOMIZE SVELTE-HMR OPTIONS UNLESS YOU KNOW EXACTLY WHAT YOU ARE DOING
45
+ *
46
+ * YOU HAVE BEEN WARNED
47
+ *
48
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
49
+ *
50
+ * Set an object to pass custom options to svelte-hmr
51
+ *
52
+ * @see https://github.com/rixo/svelte-hmr#options
53
+ * @default true for development, always false for production
54
+ */
55
+ hot?: boolean | {
56
+ injectCss?: boolean;
57
+ [key: string]: any;
58
+ };
59
+ /**
60
+ * Some Vite plugins can contribute additional preprocessors by defining `api.sveltePreprocess`.
61
+ * If you don't want to use them, set this to true to ignore them all or use an array of strings
62
+ * with plugin names to specify which.
63
+ *
64
+ * @default false
65
+ */
66
+ ignorePluginPreprocessors?: boolean | string[];
67
+ /**
68
+ * vite-plugin-svelte automatically handles excluding svelte libraries and reinclusion of their dependencies
69
+ * in vite.optimizeDeps.
70
+ *
71
+ * `disableDependencyReinclusion: true` disables all reinclusions
72
+ * `disableDependencyReinclusion: ['foo','bar']` disables reinclusions for dependencies of foo and bar
73
+ *
74
+ * This should be used for hybrid packages that contain both node and browser dependencies, eg Routify
75
+ *
76
+ * @default false
77
+ */
78
+ disableDependencyReinclusion?: boolean | string[];
79
+ /**
80
+ * These options are considered experimental and breaking changes to them can occur in any release
81
+ */
82
+ experimental?: ExperimentalOptions;
83
+ }
84
+ interface SvelteOptions {
85
+ /**
86
+ * A list of file extensions to be compiled by Svelte
87
+ *
88
+ * @default ['.svelte']
89
+ */
90
+ extensions?: string[];
91
+ /**
92
+ * An array of preprocessors to transform the Svelte source code before compilation
93
+ *
94
+ * @see https://svelte.dev/docs#svelte_preprocess
95
+ */
96
+ preprocess?: Arrayable<PreprocessorGroup>;
97
+ /**
98
+ * The options to be passed to the Svelte compiler. A few options are set by default,
99
+ * including `dev` and `css`. However, some options are non-configurable, like
100
+ * `filename`, `format`, `generate`, and `cssHash` (in dev).
101
+ *
102
+ * @see https://svelte.dev/docs#svelte_compile
103
+ */
104
+ compilerOptions?: Omit<CompileOptions, 'filename' | 'format' | 'generate'>;
105
+ /**
106
+ * Handles warning emitted from the Svelte compiler
107
+ */
108
+ onwarn?: (warning: Warning, defaultHandler?: (warning: Warning) => void) => void;
109
+ /**
110
+ * Options for vite-plugin-svelte
111
+ */
112
+ vitePlugin?: PluginOptions;
113
+ }
114
+ /**
115
+ * These options are considered experimental and breaking changes to them can occur in any release
116
+ */
117
+ interface ExperimentalOptions {
118
+ /**
119
+ * Use extra preprocessors that delegate style and TypeScript preprocessing to native Vite plugins
120
+ *
121
+ * Do not use together with `svelte-preprocess`!
122
+ *
123
+ * @default false
124
+ */
125
+ useVitePreprocess?: boolean;
126
+ /**
127
+ * Force Vite to pre-bundle Svelte libraries
128
+ *
129
+ * @default false
130
+ */
131
+ prebundleSvelteLibraries?: boolean;
132
+ /**
133
+ * If a preprocessor does not provide a sourcemap, a best-effort fallback sourcemap will be provided.
134
+ * This option requires `diff-match-patch` to be installed as a peer dependency.
135
+ *
136
+ * @see https://github.com/google/diff-match-patch
137
+ * @default false
138
+ */
139
+ generateMissingPreprocessorSourcemaps?: boolean;
140
+ /**
141
+ * A function to update `compilerOptions` before compilation
142
+ *
143
+ * `data.filename` - The file to be compiled
144
+ * `data.code` - The preprocessed Svelte code
145
+ * `data.compileOptions` - The current compiler options
146
+ *
147
+ * To change part of the compiler options, return an object with the changes you need.
148
+ *
149
+ * @example
150
+ * ```
151
+ * ({ filename, compileOptions }) => {
152
+ * // Dynamically set hydration per Svelte file
153
+ * if (compileWithHydratable(filename) && !compileOptions.hydratable) {
154
+ * return { hydratable: true };
155
+ * }
156
+ * }
157
+ * ```
158
+ */
159
+ dynamicCompileOptions?: (data: {
160
+ filename: string;
161
+ code: string;
162
+ compileOptions: Partial<CompileOptions>;
163
+ }) => Promise<Partial<CompileOptions> | void> | Partial<CompileOptions> | void;
164
+ /**
165
+ * enable svelte inspector
166
+ */
167
+ inspector?: InspectorOptions | boolean;
168
+ /**
169
+ * send a websocket message with svelte compiler warnings during dev
170
+ *
171
+ */
172
+ sendWarningsToBrowser?: boolean;
173
+ }
174
+ interface InspectorOptions {
175
+ /**
176
+ * define a key combo to toggle inspector,
177
+ * @default 'control-shift' on windows, 'meta-shift' on other os
178
+ *
179
+ * any number of modifiers `control` `shift` `alt` `meta` followed by zero or one regular key, separated by -
180
+ * examples: control-shift, control-o, control-alt-s meta-x control-meta
181
+ * Some keys have native behavior (e.g. alt-s opens history menu on firefox).
182
+ * To avoid conflicts or accidentally typing into inputs, modifier only combinations are recommended.
183
+ */
184
+ toggleKeyCombo?: string;
185
+ /**
186
+ * inspector is automatically disabled when releasing toggleKeyCombo after holding it for a longpress
187
+ * @default false
188
+ */
189
+ holdMode?: boolean;
190
+ /**
191
+ * when to show the toggle button
192
+ * @default 'active'
193
+ */
194
+ showToggleButton?: 'always' | 'active' | 'never';
195
+ /**
196
+ * where to display the toggle button
197
+ * @default top-right
198
+ */
199
+ toggleButtonPos?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
200
+ /**
201
+ * inject custom styles when inspector is active
202
+ */
203
+ customStyles?: boolean;
204
+ /**
205
+ * append an import to the module id ending with `appendTo` instead of adding a script into body
206
+ * useful for frameworks that do not support trannsformIndexHtml hook
207
+ *
208
+ * WARNING: only set this if you know exactly what it does.
209
+ * Regular users of vite-plugin-svelte or SvelteKit do not need it
210
+ */
211
+ appendTo?: string;
212
+ }
213
+ declare type ModuleFormat = NonNullable<CompileOptions['format']>;
214
+ declare type CssHashGetter = NonNullable<CompileOptions['cssHash']>;
215
+ declare type Arrayable<T> = T | T[];
216
+
217
+ declare function loadSvelteConfig(viteConfig?: UserConfig, inlineOptions?: Partial<Options>): Promise<Partial<SvelteOptions> | undefined>;
218
+
219
+ declare type SvelteWarningsMessage = {
220
+ id: string;
221
+ filename: string;
222
+ normalizedFilename: string;
223
+ timestamp: number;
224
+ warnings: Warning[];
225
+ allWarnings: Warning[];
226
+ rawWarnings: Warning[];
227
+ };
228
+
229
+ declare function svelte(inlineOptions?: Partial<Options>): Plugin[];
230
+
231
+ export { Arrayable, CssHashGetter, ModuleFormat, Options, PluginOptions, SvelteOptions, SvelteWarningsMessage, loadSvelteConfig, svelte };