Skip to content

Commit c0f0a17

Browse files
committed
fix: update svelte-hmr options interface and add warning to leave it at defaults
1 parent 3db53b4 commit c0f0a17

File tree

1 file changed

+99
-15
lines changed

1 file changed

+99
-15
lines changed

packages/vite-plugin-svelte/src/utils/options.ts

Lines changed: 99 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -182,50 +182,134 @@ export interface Options {
182182

183183
onwarn?: undefined | false | ((warning: any, defaultHandler?: any) => void)
184184

185-
/** Enable/configure HMR */
185+
/**
186+
* enable/disable hmr. You want this enabled.
187+
*
188+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
189+
* DO NOT CUSTOMIZE SVELTE-HMR OPTIONS UNLESS YOU KNOW EXACTLY WHAT YOU ARE DOING
190+
*
191+
* YOU HAVE BEEN WARNED
192+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
193+
*
194+
* @default true for development, always false for production
195+
*/
186196
hot?:
187197
| undefined
188198
| boolean
189199
| {
200+
// svelte-hmr options
190201
/**
191-
* Enable state preservation when a component is updated by HMR for every
192-
* components.
202+
* preserve all local state
193203
* @default false
194204
*/
195-
preserveState?: boolean
205+
preserveLocalState?: boolean
206+
207+
/**
208+
* escape hatchs from preservation of local state
209+
* disable preservation of state for this component
210+
*
211+
* @default ['@hmr:reset', '@!hmr']
212+
*/
213+
noPreserveStateKey?: string[]
196214

197215
/**
198-
* If this string appears anywhere in your component's code, then local
199-
* state won't be preserved, even when noPreserveState is false.
200-
* @default '\@hmr:reset'
216+
* enable preservation of state for all variables in this component
217+
*
218+
* @default '@hmr:keep-all'
201219
*/
202-
noPreserveStateKey?: string
220+
preserveAllLocalStateKey?: string
203221

204222
/**
205-
* If this string appears next to a `let` variable, the value of this
206-
* variable will be preserved accross HMR updates.
207-
* @default '\@hmr:keep'
223+
* enable preservation of state for a given variable (must be inline or
224+
* above the target variable or variables; can be repeated)
225+
*
226+
* @default '@hmr:keep'
208227
*/
209-
preserveStateKey?: string
228+
preserveLocalStateKey?: string
210229

211230
/**
212-
* Prevent doing a full reload on next HMR update after fatal error.
231+
* don't reload on fatal error
232+
*
213233
* @default false
214234
*/
215235
noReload?: boolean
216236

217237
/**
218-
* Try to recover after runtime errors in component init.
238+
* try to recover after runtime errors during component init
239+
*
219240
* @default true
220241
*/
221242
optimistic?: boolean
243+
/**
244+
* auto accept modules of components that have named exports (i.e. exports
245+
* from context="module")
246+
*
247+
* @default true
248+
*/
249+
acceptNamedExports?: boolean
250+
251+
/**
252+
* auto accept modules of components have accessors (either accessors compile
253+
* option, or <svelte:option accessors={true} />) -- this means that if you
254+
* set accessors compile option globally, you must also set this option to
255+
* true, or no component will be hot reloaded (but there are a lot of edge
256+
* cases that HMR can't support correctly with accessors)
257+
*
258+
* @default true
259+
*/
260+
acceptAccessors?: boolean
222261

223-
noDisableCss?: boolean
262+
/**
263+
* only inject CSS instead of recreating components when only CSS changes
264+
*
265+
* @default true, but vite-plugin-svelte configures this automatically according to emitCss requirements
266+
*/
224267
injectCss?: boolean
268+
269+
/**
270+
* to mitigate FOUC between dispose (remove stylesheet) and accept
271+
*
272+
* note: has no effect when emitCss is true (vite-plugin-svelte default)
273+
* @default 100
274+
*/
225275
cssEjectDelay?: number
276+
277+
//
278+
/**
279+
* Svelte Native mode
280+
*
281+
* @default false
282+
*/
283+
native?: boolean
284+
285+
/**
286+
* name of the adapter import binding
287+
*
288+
* @default '___SVELTE_HMR_HOT_API_PROXY_ADAPTER'
289+
*/
290+
importAdapterName?: string
291+
/**
292+
* use absolute file paths to import runtime deps of svelte-hmr
293+
* (see https://github.com/rixo/svelte-hmr/issues/11)
294+
*
295+
* @default true
296+
*/
226297
absoluteImports?: boolean
227298

299+
/**
300+
* disable runtime error overlay
301+
*
302+
* @default false
303+
*/
304+
noOverlay?: boolean
305+
306+
/**
307+
* custom import path for hotApi
308+
*/
228309
hotApi?: string
310+
/**
311+
* custom path for adapter
312+
*/
229313
adapter?: string
230314
}
231315
/**

0 commit comments

Comments
 (0)