Skip to content

Commit 92a5533

Browse files
committed
Add new refresh config
1 parent 9b59fdc commit 92a5533

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"@types/babel__core": "^7.20.4",
4646
"babel-preset-solid": "^1.8.4",
4747
"merge-anything": "^5.1.7",
48-
"solid-refresh": "^0.6.3",
48+
"solid-refresh": "^0.7.0",
4949
"vitefu": "^0.2.5"
5050
},
5151
"devDependencies": {

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { readFileSync } from 'fs';
44
import { mergeAndConcat } from 'merge-anything';
55
import { createRequire } from 'module';
66
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';
79
import { createFilter } from 'vite';
810
import type { Alias, AliasOptions, Plugin, FilterPattern } from 'vite';
911
import { crawlFrameworkPkgs } from 'vitefu';
@@ -51,6 +53,7 @@ export interface Options {
5153
* This will inject HMR runtime in dev mode. Has no effect in prod. If
5254
* set to `false`, it won't inject the runtime in dev.
5355
*
56+
* @deprecated use `refresh` instead
5457
* @default true
5558
*/
5659
hot: boolean;
@@ -142,6 +145,8 @@ export interface Options {
142145
*/
143146
builtIns?: string[];
144147
};
148+
149+
refresh: Omit<RefreshOptions & { disabled: boolean }, 'bundler' | 'fixRender'>;
145150
}
146151

147152
function getExtension(filename: string): string {
@@ -255,7 +260,7 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
255260
},
256261

257262
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);
259264
},
260265

261266
resolveId(id) {
@@ -318,7 +323,12 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
318323
filename: id,
319324
sourceFileName: id,
320325
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+
}]] : [],
322332
ast: false,
323333
sourceMaps: true,
324334
configFile: false,

0 commit comments

Comments
 (0)