Skip to content

Commit

Permalink
New Solid Refresh (#34)
Browse files Browse the repository at this point in the history
* Update .prettierrc

* Rework HMR

* Fix build

* Update package.json

* Fix output

* Update package.json

* Fix build

* Fix babel exports

* Update package.json

* Fix generator call

* Update babel.ts

* Fix generator to shim for cjs/esm

* Migrate to `js-xxhash` for signature generation

* Fix typo

* Fix dependency generation

* Remove `js-xxhash`

* Drop Parcel from the Setup section

* Restructure `src/`

* Fix node unwraps for TS

* Fix snapshots

* Drop support for anonymous components

* Fix name generation

* Fix `$$refresh` interface

* Update package.json

* Update index.ts

* Fix build

* Update package.json

* Update package.json

* Update package.json

* Fix refresh behavior on vite

* Update package.json

* Update index.ts

* Update vite snapshots

* Fix esm refresh behavior

* Update package.json

* Prioritize context patching

* Add `location` and `solid-refresh` naming scheme

* Fix module invalidation in vite

* Fix location assignment

* Fix proxy components not updating for late dependent module

* Fix key iteration for registered data

* Fix dependency comparison to be out-of-order

* Update is-list-updated.ts

* Fix `isInTypescript` recursion

* Fix decline calls

* Fix snapshots

* Update package.json

* Update README.md

* Revert info
  • Loading branch information
lxsmnsyc authored Mar 1, 2023
1 parent cbee794 commit 21c4df5
Show file tree
Hide file tree
Showing 31 changed files with 4,028 additions and 4,280 deletions.
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"trailingComma": "none",
"tabWidth": 2,
"semi": true,
"singleQuote": false,
"singleQuote": true,
"arrowParens": "avoid",
"printWidth": 100
}
36 changes: 7 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,21 @@ pnpm add -D solid-refresh

This project aims to provide HMR for Solid for various bundlers. It comes with a babel plugin and a runtime. Over time I hope to add different bundlers. Today it supports:

* Webpack (for strict ESM, use option `bundler: "webpack5"`)
* Parcel
* Nollup
* Vite (with option `bundler: "vite"`)
* Snowpack (with option `bundler: "esm"`)
* Webpack (for strict ESM, use option `bundler: "webpack5"`)
* Nollup

## Setup

### Vite

`solid-refresh` is already built into [`vite-plugin-solid`](https://github.com/solidjs/vite-plugin-solid).

### Parcel

You can add the following to `.babelrc`:

```json
{
"env": {
"development": {
"plugins": [
["module:solid-refresh/babel"]
]
}
}
}
```

### Webpack

You can follow [this guide](https://webpack.js.org/guides/hot-module-replacement#enabling-hmr) first.

Requires the use of [`babel-loader`](https://www.npmjs.com/package/babel-loader). Add the following to `.babelrc`:

```json
Expand All @@ -60,7 +45,7 @@ Requires the use of [`babel-loader`](https://www.npmjs.com/package/babel-loader)
}
```

If you're using strict ESM:
If you're using strict ESM a.k.a. `import.meta.webpackHot`:

```json
{
Expand Down Expand Up @@ -111,8 +96,10 @@ Requires the use of [`@snowpack/plugin-babel`](https://www.npmjs.com/package/@sn

### Other dev servers

* [`Parcel`](https://parceljs.org/) - ParcelJS doesn't support [conditional exports](https://nodejs.org/api/packages.html#conditional-exports) yet, which makes ParcelJS load the production build of SolidJS instead of its development build.
* [`wmr`](https://wmr.dev/) - SolidJS is yet to be supported or isn't clear yet. It will use the same config as Snowpack.
* [`rollup-plugin-hot`](https://github.com/rixo/rollup-plugin-hot) - The library uses almost an ESM HMR-like API however it behaves the same way as Parcel. Supporting this library is still unclear.
* [`@web/dev-server`](https://modern-web.dev/docs/dev-server) - The library supports HMR through their [HMR Plugin](https://modern-web.dev/docs/dev-server/plugins/hmr). The HMR interface is basically the same as Snowpack's.

### Development Environment

Expand All @@ -134,15 +121,6 @@ function Foo() {
const Bar = () => <h1>Hello Bar</h1>;
```

Anonymous functions with `props` as the only parameter are also supported.

```js
// This also works
export default function (props) {
return <h1>Hello Anonymous!</h1>;
}
```

The components are wrapped and memoized. When the module receives an update, it replaces the old components from the old module with the new components.

## Automatic Render Cleanup
Expand Down
Loading

0 comments on commit 21c4df5

Please sign in to comment.