{"name":"@pmmmwh/react-refresh-webpack-plugin","version":"0.4.0-beta.8","keywords":["react","javascript","webpack","refresh","hmr","hotreload","livereload","live","edit","hot","reload"],"author":{"name":"Michael Mok"},"license":"MIT","_id":"@pmmmwh/react-refresh-webpack-plugin@0.4.0-beta.8","maintainers":[{"name":"pmmmwh","email":"pmmmwh@gmail.com"}],"homepage":"https://github.com/pmmmwh/react-refresh-webpack-plugin#readme","bugs":{"url":"https://github.com/pmmmwh/react-refresh-webpack-plugin/issues"},"dist":{"shasum":"a6b22928534650bec612e13886bab3083026c6b5","tarball":"http://registry-npm.ywwl.com/@pmmmwh/react-refresh-webpack-plugin/download/@pmmmwh/react-refresh-webpack-plugin-0.4.0-beta.8.tgz","fileCount":46,"integrity":"sha512-MMdSFLGhWvPwNsOkPWUEaZwSZEgH+Ingl5sOxm1iv9WOb6AbVepAvSH79xArZosB3Pv6NWHj9ufU4dpwgluK/A==","signatures":[{"sig":"MEYCIQCjQTHr+D1qQEdKKOjSfpVVEitl/5VJCeBUjfoZ6BliJQIhAKyovTmY/QJXPGp5XngQDzd2P3JSN2z5Rr2MVByIKWyN","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":100417,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfC36LCRA9TVsSAnZWagAAdBsP/2a8HPKc2AL+sTZXq0d2\nNWDJtkMtlCYUGFkq+Xf7VMnbIYyJx/ulmFEmwuvdGO5ShgqFagyX3n00eHHQ\nOs0CE6ugUW7hW2V5VcRmF/Mgdy3ZgN6XDX23IDgKlImknlNuZeM9Dng9NY6j\nkFyr/J2y0faNaeqVGK+TR68y7dIWXNDCooo06PvlDp7uRTwH5w2agHNwgvp9\nHb6PnbDI5SM4gcU4u9sdcXNzYCqAeq/8UVDD/gH7RRzNOdsDuBuVWPrM8r6q\nYjv3ZZw7QYDcp34rzkNqQoI5n0SxGo7kTmpG2vaXnwYTi8MznQGfktlH2z6j\nnbkWEvJ9TXDY7strwP3YzAV2S5cqLuBQ2iTvDih4w8Ggh511uHsb3OdHokcg\nsBGPjl3yZZClsmNOW+hWdskcgNFb2eFX8gGDilZSQAtuEFKrcLck1hnRt0w/\n7AC5AnzZTYSiXKVYkrWUzK37HYLzveL9rBLXl95yrIbqXMvi56vmqmG38mYz\nP5U3wLng5t5Dm6NQTXABTePu981WM3ORitaYJFS8aBUEspWWvNMESrdOQYJl\nXKEIySqOuzcpUhJqRmqTpzS4jh2f1x5/JAldXlFYv3znpBtfQsWKg/sjjXNQ\nYcgD8GEmyV/SpE0bGkBoKs4a/DHIa7npxSYpCC51OxpsxnfntKgQbsCh+f/0\niKfi\r\n=HlM2\r\n-----END PGP SIGNATURE-----\r\n","size":28877,"noattachment":false,"key":"/@pmmmwh/react-refresh-webpack-plugin/-/@pmmmwh/react-refresh-webpack-plugin-0.4.0-beta.8.tgz"},"main":"lib/index.js","types":"types/index.d.ts","readme":"# React Refresh Webpack Plugin\n\n[![Latest Version](https://img.shields.io/npm/v/@pmmmwh/react-refresh-webpack-plugin/latest)](https://www.npmjs.com/package/@pmmmwh/react-refresh-webpack-plugin/v/latest)\n[![Next Version](https://img.shields.io/npm/v/@pmmmwh/react-refresh-webpack-plugin/next)](https://www.npmjs.com/package/@pmmmwh/react-refresh-webpack-plugin/v/next)\n[![License](https://img.shields.io/github/license/pmmmwh/react-refresh-webpack-plugin)](./LICENSE)\n\nAn **EXPERIMENTAL** Webpack plugin to enable \"Fast Refresh\" (also previously known as _Hot Reloading_) for React components.\n\n## Installation\n\nFirst - this plugin is not 100% stable.\nIt works pretty reliably, and we have been testing it for some time, but there are still edge cases yet to be discovered.\nPlease **DO NOT** use it if you cannot afford to face breaking changes in the future.\n\n```sh\n# if you prefer npm\nnpm install -D @pmmmwh/react-refresh-webpack-plugin react-refresh\n\n# if you prefer yarn\nyarn add -D @pmmmwh/react-refresh-webpack-plugin react-refresh\n```\n\n## Usage\n\nFirst, apply the plugin in your Webpack configuration as follows:\n\n**webpack.config.js**\n\n```js\nconst ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');\n// ... your other imports\n\n// You can tie this to whatever mechanisms you are using to detect a development environment.\n// For example, as shown here, is to tie that to `NODE_ENV` -\n// Then if you run `NODE_ENV=production webpack`, the constant will be set to false.\nconst isDevelopment = process.env.NODE_ENV !== 'production';\n\nmodule.exports = {\n  // It is suggested to run the plugin in development mode only\n  // If you are an advanced user and would like to setup Webpack yourselves,\n  // you can also use the `none` mode,\n  // but you will need to set `forceEnable: true` in the plugin options.\n  mode: isDevelopment ? 'development' : 'production',\n  // ... other configurations\n  plugins: [\n    // ... other plugins\n    // You could also keep the plugin in your production config,\n    // It will simply do nothing.\n    isDevelopment && new ReactRefreshWebpackPlugin(),\n  ].filter(Boolean),\n};\n```\n\nThen, update your Babel configuration.\nThis can either be done in your Webpack config (via options of `babel-loader`), or in the form of a `.babelrc`/`babel.config.js`.\n\n**webpack.config.js** (if you choose to inline the config)\n\n```js\nconst isDevelopment = process.env.NODE_ENV !== 'production';\n\nmodule.exports = {\n  // DO NOT apply the plugin in production mode!\n  mode: isDevelopment ? 'development' : 'production',\n  module: {\n    rules: [\n      // ... other rules\n      {\n        // for TypeScript, change the following to \"\\.[jt]sx?\"\n        test: /\\.jsx?$/,\n        exclude: /node_modules/,\n        use: [\n          // ... other loaders\n          {\n            loader: require.resolve('babel-loader'),\n            options: {\n              // ... other options\n              // DO NOT apply the Babel plugin in production mode!\n              plugins: [isDevelopment && require.resolve('react-refresh/babel')].filter(Boolean),\n            },\n          },\n        ],\n      },\n    ],\n  },\n};\n```\n\n**.babelrc.js** (if you choose to extract the config)\n\n```js\nmodule.exports = (api) => {\n  // This caches the Babel config by environment.\n  api.cache.using(() => process.env.NODE_ENV);\n  return {\n    // ... other options\n    plugins: [\n      // ... other plugins\n      // Applies the react-refresh Babel plugin on non-production modes only\n      !api.env('production') && 'react-refresh/babel',\n    ].filter(Boolean),\n  };\n};\n```\n\nMore sample projects for common Webpack development setups are available in the [examples](https://github.com/pmmmwh/react-refresh-webpack-plugin/tree/main/examples) directory.\n\n> Note 1: If you use `webpack.config.ts`, please also install `type-fest` as a peer dependency.\n\n> Note 2: If you are using TypeScript (instead of Babel) as a transpiler, you will still need to use `babel-loader` to process your source code.\n> Check out this [sample project](https://github.com/pmmmwh/react-refresh-webpack-plugin/tree/main/examples/typescript-without-babel) on how to set this up.\n\n### Caveats\n\n- Class components will be re-mounted on hot update.\n  See [this comment](https://github.com/pmmmwh/react-refresh-webpack-plugin/issues/112#issuecomment-642491198) for more background on why this is the case.\n- Unnamed components will fallback to full refresh.\n  See [this comment](https://github.com/pmmmwh/react-refresh-webpack-plugin/issues/82#issuecomment-624590282) for more info and why this is generally a bad idea.\n\n### Polyfill for Older Browsers\n\nIf you need to develop on IE11, you will need to polyfill the DOM URL API.\nThis can be done by adding the following before any of your code in the main entry (either one is fine):\n\n**Using `url-polyfill`**\n\n```js\nimport 'url-polyfill';\n```\n\n**Using `core-js`**\n\n```js\nimport 'core-js/features/url';\nimport 'core-js/features/url-search-params';\n```\n\n**Using `react-app-polyfill`**\n\n```js\nimport 'react-app-polyfill/ie11';\nimport 'react-app-polyfill/stable';\n```\n\n## Options\n\nThis plugin accepts a few options that are specifically targeted for advanced users.\n\n### `options.forceEnable`\n\nType: `boolean`\nDefault: `false`\n\nEnables the plugin forcefully.\nUseful if you want to use the plugin in production, or if you are using Webpack's `none` mode without `NODE_ENV`, for example.\n\n### `options.overlay`\n\nType: `boolean | ErrorOverlayOptions`\nDefault: `undefined`\n\nModifies how the error overlay integration works in the plugin.\n\n- If `options.overlay` is not provided or is `true`, the plugin will use the bundled error overlay interation.\n- If `options.overlay` is `false`, it will disable the error overlay integration.\n- If an `ErrorOverlayOptions` object is provided:\n  (**NOTE**: This is an advanced option that exists mostly for tools like `create-react-app` or `Next.js`)\n\n  - An optional `module` property could be defined.\n    If it is not defined, the bundled error overlay will be used.\n    If defined, it should reference a JS file that exports at least two functions with footprints as follows:\n\n    ```ts\n    function handleRuntimeError(error: Error) {}\n    function clearRuntimeErrors() {}\n    ```\n\n  - An optional `entry` property could be defined, which should also reference a JS file that contains code needed to set up your custom error overlay integration.\n    If it is not defined, the bundled error overlay entry will be used.\n    It expects the `module` file to export two more functions:\n\n    ```ts\n    function showCompileError(webpackErrorMessage: string) {}\n    function clearCompileErrors() {}\n    ```\n\n    Note that `webpackErrorMessage` is ANSI encoded, so you will need logic to parse it.\n\n  - An example configuration:\n    ```js\n    const options = {\n      overlay: {\n        entry: 'some-webpack-entry-file',\n        module: 'some-error-overlay-module',\n      },\n    };\n    ```\n\n#### `options.overlay.sockHost`\n\nType: `string`\nDefault: `window.location.hostname`\n\nSet this if you are running webpack on a host other than `window.location.hostname`.\nThis will be used by the error overlay module, and is available for `webpack-dev-server` only.\n\n#### `options.overlay.sockIntegration`\n\nType: `wds`, `whm`, `wps` or `string`\nDefault: `wds`\n\nThis controls how the error overlay connects to the sockets provided by several Webpack hot reload integrations.\n\n- If you use `webpack-dev-server`, you don't need to set this as it defaults to `wds`.\n- If you use `webpack-hot-middleware`, you should set this to `whm`.\n- If you use `webpack-plugin-serve`, you should set this to `wps`.\n- If you use anything else, or if you want to customize the socket handling yourself, you will have to provide a path to a module that will accept a message handler function and initializes the socket connection.\n  See the [`sockets`](https://github.com/pmmmwh/react-refresh-webpack-plugin/tree/main/sockets) directory for sample implementations.\n\n#### `options.overlay.sockPort`\n\nType: `number`\nDefault: `window.location.port`\n\nSet this if you are running webpack on a port other than `window.location.port`.\nThis will be used by the error overlay module, and is available for `webpack-dev-server` only.\n\n#### `options.overlay.sockPath`\n\nType: `string`\nDefault: `/sockjs-node`\n\nSet this if you are running webpack on a custom path.\nThis will be used by the error overlay module, and is available for `webpack-dev-server` only.\n\n### `options.useLegacyWDSSockets`\n\nType: `boolean`\nDefault: `false`\n\nSet this to true if you are using a `webpack-dev-server` version prior to 3.8 as it requires a custom SockJS implementation.\nIf you use this feature, you will also need to install `sockjs-client` as a peer dependency.\n\n## Related Work\n\n- [Initial Implementation by @maisano](https://gist.github.com/maisano/441a4bc6b2954205803d68deac04a716)\n","engines":{"node":">= 10.x"},"gitHead":"adebc226687a465576cc01214f0842dc99353ce0","scripts":{"lint":"eslint --report-unused-disable-directives --ext .js .","test":"node scripts/test.js","format":"prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\"","pretest":"patch-package && yarn link && yarn link \"@pmmmwh/react-refresh-webpack-plugin\"","lint:fix":"yarn lint --fix","posttest":"yarn unlink \"@pmmmwh/react-refresh-webpack-plugin\"","format:check":"prettier --check \"**/*.{js,jsx,ts,tsx,json,md}\"","generate-types":"tsc -p tsconfig.json && rimraf \"types/{globals.*,runtime,utils}\" && yarn format","prepublishOnly":"rimraf types && yarn generate-types","test:webpack-5":"WEBPACK_VERSION=5 yarn test"},"_npmUser":{"name":"pmmmwh","email":"pmmmwh@gmail.com"},"repository":{"url":"git+https://github.com/pmmmwh/react-refresh-webpack-plugin.git","type":"git"},"_npmVersion":"6.14.5","description":"An **EXPERIMENTAL** Webpack plugin to enable \"Fast Refresh\" (also previously known as _Hot Reloading_) for React components.","directories":{},"_nodeVersion":"14.4.0","dependencies":{"ansi-html":"^0.0.7","native-url":"^0.2.6","source-map":"^0.7.3","schema-utils":"^2.6.5","html-entities":"^1.2.1","lodash.debounce":"^4.0.8","error-stack-parser":"^2.0.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"yn":"^4.0.0","jest":"^26.1.0","memfs":"^3.2.0","eslint":"^7.3.1","nanoid":"^3.1.10","rimraf":"^3.0.2","webpack":"^4.43.0","fs-extra":"^9.0.1","get-port":"^5.1.1","prettier":"^2.0.5","puppeteer":"^3.3.0","type-fest":"^0.15.1","jest-junit":"^11.0.1","typescript":"^3.9.5","@babel/core":"^7.10.3","@types/node":"^14.0.14","cross-spawn":"^7.0.3","jest-circus":"^26.1.0","webpack-cli":"^3.3.12","babel-loader":"^8.1.0","webpack.next":"npm:webpack@^5.0.0-beta.21","patch-package":"^6.2.2","react-refresh":"^0.8.3","@types/webpack":"^4.41.17","@types/puppeteer":"^3.0.0","webpack-cli.beta":"npm:webpack-cli@^4.0.0-beta.8","@types/json-schema":"^7.0.5","@webpack-cli/serve":"^1.0.1-alpha.5","webpack-dev-server":"^3.11.0","sourcemap-validator":"^2.1.0","jest-watch-typeahead":"^0.6.0","webpack-plugin-serve":"^1.0.1","jest-environment-node":"^26.1.0","eslint-config-prettier":"^6.11.0","eslint-plugin-prettier":"^3.1.4","webpack-hot-middleware":"^2.25.0"},"peerDependencies":{"webpack":">=4.43.0 <6.0.0","type-fest":"^0.13.1","react-refresh":"^0.8.3","sockjs-client":"^1.4.0","@types/webpack":"^4.41.17","webpack-dev-server":"3.x","webpack-plugin-serve":"0.x || 1.x","webpack-hot-middleware":"2.x"},"peerDependenciesMeta":{"type-fest":{"optional":true},"sockjs-client":{"optional":true},"@types/webpack":{"optional":true},"webpack-dev-server":{"optional":true},"webpack-plugin-serve":{"optional":true},"webpack-hot-middleware":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/react-refresh-webpack-plugin_0.4.0-beta.8_1594588811022_0.026775257285752474","host":"s3://npm-registry-packages"},"publish_time":1594588811132,"_cnpm_publish_time":1594588811132,"dist-tags":{"latest":"0.6.3","next":"0.6.3"}}