@@ -4,6 +4,8 @@ import { readFileSync } from 'fs';
4
4
import { mergeAndConcat } from 'merge-anything' ;
5
5
import { createRequire } from 'module' ;
6
6
import solidRefresh from 'solid-refresh/babel' ;
7
+ // TODO use proper path
8
+ import type { Options as RefreshOptions } from 'solid-refresh/dist/types/src/babel/core/types' ;
7
9
import { createFilter } from 'vite' ;
8
10
import type { Alias , AliasOptions , Plugin , FilterPattern } from 'vite' ;
9
11
import { crawlFrameworkPkgs } from 'vitefu' ;
@@ -51,6 +53,7 @@ export interface Options {
51
53
* This will inject HMR runtime in dev mode. Has no effect in prod. If
52
54
* set to `false`, it won't inject the runtime in dev.
53
55
*
56
+ * @deprecated use `refresh` instead
54
57
* @default true
55
58
*/
56
59
hot : boolean ;
@@ -142,6 +145,8 @@ export interface Options {
142
145
*/
143
146
builtIns ?: string [ ] ;
144
147
} ;
148
+
149
+ refresh : Omit < RefreshOptions & { disabled : boolean } , 'bundler' | 'fixRender' > ;
145
150
}
146
151
147
152
function getExtension ( filename : string ) : string {
@@ -255,7 +260,7 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
255
260
} ,
256
261
257
262
configResolved ( config ) {
258
- needHmr = config . command === 'serve' && config . mode !== 'production' && options . hot !== false ;
263
+ needHmr = config . command === 'serve' && config . mode !== 'production' && ( options . hot !== false || ! options . refresh . disabled ) ;
259
264
} ,
260
265
261
266
resolveId ( id ) {
@@ -318,7 +323,12 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
318
323
filename : id ,
319
324
sourceFileName : id ,
320
325
presets : [ [ solid , { ...solidOptions , ...( options . solid || { } ) } ] ] ,
321
- plugins : needHmr && ! isSsr && ! inNodeModules ? [ [ solidRefresh , { bundler : 'vite' } ] ] : [ ] ,
326
+ plugins : needHmr && ! isSsr && ! inNodeModules ? [ [ solidRefresh , {
327
+ bundler : 'vite' ,
328
+ fixRender : true ,
329
+ imports : options . refresh . imports ,
330
+ granular : options . refresh . granular ,
331
+ } ] ] : [ ] ,
322
332
ast : false ,
323
333
sourceMaps : true ,
324
334
configFile : false ,
0 commit comments