{"id":21309640,"url":"https://github.com/ahonn/react-hot-export-loader","last_synced_at":"2025-07-11T23:30:57.381Z","repository":{"id":48270771,"uuid":"196787606","full_name":"ahonn/react-hot-export-loader","owner":"ahonn","description":"A Webpack loader that automatically inserts react-hot-loader code, Inspired by react-hot-loader-loader","archived":false,"fork":false,"pushed_at":"2021-08-03T20:04:07.000Z","size":1061,"stargazers_count":5,"open_issues_count":10,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-07T23:52:40.362Z","etag":null,"topics":["babel","react-hot-loader","webpack-loader"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/react-hot-export-loader","language":"JavaScript","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/ahonn.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}},"created_at":"2019-07-14T03:03:27.000Z","updated_at":"2021-02-24T19:35:25.000Z","dependencies_parsed_at":"2022-08-23T15:21:18.369Z","dependency_job_id":null,"html_url":"https://github.com/ahonn/react-hot-export-loader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahonn%2Freact-hot-export-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahonn%2Freact-hot-export-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahonn%2Freact-hot-export-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahonn%2Freact-hot-export-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahonn","download_url":"https://codeload.github.com/ahonn/react-hot-export-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225769383,"owners_count":17521258,"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":["babel","react-hot-loader","webpack-loader"],"created_at":"2024-11-21T17:09:42.868Z","updated_at":"2024-11-21T17:09:43.503Z","avatar_url":"https://github.com/ahonn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-hot-export-loader\n\n![version](https://img.shields.io/npm/v/react-hot-export-loader.svg)\n![download](https://img.shields.io/npm/dm/react-hot-export-loader.svg)\n![coveralls](https://img.shields.io/coveralls/github/ahonn/react-hot-export-loader.svg)\n![travis](https://img.shields.io/travis/com/ahonn/react-hot-export-loader.svg)\n![license](https://img.shields.io/github/license/ahonn/react-hot-export-loader.svg)\n\nA Webpack loader that automatically inserts react-hot-loader code, Inspired by [react-hot-loader-loader](https://github.com/NoamELB/react-hot-loader-loader)\n\n**Skip resources that are not exported to React components, do nothing when `process.env.NODE_ENV`**\n\n## Install\n\n```bash\nnpm install react-hot-loader --save-dev\nnpm install react-hot-export-loader --save-dev\n```\n\n## Getting started\n\n1. Add `react-hot-loader/babel` to your `.babelrc`\n\n```json\n// .babelrc\n{\n  \"presets\": [\"@babel/preset-env\", \"@babel/preset-react\"],\n  \"plugins\": [\"react-hot-loader/babel\"]\n}\n```\n\n2. Add `react-hot-export-loader` to your webpack configuration (must be before `babel-loader`)\n\n```js\n// webpack.config.js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.(js|jsx)$/,\n        exclude: /node_modules/,\n        use: [\n          'babel-loader',\n          'react-hot-export-loader', // \u003c== add this line\n        ],\n      },\n    ],\n  },\n};\n```\n\n### How to run example\n```bash\ngit clone git@github.com:ahonn/react-hot-export-loader.git\ncd react-hot-export-loader/example\nyarn install\nyarn run dev\n```\n\nopen [http://localhost:8080/](http://localhost:8080/) in your browser\n\n## Options\n\n### identifier\n\nBy default `react-hot-loader / root` exports the `hot` function as `__HOT__`, you can set the `identifier` option to modify the export name.\n\n`react-hot-export-loader` will automatically inserts react-hot-loader code to the React component code like that:\n\n```js\n// before inserts\nimport React from 'react';\n\nconst App = () =\u003e {\n  return (\n    \u003ch1\u003eHello World\u003c/h1\u003e\n  );\n};\n\nexport default App\n\n// after inserts\nimport 'react-hot-loader';\nimport { hot as __HOT__ } from 'react-hot-loader/root';\nimport React from 'react';\n\nconst App = () =\u003e {\n  return (\n    \u003ch1\u003eHello World\u003c/h1\u003e\n  );\n};\n\nexport default __HOT__(App);\n```\n\n### plugins\nArray containing the babel plugins that you want to enable.\n\n#### use `classProperties` babel plugin\n- add `@babel/plugin-proposal-class-properties` to your\n\n```json\n// /babelrc\n{\n  \"presets\": [\"@babel/preset-env\", \"@babel/preset-react\"],\n  \"plugins\": [\"react-hot-loader/babel\", \"@babel/plugin-proposal-class-properties\"]\n}\n```\n\n- add `classProperties` to `react-hot-export-loader` plugins options\n\n```js\n// webpack.config.js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.(js|jsx)$/,\n        exclude: /node_modules/,\n        use: [\n          'babel-loader',\n          {\n            loader: 'react-hot-export-loader',\n            options: {\n              plugins: ['classProperties'],\n            },\n          }\n        ],\n      },\n    ],\n  },\n};\n```\n\n### filter\nThe function of filtering the resources you want to automatically add code\n\n```js\n// webpack.config.js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.(js|jsx)$/,\n        exclude: /node_modules/,\n        use: [\n          'babel-loader',\n          {\n            loader: 'react-hot-export-loader',\n            options: {\n              filter: (ctx) =\u003e {\n                const { resourcePath } = ctx;\n                return resourcePath === '/path/to/any/what/you/want';\n              };\n            },\n          }\n        ],\n      },\n    ],\n  },\n};\n```\n\n## Licence\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahonn%2Freact-hot-export-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahonn%2Freact-hot-export-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahonn%2Freact-hot-export-loader/lists"}