Skip to content

Commit

Permalink
Troubleshooting steps to make HMR work in complex webpack configs
Browse files Browse the repository at this point in the history
  • Loading branch information
non25 committed May 29, 2024
1 parent ad30cba commit fe16735
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,32 @@ Granular mode for HMR (which allows independent HMR for components and templates
### JSX HMR

JSX, by default, is moved to a separate component to perform granular HMR. To disable this, add `jsx: false`.

## Troubleshooting

### Webpack and dynamic exports

If HMR doesn't work for you in webpack, and you see this warning in the browser's console:

> 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.
Consider checking `resolve.mainFields` and `resolve.conditionNames`. Fx. if you have `svelte-loader` in webpack configuration, which suggests adjusting these fields like this:

This comment has been minimized.

Copy link
@vincentfretin

vincentfretin May 30, 2024

Contributor

I would say first just to remove mainFields and conditionNames in your config if there was no reason to configure it. And then if one of the webpack loader needed to configure those like svelte-loader for a particular case where you have svelte and solidjs code in the same repository, be sure to add "..." in the list.
"Fx." stands for "For example"?, first time I see this abbreviation.


```js
resolve: {
mainFields: ['svelte', 'browser', 'module', 'main'],
conditionNames: ['svelte', 'browser', 'import']
}
```

You need to adjust them like this

```js
resolve: {
mainFields: ['svelte', 'browser', '...'],
conditionNames: ['svelte', 'browser', '...'],
// ^^^ this includes default configuration
}
```

That way they will preserve default configuration for conditional exports loading development build of SolidJS.

0 comments on commit fe16735

Please sign in to comment.