Skip to content

Commit fe16735

Browse files
committed
Troubleshooting steps to make HMR work in complex webpack configs
1 parent ad30cba commit fe16735

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

+29
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,32 @@ Granular mode for HMR (which allows independent HMR for components and templates
226226
### JSX HMR
227227

228228
JSX, by default, is moved to a separate component to perform granular HMR. To disable this, add `jsx: false`.
229+
230+
## Troubleshooting
231+
232+
### Webpack and dynamic exports
233+
234+
If HMR doesn't work for you in webpack, and you see this warning in the browser's console:
235+
236+
> To use solid-refresh, you need to use the dev build of SolidJS. Make sure your build system supports package.json conditional exports and has the 'development' condition turned on.
237+
238+
Consider checking `resolve.mainFields` and `resolve.conditionNames`. Fx. if you have `svelte-loader` in webpack configuration, which suggests adjusting these fields like this:
239+
240+
```js
241+
resolve: {
242+
mainFields: ['svelte', 'browser', 'module', 'main'],
243+
conditionNames: ['svelte', 'browser', 'import']
244+
}
245+
```
246+
247+
You need to adjust them like this
248+
249+
```js
250+
resolve: {
251+
mainFields: ['svelte', 'browser', '...'],
252+
conditionNames: ['svelte', 'browser', '...'],
253+
// ^^^ this includes default configuration
254+
}
255+
```
256+
257+
That way they will preserve default configuration for conditional exports loading development build of SolidJS.

0 commit comments

Comments
 (0)