@@ -4,8 +4,10 @@ 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/babel' ;
9
+ import type { Alias , AliasOptions , FilterPattern , Plugin } from 'vite' ;
7
10
import { createFilter } from 'vite' ;
8
- import type { Alias , AliasOptions , Plugin , FilterPattern } from 'vite' ;
9
11
import { crawlFrameworkPkgs } from 'vitefu' ;
10
12
11
13
const require = createRequire ( import . meta. url ) ;
@@ -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 ) {
@@ -307,7 +312,19 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
307
312
308
313
return extensionOptions . typescript ;
309
314
} ) ;
310
- const plugins : NonNullable < NonNullable < babel . TransformOptions [ 'parserOpts' ] > [ 'plugins' ] > = [ 'jsx' ]
315
+ const plugins : NonNullable < NonNullable < babel . TransformOptions [ 'parserOpts' ] > [ 'plugins' ] > = [
316
+ 'jsx' ,
317
+ // import { example } from 'example' with { example: true };
318
+ 'importAttributes' ,
319
+ // () => throw example
320
+ 'throwExpressions' ,
321
+ // You know what this is
322
+ 'decorators' ,
323
+ // const { #example: example } = this;
324
+ 'destructuringPrivate' ,
325
+ // using example = myExample()
326
+ 'explicitResourceManagement' ,
327
+ ] ;
311
328
312
329
if ( shouldBeProcessedWithTypescript ) {
313
330
plugins . push ( 'typescript' ) ;
@@ -318,7 +335,12 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
318
335
filename : id ,
319
336
sourceFileName : id ,
320
337
presets : [ [ solid , { ...solidOptions , ...( options . solid || { } ) } ] ] ,
321
- plugins : needHmr && ! isSsr && ! inNodeModules ? [ [ solidRefresh , { bundler : 'vite' } ] ] : [ ] ,
338
+ plugins : needHmr && ! isSsr && ! inNodeModules ? [ [ solidRefresh , {
339
+ bundler : 'vite' ,
340
+ fixRender : true ,
341
+ imports : options . refresh . imports ,
342
+ granular : options . refresh . granular ,
343
+ } ] ] : [ ] ,
322
344
ast : false ,
323
345
sourceMaps : true ,
324
346
configFile : false ,
0 commit comments