{"id":13533064,"url":"https://github.com/solidjs/solid-refresh","last_synced_at":"2025-04-05T10:10:40.441Z","repository":{"id":37711673,"uuid":"340609080","full_name":"solidjs/solid-refresh","owner":"solidjs","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-01T11:20:05.000Z","size":678,"stargazers_count":87,"open_issues_count":7,"forks_count":18,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-10-29T18:45:07.172Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/solidjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-20T09:01:51.000Z","updated_at":"2024-10-24T07:13:17.000Z","dependencies_parsed_at":"2023-12-23T09:06:54.565Z","dependency_job_id":"2f79f104-a999-4ebe-9203-c7f841e0432e","html_url":"https://github.com/solidjs/solid-refresh","commit_stats":{"total_commits":110,"total_committers":11,"mean_commits":10.0,"dds":0.5272727272727273,"last_synced_commit":"e5b99c2f525ad0e5922c6d5c79e93c40c0b64f50"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solidjs%2Fsolid-refresh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solidjs%2Fsolid-refresh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solidjs%2Fsolid-refresh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solidjs%2Fsolid-refresh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/solidjs","download_url":"https://codeload.github.com/solidjs/solid-refresh/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246981161,"owners_count":20863828,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T07:01:16.250Z","updated_at":"2025-04-05T10:10:40.424Z","avatar_url":"https://github.com/solidjs.png","language":"TypeScript","funding_links":[],"categories":["📦 Components \u0026 Libraries"],"sub_categories":["DX"],"readme":"\u003cp\u003e\n  \u003cimg width=\"100%\" src=\"https://assets.solidjs.com/banner?project=Refresh\u0026type=core\" alt=\"Solid Refresh\"\u003e\n\u003c/p\u003e\n\n# Solid Refresh\n\n```bash\nnpm i -D solid-refresh\n```\n\n```bash\nyarn add -D solid-refresh\n```\n\n```bash\npnpm add -D solid-refresh\n```\n\nThis 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:\n\n* Vite (with option `bundler: \"vite\"`)\n* Snowpack (with option `bundler: \"esm\"`)\n* Webpack (for strict ESM, use option `bundler: \"webpack5\"`)\n* Nollup\n\n## Setup\n\n### Vite\n\n`solid-refresh` is already built into [`vite-plugin-solid`](https://github.com/solidjs/vite-plugin-solid).\n\n### Webpack \u0026 Rspack\n\nYou can read the following guides first, respectively:\n\n* [Webpack](https://webpack.js.org/guides/hot-module-replacement#enabling-hmr)\n* [Rspack](https://www.rspack.dev/guide/dev-server.html#hmr)\n* [Rspack SolidJS guide](https://www.rspack.dev/guide/solid.html)\n\n\u003e [!NOTE]\n\u003e Rspack has HMR already enabled by default. The guide only tells you how to disable it or run the dev server on a proxy server.\n\nRequires the use of [`babel-loader`](https://www.npmjs.com/package/babel-loader). Add the following to `.babelrc`:\n\n```json\n{\n  \"env\": {\n    \"development\": {\n      \"plugins\": [\"solid-refresh/babel\"]\n    }\n  }\n}\n```\n\nIf you're using strict ESM a.k.a. `import.meta.webpackHot`:\n\n```json\n{\n  \"env\": {\n    \"development\": {\n      \"plugins\": [[\"solid-refresh/babel\", {\n        \"bundler\": \"webpack5\" // or \"rspack-esm\"\n      }]]\n    }\n  }\n}\n```\n\nIn your webpack config, be sure to have the following options:\n\n```js\ndevServer: {\n  liveReload: false,\n  hot: true,\n}\n```\n\n### Parcel\n\nAdd the following to `.babelrc`:\n\n```json\n{\n  \"env\": {\n    \"development\": {\n      \"presets\": [\n        [\"babel-preset-solid\"]\n      ],\n      \"plugins\": [\n        [\"module:solid-refresh/babel\"]\n      ]\n    },\n    \"production\": {\n      \"presets\": [\n        [\"babel-preset-solid\"]\n      ],\n      \"plugins\": [\n      ]\n    }\n  }\n}\n```\n\nParcel doesn't enable package exports by default, which allows loading the dev version of SolidJS. To enable it, the following must be added in `package.json` (in accordance with [this document](https://parceljs.org/features/dependency-resolution/#enabling-package-exports)):\n\n```json\n{\n  \"@parcel/resolver-default\": {\n    \"packageExports\": true\n  }\n}\n```\n\n### Nollup\n\nRequires the use of [`@rollup/plugin-babel`](https://www.npmjs.com/package/@rollup/plugin-babel). Add the following to `.babelrc`:\n\n```json\n{\n  \"env\": {\n    \"development\": {\n      \"plugins\": [\"solid-refresh/babel\"]\n    }\n  }\n}\n```\n\n### Snowpack\n\nRequires the use of [`@snowpack/plugin-babel`](https://www.npmjs.com/package/@snowpack/plugin-babel).  Add the following to `.babelrc`:\n\n```json\n{\n  \"env\": {\n    \"development\": {\n      \"plugins\": [\"solid-refresh/babel\", { \"bundler\": \"esm\" }]\n    }\n  }\n}\n```\n\n### Other dev servers\n\n* [`wmr`](https://wmr.dev/)\n  * SolidJS is yet to be supported or isn't clear yet. It will use the same config as Snowpack.\n* [`rollup-plugin-hot`](https://github.com/rixo/rollup-plugin-hot)\n  * The library uses almost an ESM HMR-like API however it behaves the same way as Parcel. Supporting this library is still unclear.\n* [`@web/dev-server`](https://modern-web.dev/docs/dev-server)\n  * 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.\n\n### Development Environment\n\nIn any case, your build system needs to support conditional exports and have the `development` condition set.\n\n\u003e [!WARNING]\n\u003e In some standard HMR implementations, this may cause your app to reload the full page if the development environment isn't properly set!\n\n## How it works\n\nThe babel plugin will transform components with matching Pascal-cased names (indicating that they are components). This detection is supported in variable declarations, function declarations and named exports:\n\n```jsx\n// This works\nfunction Foo() {\n  return \u003ch1\u003eHello Foo\u003c/h1\u003e;\n}\n\n// This also works\nconst Bar = () =\u003e \u003ch1\u003eHello Bar\u003c/h1\u003e;\n```\n\nThe components are wrapped and memoized. When the module receives an update, it replaces the old components from the old module with the new components.\n\n## Automatic Render Cleanup\n\nThe plugin automatically handles cleanups for unhandled `render` and `hydrate` calls from `solid-js/web`.\n\nYou can disable this feature entirely through the option `\"fixRender\": false`.\n\n## Pragma\n\nOn a per file basis, use comments at top of file to opt out(change moves up to parent):\n\n```js\n/* @refresh skip */\n```\n\nOr force reload:\n\n```js\n/* @refresh reload */\n```\n\n## Limitations\n\n* Preserving state is applied partially.\n* No HOC support.\n\n## Custom `render`/`createContext`\n\nYou can define custom `render`/`createContext` calls by using the `imports` option\n\n```js\n{\n  \"imports\": [\n    {\n      // Only either \"render\" or \"createContext\"\n      \"type\": \"render\",\n      // Import identifier\n      \"name\": \"render\",\n      // Kind of import (named or default)\n      \"kind\": \"named\",\n      // Module source\n      \"source\": \"my-solid-library\"\n    }\n  ],\n}\n```\n\n## Other Configs\n\n### Granular Mode\n\nGranular mode for HMR (which allows independent HMR for components and templates) is enabled by default. You can disable this by adding `granular: false`.\n\n### JSX HMR\n\nJSX, by default, is moved to a separate component to perform granular HMR. To disable this, add `jsx: false`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolidjs%2Fsolid-refresh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsolidjs%2Fsolid-refresh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolidjs%2Fsolid-refresh/lists"}