[
  {
    "path": ".babelrc.json",
    "content": "{\n  \"env\": {\n    \"test\": {\n      \"plugins\": [\"@babel/plugin-transform-modules-commonjs\"]\n    }\n  }\n}\n"
  },
  {
    "path": ".eslintignore",
    "content": "*dist/\n*node_modules/\n*umd/\n*__tmp__\n\n# Ignore examples because they might have custom ESLint configurations\nexamples/*\n"
  },
  {
    "path": ".eslintrc.json",
    "content": "{\n  \"extends\": [\"eslint:recommended\", \"plugin:prettier/recommended\"],\n  \"parserOptions\": {\n    \"ecmaVersion\": 2022\n  },\n  \"env\": {\n    \"commonjs\": true,\n    \"es2022\": true,\n    \"node\": true\n  },\n  \"overrides\": [\n    {\n      \"files\": [\"client/**/*.js\", \"overlay/**/*.js\", \"lib/runtime/**/*.js\", \"sockets/**/*.js\"],\n      \"parserOptions\": {\n        \"ecmaVersion\": 2015\n      },\n      \"env\": {\n        \"browser\": true,\n        \"es6\": true\n      }\n    },\n    {\n      \"files\": [\n        \"scripts/test.mjs\",\n        \"test/jest-test-setup.js\",\n        \"test/helpers/{,!(fixtures)*/}*.js\",\n        \"test/mocks/**/*.js\",\n        \"test/**/*.test.js\"\n      ],\n      \"env\": {\n        \"jest\": true\n      },\n      \"globals\": {\n        \"__DEBUG__\": true,\n        \"WDS_VERSION\": true,\n        \"browser\": true,\n        \"window\": true\n      },\n      \"parserOptions\": {\n        \"sourceType\": \"module\"\n      }\n    },\n    {\n      \"files\": [\"test/helpers/**/fixtures/*.js\", \"test/conformance/**/*.test.js\"],\n      \"env\": {\n        \"browser\": true\n      }\n    },\n    {\n      \"files\": [\"test/**/fixtures/esm/*.js\"],\n      \"parserOptions\": {\n        \"ecmaVersion\": 2015,\n        \"sourceType\": \"module\"\n      },\n      \"env\": {\n        \"commonjs\": false,\n        \"es6\": true\n      }\n    },\n    {\n      \"files\": [\"test/**/fixtures/cjs/esm/*.js\"],\n      \"parserOptions\": {\n        \"ecmaVersion\": 2015,\n        \"sourceType\": \"module\"\n      },\n      \"env\": {\n        \"commonjs\": false,\n        \"es6\": true\n      }\n    },\n    {\n      \"files\": [\"test/**/fixtures/esm/cjs/*.js\"],\n      \"env\": {\n        \"commonjs\": true,\n        \"es6\": true\n      }\n    }\n  ]\n}\n"
  },
  {
    "path": ".gitattributes",
    "content": "* text=auto eol=lf\n"
  },
  {
    "path": ".github/workflows/ci.yml",
    "content": "name: CI\n\non:\n  pull_request:\n  push:\n    branches:\n      - main\n\nconcurrency:\n  group: ${{ github.workflow }}-${{ github.event.pull_request.number }}\n  cancel-in-progress: true\n\njobs:\n  lint-and-format:\n    name: Lint and Format\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout Repository\n        uses: actions/checkout@v4\n      - name: Setup Node.js\n        uses: actions/setup-node@v4\n        with:\n          cache: yarn\n          node-version: 22\n      - name: Install Dependencies\n        run: yarn install --frozen-lockfile\n      - name: Check Linting\n        run: yarn lint\n      - name: Check Formatting\n        run: yarn format:check\n\n  test:\n    name: Tests (Node ${{ matrix.node-version }} - WDS ${{ matrix.wds-version }})\n    runs-on: ubuntu-latest\n    strategy:\n      fail-fast: false\n      matrix:\n        node-version:\n          - '18'\n          - '20'\n          - '22'\n        wds-version:\n          - '4'\n          - '5'\n    steps:\n      - name: Checkout Repository\n        uses: actions/checkout@v4\n      - name: Setup Node.js\n        uses: actions/setup-node@v4\n        with:\n          cache: yarn\n          node-version: ${{ matrix.node-version }}\n      - name: Install Dependencies\n        run: yarn install --frozen-lockfile\n      - name: Run Tests\n        run: yarn test --testPathIgnorePatterns conformance\n        env:\n          BROWSER: false\n          WDS_VERSION: ${{ matrix.wds-version }}\n\n  conformance:\n    name: Conformance (Node ${{ matrix.node-version }} - WDS ${{ matrix.wds-version }})\n    runs-on: ubuntu-latest\n    strategy:\n      fail-fast: false\n      matrix:\n        node-version:\n          - '18'\n          - '20'\n          - '22'\n        wds-version:\n          - '4'\n          - '5'\n    steps:\n      - name: Checkout Repository\n        uses: actions/checkout@v4\n      - name: Setup Node.js\n        uses: actions/setup-node@v4\n        with:\n          cache: yarn\n          node-version: ${{ matrix.node-version }}\n      - name: Install Dependencies\n        run: yarn install --frozen-lockfile\n      - name: Disable AppArmor\n        run: echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns\n      - name: Run Conformance Tests\n        run: yarn test conformance\n        env:\n          WDS_VERSION: ${{ matrix.wds-version }}\n"
  },
  {
    "path": ".gitignore",
    "content": "# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.\n\n# dependencies\n*node_modules\n\n# distribution\n*dist\n*umd\n\n# misc\n.DS_Store\n\n# logs\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n\n# editor config\n.idea\n.vscode\n\n# test artifacts\n*__tmp__\n"
  },
  {
    "path": ".prettierignore",
    "content": "*dist/\n*node_modules/\n*umd/\n*__tmp__\n"
  },
  {
    "path": ".prettierrc.json",
    "content": "{\n  \"printWidth\": 100,\n  \"singleQuote\": true,\n  \"trailingComma\": \"es5\"\n}\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "## 0.6.2 (26 Nov 2025)\n\n### Fixes\n\n- Relaxed peer dependency requirement on `type-fest` to allow v5.x\n  ([#934](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/934))\n\n## 0.6.1 (26 Jun 2025)\n\n### Fixes\n\n- Ensure `this` propagates into module factory properly\n  ([#921](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/921))\n\n## 0.6.0 (28 Apr 2025)\n\n### BREAKING\n\n- Minimum required Node.js version has been bumped to `18.12.0`.\n\n- Minimum required `webpack` version has been bumped to `5.2.0`.\n\n- Minimum supported `webpack-dev-server` version has been bumped to `4.8.0`.\n\n- Minimum supported `webpack-plugin-serve` version has been bumped to `1.0.0`.\n\n- `overlay.sockHost`, `overlay.sockPath`, `overlay.sockPort`, `overlay.sockProtocol` and `overlay.useURLPolyfill` have all been removed.\n  ([#850](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/850))\n\n  It was necessary to support WDS below `4.8.0` (published in April 2022).\n\n  It is no-longer necessary as a direct integration with WDS is now possible.\n\n### Features\n\n- Added helper script to better support use cases where React and/or React-DOM are externalized\n  ([#852](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/852))\n\n### Fixes\n\n- Ensure plugin injected entries are no-op in production\n  ([#900](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/900))\n\n### Internal\n\n- Dropped support for Webpack 4 / WDS 3\n  ([#850](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/850),\n  [#904](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/904))\n\n- Migrated from `ansi-html` to `anser` in error overlay\n  ([#854](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/854))\n\n- Bumped all development dependencies\n  ([#905](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/905))\n\n## 0.5.17 (26 Jun 2025)\n\n### Fixes\n\n- Ensure `this` propagates into module factory properly\n  ([#922](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/922))\n\n## 0.5.16 (31 Mar 2025)\n\n### Fixes\n\n- Fixed out of order cleanup when using top-level await\n  ([#898](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/898))\n\n## 0.5.15 (3 Jun 2024)\n\n### Fixes\n\n- Fixed wrong import in error overlay for `ansi-html`\n  ([#853](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/853))\n\n## 0.5.14 (1 Jun 2024)\n\n### Fixes\n\n- Moved to `ansi-html` `v0.0.9` and `schema-utils` `v4.x`\n  ([#848](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/848))\n\n### Internal\n\n- Run tests on latest versions of Node.js 18, 20 and 22\n  ([#848](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/848))\n\n- Bumped `jest` to v29 and some other development dependencies\n  ([#848](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/848))\n\n- Removed `yalc`\n  ([#849](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/849))\n\n## 0.5.13 (28 Apr 2024)\n\n### Fixes\n\n- Fixed module system inferring (ESM vs CJS) to start from the point of each file\n  ([#771](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/771))\n\n## 0.5.12 (27 Apr 2024)\n\n### Fixes\n\n- Fixed incorrect `sockProtocol` override\n  ([#835](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/835))\n\n- Relaxed peer dependency requirement on `webpack-dev-server` to allow v5.x\n  ([#837](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/837))\n\n## 0.5.11 (15 Aug 2023)\n\n### Features\n\n- Added support to exclude dynamically generated modules from other loaders\n  ([#769](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/769))\n\n### Fixes\n\n- Fixed unnecessary memory leaks due to `prevExports`\n  ([#766](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/766))\n\n- Relaxed peer dependency requirement on `type-fest` to allow v4.x\n  ([#767](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/767))\n\n- Fixed module type resolution when there is difference across contexts\n  ([#768](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/768))\n\n## 0.5.10 (24 Nov 2022)\n\n### Fixes\n\n- Bumped `loader-utils` to fix security vulnerability\n  ([#700](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/700))\n\n## 0.5.9 (10 Nov 2022)\n\n### Fixes\n\n- Bumped `loader-utils` to fix security vulnerability\n  ([#685](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/685))\n\n## 0.5.8 (9 Oct 2022)\n\n### Fixes\n\n- Fixed performance issue regarding `require.resolve` in loader injection\n  ([#669](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/669))\n\n- Bumped `core-js-pure` to not depend on deprecated versions\n  ([#674](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/674))\n\n## 0.5.7 (23 May 2022)\n\n### Fixes\n\n- Removed debug `console.log` statement\n  ([#631](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/631))\n\n### Internal\n\n- Run tests on Node.js 18\n  ([#631](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/631))\n\n## 0.5.6 (10 May 2022)\n\n### Fixes\n\n- Fixed faulty `this` type import in loader\n  ([#624](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/624))\n\n- Made current script detection more robust for edge cases\n  ([#630](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/630))\n\n### Internal\n\n- Swapped to new `ReactDOM.createRoot` API in examples\n  ([#626](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/626))\n\n## 0.5.5 (4 April 2022)\n\n### Fixes\n\n- Handle unknown `moduleId` for dynamically generated modules\n  ([#547](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/547))\n\n- Handle WDS `auto` value on `port`\n  ([#574](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/574))\n\n- Fixed `react-refresh@0.12.0` compatibility\n  ([#576](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/576))\n\n- Fixed crash when parsing compile errors in overlay\n  ([#577](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/577))\n\n- Respect virtual modules when injecting loader\n  ([#593](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/593))\n\n- Allow `port` to be missing for WDS, also some general refactoring\n  ([#623](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/623))\n\n### Internal\n\n- A couple documentation changes in README\n  ([#575](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/575),\n  [8c39623](https://github.com/pmmmwh/react-refresh-webpack-plugin/commit/8c39623dac237aa15795b60820babcffebb28c64),\n  [#597](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/597))\n\n- Bumped dependencies for testing infrastructure\n  ([#526](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/526),\n  [#564](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/564),\n  [#567](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/567),\n  [#581](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/581),\n  [#588](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/588),\n  [#591](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/591),\n  [#594](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/594),\n  [#616](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/616))\n\n## 0.5.4 (22 December 2021)\n\n### Fixes\n\n- Skip loader injection for files referenced as assets\n  ([#545](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/545))\n\n- Changed failures of `exports` capturing to warn instead of throw\n  ([#546](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/546))\n\n## 0.5.3 (28 November 2021)\n\n### Fixes\n\n- Updated overlay for unsafe area in Safari\n  ([#528](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/528))\n\n- Fixed performance in large projects due to memory leak in loader\n  ([#537](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/537))\n\n## 0.5.2 (19 November 2021)\n\n### Features\n\n- Added support for WDS v4 `client.webSocketURL`\n  ([#529](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/529))\n\n### Fixes\n\n- Fixed lost module context due to interceptor by always using regular functions\n  ([#531](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/531))\n\n- Relaxed peer dependency requirement on `react-refresh`\n  ([#534](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/534))\n\n## 0.5.1 (15 September 2021)\n\n### Fixes\n\n- Relaxed peer dependency requirement on `type-fest` to allow v2.x\n  ([#507](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/507),\n  [#508](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/508))\n\n### Internal\n\n- Fixed typos in README\n  ([#509](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/509))\n\n## 0.5.0 (14 September 2021)\n\n### BREAKING\n\n- While most of the public API did not change,\n  we've re-written a large chunk of the runtime code to support a wider range of use cases.\n\n  This is likely to provide more stability, but if `0.4.x` works in your setup but `0.5.x` doesn't,\n  please file us an issue - we would love to address it!\n\n- The `disableRefreshCheck` option have been removed.\n  ([#285](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/285))\n\n  It has long been effect-less and deprecated since `0.3.x`.\n\n- The `overlay.useLegacyWDSSockets` have been removed.\n  ([#498](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/498))\n\n  It is aimed to support WDS below `3.6.0` (published in June 2019),\n  but looking at current usage and download stats,\n  we've decided it is best to drop support for the old socket format moving forward.\n\n- Handling of port `0` have been removed.\n  ([#337](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/337))\n\n- `html-entities` have been bumped to `2.x`.\n  ([#321](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/321))\n\n- `react-refresh` have been bumped to `0.10.0`.\n  ([#353](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/353))\n\n### Features\n\n- Added WDS v4 support with new socket defaults through Webpack config\n  ([#241](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/241),\n  [#286](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/286),\n  [#392](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/392),\n  [#413](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/413),\n  [#479](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/479))\n\n- Added the `overlay.sockProtocol` option\n  ([#242](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/242))\n\n- Added monorepo compatibility via the the `library` option\n  ([#273](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/273))\n\n- Rewritten URL handling using WHATWG `URL` APIs with automatic pony-filling\n  ([#278](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/278),\n  [#332](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/332),\n  [#378](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/378))\n\n- Rewritten Webpack 5 compatibility using new APIs and hooks\n  ([#319](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/319),\n  [#372](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/372),\n  [#434](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/434),\n  [#483](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/483))\n\n- Rewritten refresh runtime to be fully module system aware\n  ([#337](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/337),\n  [#461](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/461),\n  [#482](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/482),\n  [#492](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/492))\n\n- Rewritten Webpack 4 and 5 checks using feature detection on compiler\n  ([#415](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/415))\n\n- Added support for `experiments.topLevelAwait`\n  ([#435](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/435),\n  [#447](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/447),\n  [#493](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/493))\n\n- Added retry logic when socket initialisation fails\n  ([#446](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/446))\n\n### Fixes\n\n- Relaxed peer dependency requirement on `type-fest`\n  ([#257](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/257),\n  [c02018a](https://github.com/pmmmwh/react-refresh-webpack-plugin/commit/c02018a853f58341d44ea9f1b56a9568ffe7b657),\n  [#484](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/484))\n\n- Relaxed requirement on the `overlay` option to accept relative paths\n  ([#284](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/284))\n\n- Patched unstable initialisation of global scope across module boundaries\n  ([#290](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/290),\n  [#369](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/369),\n  [#464](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/464),\n  [#505](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/505))\n\n- Patched quote escaping in injected runtime code\n  ([#306](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/306))\n\n- Invalidate updates outside of Refresh boundary for consistency\n  ([#307](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/307))\n\n- Properly throw when an ambiguous entrypoint is received while using Webpack 4\n  ([#320](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/320))\n\n- Fixed overlay script source detection for WDS when no `src` is found\n  ([#331](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/331))\n\n- Fixed possible Stack Overflow through self-referencing\n  ([#370](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/370),\n  [#380](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/380))\n\n- Relaxed errors on HMR not found to not crash JS parsing\n  ([#371](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/371))\n\n- Ensure overlay code won't run if disabled\n  ([#374](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/374))\n\n- Relaxed peer dependency requirement on `@types/webpack`\n  ([#414](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/414))\n\n- Fixed compiler error overlay crashes when messages are empty\n  ([#462](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/462))\n\n- Swapped `ansi-html` to `ansi-html-community` to fix ReDoS vulnerability\n  ([#501](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/501))\n\n### Internal\n\n- More stable testing infrastructure\n  ([#234](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/234))\n\n- Run tests by default on Webpack 5\n  ([#440](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/440))\n\n- Rewrite documentation and fix outstanding issues\n  ([#283](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/283),\n  [#291](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/291),\n  [#311](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/311),\n  [#376](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/376),\n  [#480](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/480),\n  [#497](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/497),\n  [#499](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/499))\n\n- Added documentation on community plugins: `react-refresh-typescript` and `swc`\n  ([#248](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/248),\n  [fbe1f27](https://github.com/pmmmwh/react-refresh-webpack-plugin/commit/fbe1f270de46c4a308d996a4487653a95aebfc25),\n  [#450](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/450))\n\n## 0.4.3 (2 November 2020)\n\n### Fixes\n\n- Fixed Yarn 2 PnP compatibility with absolute `react-refresh/runtime` imports\n  ([#230](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/230))\n\n- Fixed Webpack 5 compatibility by requiring `__webpack_require__`\n  ([#233](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/233))\n\n- Fixed IE 11 compatibility in socket code\n  ([4033e6af](https://github.com/pmmmwh/react-refresh-webpack-plugin/commit/4033e6af279f5f50396ff24fb1ec89c41fc2df32))\n\n- Relaxed peer dependency requirement for `react-refresh` to allow `0.9.x`\n  ([747c19ba](https://github.com/pmmmwh/react-refresh-webpack-plugin/commit/747c19ba43d81f19a042d44922d0518c6403528c))\n\n## 0.4.2 (3 September 2020)\n\n### Fixes\n\n- Patched loader to use with Node.js global `fetch` polyfills\n  ([#193](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/193))\n\n- Patched default `include` and `exclude` options to be case-insensitive\n  ([#194](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/194))\n\n## 0.4.1 (28 July 2020)\n\n### Fixes\n\n- Fixed accidental use of testing alias `webpack.next` in published plugin code\n  ([#167](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/167))\n\n## 0.4.0 (28 July 2020)\n\n### BREAKING\n\n- Minimum required Node.js version have been bumped to 10 as Node.js 8 is EOL now.\n\n- Minimum required Webpack version is now `v4.43.0` or later as we adopted the new `module.hot.invalidate` API.\n  ([#89](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/89))\n\n  The new API enabled us to bail out of the HMR loop less frequently and provide a better experience.\n  If you really cannot upgrade, you can stay on `0.3.3` for the time being.\n\n- While most of our public API did not change, this release is closer to a rewrite than a refactor.\n\n  A lot of files have moved to provide easier access for advanced users and frameworks.\n  ([#122](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/122))\n\n  You can check the difference in the PR to see what have moved and where they are now.\n\n- The `useLegacyWDSSockets` option is now scoped under the `overlay` option.\n  ([#153](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/153))\n\n### Features\n\n- Adopted the `module.hot.invalidate()` API, which means we will now bail out less often\n  ([#89](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/89))\n\n- Attach runtime on Webpack's global scope instead of `window`, making the plugin platform-agnostic\n  ([#102](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/102))\n\n- Added stable support for **Webpack 5** and beta support for **Module Federation**\n  ([#123](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/123),\n  [#132](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/132),\n  [#164](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/164))\n\n- Socket integration URL detection via `document.currentScript`\n  ([#133](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/133))\n\n- Relaxed requirements for \"required\" `overlay` options to receive `false` as value\n  ([#154](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/154))\n\n- Prefixed all errors thrown by the plugin\n  ([#161](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/161))\n\n- Eliminated use of soon-to-be-deprecated `lodash.debounce` package\n  ([#163](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/163))\n\n### Fixes\n\n- Fixed circular references for `__react_refresh_error_overlay__` and `__react_refresh_utils`\n  ([#116](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/116))\n\n- Fixed IE11 compatibility\n  ([#106](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/106),\n  [#121](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/121))\n\n- Rearranged directories to provide more ergonomic imports\n  ([#122](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/122))\n\n- Fixed issues with Babel/ESLint/Flow regarding loader ordering and runtime cleanup\n  ([#129](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/129),\n  [#140](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/140))\n\n- Correctly detecting the HMR plugin\n  ([#130](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/130),\n  [#160](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/160))\n\n- Fixed unwanted injection of error overlay in non-browser environment\n  ([#146](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/146))\n\n- Scoped the `useLegacyWDSSockets` options under `overlay` to reflect its true use\n  ([#153](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/153))\n\n- Fixed non-preserved relative ordering of Webpack entries\n  ([#165](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/165))\n\n### Internal\n\n- Full HMR test suite - we are confident the plugin works!\n  ([#93](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/93),\n  [#96](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/96))\n\n- Unit tests for all plugin-related Node.js code\n  ([#127](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/127))\n\n## 0.3.3 (29 May 2020)\n\n### Fixes\n\n- Removed unrecoverable React errors check and its corresponding bail out logic on hot dispose\n  ([#104](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/104))\n\n## 0.3.2 (22 May 2020)\n\n### Fixes\n\n- Fixed error in overlay when stack trace is unavailable\n  ([#91](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/91))\n\n- Fixed IE11 compatibility\n  ([#98](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/98))\n\n## 0.3.1 (11 May 2020)\n\n### Fixes\n\n- Relaxed peer dependency requirements for `webpack-plugin-serve`\n  ([64bb6b8](https://github.com/pmmmwh/react-refresh-webpack-plugin/commit/64bb6b8c26bbf9e51484ef7a109c0921be7889ff))\n\n## 0.3.0 (10 May 2020)\n\n### BREAKING\n\n- Deprecated the `disableRefreshCheck` flag\n  ([#60](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/60))\n\n### Features\n\n- Added custom error overlay support\n  ([#44](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/44))\n\n- Added example project to use TypeScript without usual Babel settings\n  ([#46](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/46))\n\n- Added custom socket parameters for WDS\n  ([#52](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/52))\n\n- Added TypeScript definition files\n  ([#65](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/65))\n\n- Added stricter options validation rules\n  ([#62](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/62))\n\n- Added option to configure socket runtime to support more hot integrations\n  ([#64](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/64))\n\n- Added support for `webpack-plugin-serve`\n  ([#74](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/74))\n\n### Fixes\n\n- Fixed non-dismissible overlay for build warnings\n  ([#57](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/57))\n\n- Fixed electron compatibility\n  ([#58](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/58))\n\n- Fixed optional peer dependencies to be truly optional\n  ([#59](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/59))\n\n- Fixed compatibility issues caused by `node-url`\n  ([#61](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/61))\n\n- Removed check for `react` import for compatibility\n  ([#69](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/69))\n\n## 0.2.0 (2 March 2020)\n\n### Features\n\n- Added `webpack-hot-middleware` support\n  ([#23](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/23))\n\n### Fixes\n\n- Fixed dependency on a global `this` variable to better support web workers\n  ([#29](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/29))\n\n## 0.1.3 (19 December 2019)\n\n### Fixes\n\n- Fixed runtime template injection when the `runtimeChunks` optimization is used in Webpack\n  ([#26](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/26))\n\n## 0.1.2 (18 December 2019)\n\n### Fixes\n\n- Fixed caching of Webpack loader to significantly improve performance\n  ([#22](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/22))\n\n## 0.1.1 (13 December 2019)\n\n### Fixes\n\n- Fixed usage of WDS SockJS fallback\n  ([#17](https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/17))\n\n## 0.1.0 (7 December 2019)\n\n- Initial public release\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2019 Michael Mok\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# React Refresh Webpack Plugin\n\n[actions]: https://github.com/pmmmwh/react-refresh-webpack-plugin/actions/workflows/ci.yml\n[actions:badge]: https://img.shields.io/github/actions/workflow/status/pmmmwh/react-refresh-webpack-plugin/ci.yml?branch=main\n[license:badge]: https://img.shields.io/github/license/pmmmwh/react-refresh-webpack-plugin\n[npm:latest]: https://www.npmjs.com/package/@pmmmwh/react-refresh-webpack-plugin/v/latest\n[npm:latest:badge]: https://img.shields.io/npm/v/@pmmmwh/react-refresh-webpack-plugin/latest\n[npm:next]: https://www.npmjs.com/package/@pmmmwh/react-refresh-webpack-plugin/v/next\n[npm:next:badge]: https://img.shields.io/npm/v/@pmmmwh/react-refresh-webpack-plugin/next\n\n[![GitHub Actions][actions:badge]][actions]\n[![License][license:badge]](./LICENSE)\n[![Latest Version][npm:latest:badge]][npm:latest]\n[![Next Version][npm:next:badge]][npm:next]\n\nA Webpack plugin to enable \"Fast Refresh\" (also known as _Hot Reloading_) for React components.\n\n> We're hoping to land a v1 release soon - please help us by reporting any issues you've encountered!\n\n## Getting Started\n\n### Prerequisites\n\nEnsure that you are using at least the minimum supported versions of this plugin's peer dependencies -\nolder versions unfortunately do not contain code to orchestrate \"Fast Refresh\",\nand thus cannot be made compatible.\n\nWe recommend using the following versions:\n\n| Dependency      | Version                              |\n| --------------- | ------------------------------------ |\n| `Node.js`       | `18.12.0`+, `20.x`, `22.x`           |\n| `react`         | `16.13.0`+, `17.x`, `18.x` or `19.x` |\n| `react-dom`     | `16.13.0`+, `17.x`, `18.x` or `19.x` |\n| `react-refresh` | `0.10.0`+                            |\n| `webpack`       | `5.2.0`+                             |\n\n<details>\n<summary>Minimum requirements</summary>\n<br />\n\n| Dependency      | Version   |\n| --------------- | --------- |\n| `Node.js`       | `18.12.0` |\n| `react`         | `16.9.0`  |\n| `react-dom`     | `16.9.0`  |\n| `react-refresh` | `0.10.0`  |\n| `webpack`       | `5.2.0`   |\n\n</details>\n\n<details>\n<summary>Using custom renderers (e.g. <code>react-three-fiber</code>, <code>react-pdf</code>, <code>ink</code>)</summary>\n<br />\n\nTo ensure full support of \"Fast Refresh\" with components rendered by custom renderers,\nyou should ensure the renderer you're using depends on a recent version of `react-reconciler`.\n\nWe recommend version `0.25.0` or above, but any versions above `0.22.0` should work.\n\nIf the renderer is not compatible, please file them an issue instead.\n\n</details>\n\n### Installation\n\nWith all prerequisites met, you can install this plugin using your package manager of choice:\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# if you prefer pnpm\npnpm add -D @pmmmwh/react-refresh-webpack-plugin react-refresh\n```\n\nThe `react-refresh` package (from the React team) is a required peer dependency of this plugin.\nWe recommend using version `0.10.0` or above.\n\n<details>\n<summary>Support for TypeScript</summary>\n<br />\n\nTypeScript support is available out-of-the-box for those who use `webpack.config.ts`.\n\nOur exported types however depends on `type-fest`, so you'll have to add it as a `devDependency`:\n\n```sh\n# if you prefer npm\nnpm install -D type-fest\n\n# if you prefer yarn\nyarn add -D type-fest\n\n# if you prefer pnpm\npnpm add -D type-fest\n```\n\n> **:memo: Note**:\n>\n> `type-fest@4.x` only supports Node.js v16 or above,\n> `type-fest@3.x` only supports Node.js v14.16 or above,\n> and `type-fest@2.x` only supports Node.js v12.20 or above.\n> If you're using an older version of Node.js, please install `type-fest@1.x`.\n\n</details>\n\n### Usage\n\nFor most setups, we recommend integrating with `babel-loader`.\nIt covers the most use cases and is officially supported by the React team.\n\nThe example below will assume you're using `webpack-dev-server`.\n\nIf you haven't done so, set up your development Webpack configuration for Hot Module Replacement (HMR).\n\n```js\nconst isDevelopment = process.env.NODE_ENV !== 'production';\n\nmodule.exports = {\n  mode: isDevelopment ? 'development' : 'production',\n  devServer: {\n    hot: true,\n  },\n};\n```\n\n<details>\n<summary>Using <code>webpack-hot-middleware</code></summary>\n<br />\n\n```js\nconst webpack = require('webpack');\n\nconst isDevelopment = process.env.NODE_ENV !== 'production';\n\nmodule.exports = {\n  mode: isDevelopment ? 'development' : 'production',\n  plugins: [isDevelopment && new webpack.HotModuleReplacementPlugin()].filter(Boolean),\n};\n```\n\n</details>\n\n<details>\n<summary>Using <code>webpack-plugin-serve</code></summary>\n<br />\n\n```js\nconst { WebpackPluginServe } = require('webpack-plugin-serve');\n\nconst isDevelopment = process.env.NODE_ENV !== 'production';\n\nmodule.exports = {\n  mode: isDevelopment ? 'development' : 'production',\n  plugins: [isDevelopment && new WebpackPluginServe()].filter(Boolean),\n};\n```\n\n</details>\n\nThen, add the `react-refresh/babel` plugin to your Babel configuration and this plugin to your Webpack configuration.\n\n```js\nconst ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');\n\nconst isDevelopment = process.env.NODE_ENV !== 'production';\n\nmodule.exports = {\n  mode: isDevelopment ? 'development' : 'production',\n  module: {\n    rules: [\n      {\n        test: /\\.[jt]sx?$/,\n        exclude: /node_modules/,\n        use: [\n          {\n            loader: require.resolve('babel-loader'),\n            options: {\n              plugins: [isDevelopment && require.resolve('react-refresh/babel')].filter(Boolean),\n            },\n          },\n        ],\n      },\n    ],\n  },\n  plugins: [isDevelopment && new ReactRefreshWebpackPlugin()].filter(Boolean),\n};\n```\n\n> **:memo: Note**:\n>\n> Ensure both the Babel transform (`react-refresh/babel`) and this plugin are enabled only in `development` mode!\n\n<details>\n<summary>Using <code>ts-loader</code></summary>\n<br />\n\n> **:warning: Warning**:\n> This is an un-official integration maintained by the community.\n\nInstall [`react-refresh-typescript`](https://github.com/Jack-Works/react-refresh-transformer/tree/main/typescript).\nEnsure your TypeScript version is at least 4.0.\n\n```sh\n# if you prefer npm\nnpm install -D react-refresh-typescript\n\n# if you prefer yarn\nyarn add -D react-refresh-typescript\n\n# if you prefer pnpm\npnpm add -D react-refresh-typescript\n```\n\nThen, instead of wiring up `react-refresh/babel` via `babel-loader`,\nyou can wire-up `react-refresh-typescript` with `ts-loader`:\n\n```js\nconst ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');\nconst ReactRefreshTypeScript = require('react-refresh-typescript');\n\nconst isDevelopment = process.env.NODE_ENV !== 'production';\n\nmodule.exports = {\n  mode: isDevelopment ? 'development' : 'production',\n  module: {\n    rules: [\n      {\n        test: /\\.[jt]sx?$/,\n        exclude: /node_modules/,\n        use: [\n          {\n            loader: require.resolve('ts-loader'),\n            options: {\n              getCustomTransformers: () => ({\n                before: [isDevelopment && ReactRefreshTypeScript()].filter(Boolean),\n              }),\n              transpileOnly: isDevelopment,\n            },\n          },\n        ],\n      },\n    ],\n  },\n  plugins: [isDevelopment && new ReactRefreshWebpackPlugin()].filter(Boolean),\n};\n```\n\n> It is recommended to run `ts-loader` with `transpileOnly` is set to `true`.\n> You can use `ForkTsCheckerWebpackPlugin` as an alternative if you need typechecking during development.\n\n</details>\n\n<details>\n<summary>Using <code>swc-loader</code></summary>\n<br />\n\n> **:warning: Warning**:\n> This is an un-official integration maintained by the community.\n\nEnsure your `@swc/core` version is at least `1.2.86`.\nIt is also recommended to use `swc-loader` version `0.1.13` or above.\n\nThen, instead of wiring up `react-refresh/babel` via `babel-loader`,\nyou can wire-up `swc-loader` and use the `refresh` transform:\n\n```js\nconst ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');\n\nconst isDevelopment = process.env.NODE_ENV !== 'production';\n\nmodule.exports = {\n  mode: isDevelopment ? 'development' : 'production',\n  module: {\n    rules: [\n      {\n        test: /\\.[jt]sx?$/,\n        exclude: /node_modules/,\n        use: [\n          {\n            loader: require.resolve('swc-loader'),\n            options: {\n              jsc: {\n                transform: {\n                  react: {\n                    development: isDevelopment,\n                    refresh: isDevelopment,\n                  },\n                },\n              },\n            },\n          },\n        ],\n      },\n    ],\n  },\n  plugins: [isDevelopment && new ReactRefreshWebpackPlugin()].filter(Boolean),\n};\n```\n\n> Starting from version `0.1.13`, `swc-loader` will set the `development` option based on Webpack's `mode` option.\n> `swc` won't enable fast refresh when `development` is `false`.\n\n</details>\n\nFor more information on how to set up \"Fast Refresh\" with different integrations,\nplease check out [our examples](examples).\n\n### Overlay Integration\n\nThis plugin integrates with the most common Webpack HMR solutions to surface errors during development -\nin the form of an error overlay.\n\nBy default, `webpack-dev-server` is used,\nbut you can set the [`overlay.sockIntegration`](docs/API.md#sockintegration) option to match what you're using.\n\nThe supported versions are as follows:\n\n| Dependency               | Version           |\n| ------------------------ | ----------------- |\n| `webpack-dev-server`     | `4.8.0`+ or `5.x` |\n| `webpack-hot-middleware` | `2.x`             |\n| `webpack-plugin-serve`   | `1.x`             |\n\n## API\n\nPlease refer to [the API docs](docs/API.md) for all available options.\n\n## FAQs and Troubleshooting\n\nPlease refer to [the Troubleshooting guide](docs/TROUBLESHOOTING.md) for FAQs and resolutions to common issues.\n\n## License\n\nThis project is licensed under the terms of the [MIT License](/LICENSE).\n\n## Special Thanks\n\n<a href=\"https://jb.gg/OpenSource?from=ReactRefreshWebpackPlugin\" target=\"_blank\">\n  <img\n    alt=\"JetBrains Logo\"\n    src=\"https://user-images.githubusercontent.com/9338255/132110580-61d3dba5-f5c7-4479-bd8e-39cd65b42fc5.png\"\n    width=\"120\"\n  />\n</a>\n"
  },
  {
    "path": "client/ErrorOverlayEntry.js",
    "content": "/* global __react_refresh_error_overlay__, __react_refresh_socket__ */\n\nif (process.env.NODE_ENV !== 'production') {\n  const events = require('./utils/errorEventHandlers.js');\n  const formatWebpackErrors = require('./utils/formatWebpackErrors.js');\n  const runWithRetry = require('./utils/retry.js');\n\n  // Setup error states\n  let isHotReload = false;\n  let hasRuntimeErrors = false;\n\n  /**\n   * Try dismissing the compile error overlay.\n   * This will also reset runtime error records (if any),\n   * because we have new source to evaluate.\n   * @returns {void}\n   */\n  const tryDismissErrorOverlay = function () {\n    __react_refresh_error_overlay__.clearCompileError();\n    __react_refresh_error_overlay__.clearRuntimeErrors(!hasRuntimeErrors);\n    hasRuntimeErrors = false;\n  };\n\n  /**\n   * A function called after a compile success signal is received from Webpack.\n   * @returns {void}\n   */\n  const handleCompileSuccess = function () {\n    isHotReload = true;\n\n    if (isHotReload) {\n      tryDismissErrorOverlay();\n    }\n  };\n\n  /**\n   * A function called after a compile errored signal is received from Webpack.\n   * @param {string[]} errors\n   * @returns {void}\n   */\n  const handleCompileErrors = function (errors) {\n    isHotReload = true;\n\n    const formattedErrors = formatWebpackErrors(errors);\n\n    // Only show the first error\n    __react_refresh_error_overlay__.showCompileError(formattedErrors[0]);\n  };\n\n  /**\n   * Handles compilation messages from Webpack.\n   * Integrates with a compile error overlay.\n   * @param {*} message A Webpack HMR message sent via WebSockets.\n   * @returns {void}\n   */\n  const compileMessageHandler = function (message) {\n    switch (message.type) {\n      case 'ok':\n      case 'still-ok':\n      case 'warnings': {\n        // TODO: Implement handling for warnings\n        handleCompileSuccess();\n        break;\n      }\n      case 'errors': {\n        handleCompileErrors(message.data);\n        break;\n      }\n      default: {\n        // Do nothing.\n      }\n    }\n  };\n\n  // Only register if no other overlay have been registered\n  if (\n    typeof window !== 'undefined' &&\n    !window.__reactRefreshOverlayInjected &&\n    __react_refresh_socket__\n  ) {\n    // Registers handlers for compile errors with retry -\n    // This is to prevent mismatching injection order causing errors to be thrown\n    runWithRetry(\n      function initSocket() {\n        __react_refresh_socket__.init(compileMessageHandler);\n      },\n      3,\n      'Failed to set up the socket connection.'\n    );\n    // Registers handlers for runtime errors\n    events.handleError(function handleError(error) {\n      hasRuntimeErrors = true;\n      __react_refresh_error_overlay__.handleRuntimeError(error);\n    });\n    events.handleUnhandledRejection(function handleUnhandledPromiseRejection(error) {\n      hasRuntimeErrors = true;\n      __react_refresh_error_overlay__.handleRuntimeError(error);\n    });\n\n    // Mark overlay as injected to prevent double-injection\n    window.__reactRefreshOverlayInjected = true;\n  }\n}\n"
  },
  {
    "path": "client/ReactRefreshEntry.js",
    "content": "/* global __react_refresh_library__ */\n\nif (process.env.NODE_ENV !== 'production') {\n  const safeThis = require('core-js-pure/features/global-this');\n  const RefreshRuntime = require('react-refresh/runtime');\n\n  if (typeof safeThis !== 'undefined') {\n    var $RefreshInjected$ = '__reactRefreshInjected';\n    // Namespace the injected flag (if necessary) for monorepo compatibility\n    if (typeof __react_refresh_library__ !== 'undefined' && __react_refresh_library__) {\n      $RefreshInjected$ += '_' + __react_refresh_library__;\n    }\n\n    // Only inject the runtime if it hasn't been injected\n    if (!safeThis[$RefreshInjected$]) {\n      // Inject refresh runtime into global scope\n      RefreshRuntime.injectIntoGlobalHook(safeThis);\n\n      // Mark the runtime as injected to prevent double-injection\n      safeThis[$RefreshInjected$] = true;\n    }\n  }\n}\n"
  },
  {
    "path": "client/package.json",
    "content": "{\n  \"type\": \"commonjs\"\n}\n"
  },
  {
    "path": "client/utils/errorEventHandlers.js",
    "content": "/**\n * @callback EventCallback\n * @param {string | Error | null} context\n * @returns {void}\n */\n/**\n * @callback EventHandler\n * @param {Event} event\n * @returns {void}\n */\n\n/**\n * A function that creates an event handler for the `error` event.\n * @param {EventCallback} callback A function called to handle the error context.\n * @returns {EventHandler} A handler for the `error` event.\n */\nfunction createErrorHandler(callback) {\n  return function errorHandler(event) {\n    if (!event || !event.error) {\n      return callback(null);\n    }\n    if (event.error instanceof Error) {\n      return callback(event.error);\n    }\n    // A non-error was thrown, we don't have a trace. :(\n    // Look in your browser's devtools for more information\n    return callback(new Error(event.error));\n  };\n}\n\n/**\n * A function that creates an event handler for the `unhandledrejection` event.\n * @param {EventCallback} callback A function called to handle the error context.\n * @returns {EventHandler} A handler for the `unhandledrejection` event.\n */\nfunction createRejectionHandler(callback) {\n  return function rejectionHandler(event) {\n    if (!event || !event.reason) {\n      return callback(new Error('Unknown'));\n    }\n    if (event.reason instanceof Error) {\n      return callback(event.reason);\n    }\n    // A non-error was rejected, we don't have a trace :(\n    // Look in your browser's devtools for more information\n    return callback(new Error(event.reason));\n  };\n}\n\n/**\n * Creates a handler that registers an EventListener on window for a valid type\n * and calls a callback when the event fires.\n * @param {string} eventType A valid DOM event type.\n * @param {function(EventCallback): EventHandler} createHandler A function that creates an event handler.\n * @returns {register} A function that registers the EventListener given a callback.\n */\nfunction createWindowEventHandler(eventType, createHandler) {\n  /**\n   * @type {EventHandler | null} A cached event handler function.\n   */\n  let eventHandler = null;\n\n  /**\n   * Unregisters an EventListener if it has been registered.\n   * @returns {void}\n   */\n  function unregister() {\n    if (eventHandler === null) {\n      return;\n    }\n    window.removeEventListener(eventType, eventHandler);\n    eventHandler = null;\n  }\n\n  /**\n   * Registers an EventListener if it hasn't been registered.\n   * @param {EventCallback} callback A function called after the event handler to handle its context.\n   * @returns {unregister | void} A function to unregister the registered EventListener if registration is performed.\n   */\n  function register(callback) {\n    if (eventHandler !== null) {\n      return;\n    }\n    eventHandler = createHandler(callback);\n    window.addEventListener(eventType, eventHandler);\n\n    return unregister;\n  }\n\n  return register;\n}\n\nconst handleError = createWindowEventHandler('error', createErrorHandler);\nconst handleUnhandledRejection = createWindowEventHandler(\n  'unhandledrejection',\n  createRejectionHandler\n);\n\nmodule.exports = {\n  handleError: handleError,\n  handleUnhandledRejection: handleUnhandledRejection,\n};\n"
  },
  {
    "path": "client/utils/formatWebpackErrors.js",
    "content": "/**\n * @typedef {Object} WebpackErrorObj\n * @property {string} moduleIdentifier\n * @property {string} moduleName\n * @property {string} message\n */\n\nconst friendlySyntaxErrorLabel = 'Syntax error:';\n\n/**\n * Checks if the error message is for a syntax error.\n * @param {string} message The raw Webpack error message.\n * @returns {boolean} Whether the error message is for a syntax error.\n */\nfunction isLikelyASyntaxError(message) {\n  return message.indexOf(friendlySyntaxErrorLabel) !== -1;\n}\n\n/**\n * Cleans up Webpack error messages.\n *\n * This implementation is based on the one from [create-react-app](https://github.com/facebook/create-react-app/blob/edc671eeea6b7d26ac3f1eb2050e50f75cf9ad5d/packages/react-dev-utils/formatWebpackMessages.js).\n * @param {string} message The raw Webpack error message.\n * @returns {string} The formatted Webpack error message.\n */\nfunction formatMessage(message) {\n  let lines = message.split('\\n');\n\n  // Strip Webpack-added headers off errors/warnings\n  // https://github.com/webpack/webpack/blob/master/lib/ModuleError.js\n  lines = lines.filter(function (line) {\n    return !/Module [A-z ]+\\(from/.test(line);\n  });\n\n  // Remove leading newline\n  if (lines.length > 2 && lines[1].trim() === '') {\n    lines.splice(1, 1);\n  }\n\n  // Remove duplicated newlines\n  lines = lines.filter(function (line, index, arr) {\n    return index === 0 || line.trim() !== '' || line.trim() !== arr[index - 1].trim();\n  });\n\n  // Clean up the file name\n  lines[0] = lines[0].replace(/^(.*) \\d+:\\d+-\\d+$/, '$1');\n\n  // Cleans up verbose \"module not found\" messages for files and packages.\n  if (lines[1] && lines[1].indexOf('Module not found: ') === 0) {\n    lines = [\n      lines[0],\n      lines[1]\n        .replace('Error: ', '')\n        .replace('Module not found: Cannot find file:', 'Cannot find file:'),\n    ];\n  }\n\n  message = lines.join('\\n');\n\n  // Clean up syntax errors\n  message = message.replace('SyntaxError:', friendlySyntaxErrorLabel);\n\n  // Internal stacks are generally useless, so we strip them -\n  // except the stacks containing `webpack:`,\n  // because they're normally from user code generated by webpack.\n  message = message.replace(/^\\s*at\\s((?!webpack:).)*:\\d+:\\d+[\\s)]*(\\n|$)/gm, ''); // at ... ...:x:y\n  message = message.replace(/^\\s*at\\s((?!webpack:).)*<anonymous>[\\s)]*(\\n|$)/gm, ''); // at ... <anonymous>\n  message = message.replace(/^\\s*at\\s<anonymous>(\\n|$)/gm, ''); // at <anonymous>\n\n  return message.trim();\n}\n\n/**\n * Formats Webpack error messages into a more readable format.\n * @param {Array<string | WebpackErrorObj>} errors An array of Webpack error messages.\n * @returns {string[]} The formatted Webpack error messages.\n */\nfunction formatWebpackErrors(errors) {\n  let formattedErrors = errors.map(function (errorObjOrMessage) {\n    // Webpack 5 compilation errors are in the form of descriptor objects,\n    // so we have to join pieces to get the format we want.\n    if (typeof errorObjOrMessage === 'object') {\n      return formatMessage([errorObjOrMessage.moduleName, errorObjOrMessage.message].join('\\n'));\n    }\n    // Webpack 4 compilation errors are strings\n    return formatMessage(errorObjOrMessage);\n  });\n\n  if (formattedErrors.some(isLikelyASyntaxError)) {\n    // If there are any syntax errors, show just them.\n    formattedErrors = formattedErrors.filter(isLikelyASyntaxError);\n  }\n  return formattedErrors;\n}\n\nmodule.exports = formatWebpackErrors;\n"
  },
  {
    "path": "client/utils/retry.js",
    "content": "function runWithRetry(callback, maxRetries, message) {\n  function executeWithRetryAndTimeout(currentCount) {\n    try {\n      if (currentCount > maxRetries - 1) {\n        console.warn('[React Refresh]', message);\n        return;\n      }\n\n      callback();\n    } catch (err) {\n      setTimeout(\n        function () {\n          executeWithRetryAndTimeout(currentCount + 1);\n        },\n        Math.pow(10, currentCount)\n      );\n    }\n  }\n\n  executeWithRetryAndTimeout(0);\n}\n\nmodule.exports = runWithRetry;\n"
  },
  {
    "path": "docs/API.md",
    "content": "# API\n\n## Directives\n\nThe `react-refresh/babel` plugin provide support to directive comments out of the box.\n\n### `reset`\n\n```js\n/* @refresh reset */\n```\n\nThis directive tells React Refresh to force reset state on every refresh (current file only).\nThis can be useful, for example, to reset error boundary components' state,\nso it doesn't persist when new code is executed.\n\n## Options\n\nThis plugin accepts a few options to tweak its behaviour.\n\nIn usual scenarios, you probably wouldn't have to reach for them -\nthey exist specifically to enable integration in more advanced/complicated setups.\n\n### `ReactRefreshPluginOptions`\n\n```ts\ninterface ReactRefreshPluginOptions {\n  forceEnable?: boolean;\n  exclude?: string | RegExp | Array<string | RegExp>;\n  include?: string | RegExp | Array<string | RegExp>;\n  library?: string;\n  esModule?: boolean | ESModuleOptions;\n  overlay?: boolean | ErrorOverlayOptions;\n}\n```\n\n#### `forceEnable`\n\nType: `boolean`\n\nDefault: `undefined`\n\nEnables the plugin forcefully.\n\nIt is useful if you want to:\n\n- Use the plugin in production;\n- Use the plugin with the `none` mode in Webpack without setting `NODE_ENV`;\n- Use the plugin in environments we do not support, such as `electron-prerender`\n  (**WARNING: Proceed at your own risk!**).\n\n#### `exclude`\n\nType: `string | RegExp | Array<string | RegExp>`\n\nDefault: `/node_modules/`\n\nExclude files from being processed by the plugin.\nThis is similar to the `module.rules` option in Webpack.\n\n#### `include`\n\nType: `string | RegExp | Array<string | RegExp>`\n\nDefault: `/\\.([jt]sx?|flow)$/i`\n\nInclude files to be processed by the plugin.\nThis is similar to the `module.rules` option in Webpack.\n\n#### `library`\n\nType: `string`\n\nDefault: `''`, or `output.uniqueName` in Webpack 5, or `output.library` for both Webpack 4/5 if set\n\nSets a namespace for the React Refresh runtime.\nThis is similar to the `output.uniqueName` in Webpack 5 or the `output.library` option in Webpack 4/5.\n\nIt is most useful when multiple instances of React Refresh is running together simultaneously.\n\n#### `esModule`\n\nType: `boolean | ESModuleOptions`\n\nDefault: `undefined` (auto-detection)\n\nEnables strict ES Modules compatible runtime.\nBy default, the plugin will try to infer the module system same as Webpack 5,\neither via the `type` property in `package.json` (`commonjs` and `module`),\nor via the file extension (`.cjs` and `.mjs`).\n\nIt is most useful when you want to enforce output of native ESM code.\n\nSee the [`ESModuleOptions`](#esmoduleoptions) section below for more details on the object API.\n\n#### `overlay`\n\nType: `boolean | ErrorOverlayOptions`\n\nDefault:\n\n```json5\n{\n  entry: '@pmmmwh/react-refresh-webpack-plugin/client/ErrorOverlayEntry',\n  module: '@pmmmwh/react-refresh-webpack-plugin/overlay',\n  sockIntegration: 'wds',\n}\n```\n\nModifies behaviour of the plugin's error overlay integration:\n\n- If `overlay` is not provided or `true`, the **DEFAULT** behaviour will be used;\n- If `overlay` is `false`, the error overlay integration will be **DISABLED**;\n- If `overlay` is an object (`ErrorOverlayOptions`), it will act with respect to what is provided\n  (\\*NOTE: This is targeted for ADVANCED use cases.).\n\nSee the [`ErrorOverlayOptions`](#erroroverlayoptions) section below for more details on the object API.\n\n### `ESModuleOptions`\n\n```ts\ninterface ESModuleOptions {\n  exclude?: string | RegExp | Array<string | RegExp>;\n  include?: string | RegExp | Array<string | RegExp>;\n}\n```\n\n#### `exclude`\n\nType: `string | RegExp | Array<string | RegExp>`\n\nDefault: `/node_modules/`\n\nExclude files from being processed as ESM.\nThis is similar to the `module.rules` option in Webpack.\n\n#### `include`\n\nType: `string | RegExp | Array<string | RegExp>`\n\nDefault: `/\\.([jt]sx?|flow)$/i`\n\nInclude files to be processed as ESM.\nThis is similar to the `module.rules` option in Webpack.\n\n### `ErrorOverlayOptions`\n\n```ts\ninterface ErrorOverlayOptions {\n  entry?: string | false;\n  module?: string | false;\n  sockIntegration?: 'wds' | 'whm' | 'wps' | false | string;\n}\n```\n\n#### `entry`\n\nType: `string | false`\n\nDefault: `'@pmmmwh/react-refresh-webpack-plugin/client/ErrorOverlayEntry'`\n\nThe **PATH** to a file/module that sets up the error overlay integration.\nBoth **ABSOLUTE** and **RELATIVE** paths are acceptable, but it is recommended to use the **FORMER**.\n\nWhen set to `false`, no code will be injected for this stage.\n\n#### `module`\n\nType: `string | false`\n\nDefault: `'@pmmmwh/react-refresh-webpack-plugin/overlay'`\n\nThe **PATH** to a file/module to be used as an error overlay (e.g. `react-error-overlay`).\nBoth **ABSOLUTE** and **RELATIVE** paths are acceptable, but it is recommended to use the **FORMER**.\n\nThe provided file should contain two **NAMED** exports:\n\n```ts\nfunction handleRuntimeError(error: Error) {}\nfunction clearRuntimeErrors() {}\n```\n\n- `handleRuntimeError` is invoked when a **RUNTIME** error is **CAUGHT** (e.g. during module initialisation or execution);\n- `clearRuntimeErrors` is invoked when a module is **RE-INITIALISED** via \"Fast Refresh\".\n\nIf the default `entry` is used, the file should contain two more **NAMED** exports:\n\n```ts\nfunction showCompileError(webpackErrorMessage: string) {}\nfunction clearCompileError() {}\n```\n\n- `showCompileError` is invoked when an error occurred during a Webpack compilation\n  (NOTE: `webpackErrorMessage` might be ANSI encoded depending on the integration);\n- `clearCompileError` is invoked when a new Webpack compilation is started (i.e. HMR rebuild).\n\n> Note: if you want to use `react-error-overlay` as a value to this option,\n> you should instead use `react-dev-utils/refreshOverlayInterop` or implement a similar interop.\n> The APIs expected by this plugin is slightly different from what `react-error-overlay` provides out-of-the-box.\n\n#### `sockIntegration`\n\nDefault: `wds`\n\nType: `wds`, `whm`, `wps`, `false` or `string`\n\nThe HMR integration that the error overlay will interact with -\nit can either be a short form name of the integration (`wds`, `whm`, `wps`),\nor a **PATH** to a file/module that sets up a connection to receive Webpack build messages.\nBoth **ABSOLUTE** and **RELATIVE** paths are acceptable, but it is recommended to use the **FORMER**.\n\nCommon HMR integrations (for Webpack) are support by this plugin out-of-the-box:\n\n- For `webpack-dev-server`, you can skip this option or set it to `wds`;\n- For `webpack-hot-middleware`, set this option to `whm`;\n- For `webpack-plugin-serve`, set this option to `wps`.\n\nIf you use any other HMR integrations (e.g. custom ones), or if you want to customise how the connection is being setup,\nyou will need to implement a message client in the provided file/module.\nYou can reference implementations inside the [`sockets`](https://github.com/pmmmwh/react-refresh-webpack-plugin/tree/main/sockets) directory.\n"
  },
  {
    "path": "docs/TROUBLESHOOTING.md",
    "content": "# Troubleshooting\n\n## Coming from `react-hot-loader`\n\nIf you are coming from `react-hot-loader`, before using the plugin,\nyou have to ensure that you've completely erased the integration of RHL from your app:\n\n- Removed the `react-hot-loader/babel` Babel plugin (from Babel config variants or Webpack config)\n- Removed the `react-hot-loader/patch` Webpack entry\n- Removed the `react-hot-loader/webpack` Webpack loader\n- Removed the alias of `react-dom` to `@hot-loader/react-dom` (from `package.json` or Webpack config)\n- Removed imports and their usages from `react-hot-loader`\n\nThis has to be done because, internally,\n`react-hot-loader` intercepts and reconciles the React tree before React can try to re-render it.\nThat in turn breaks mechanisms the plugin depends on to deliver the experience.\n\n## Compatibility with `npm@7`\n\n`npm@7` have brought back the behaviour of auto-installing peer dependencies with new semantics,\nbut their support for optional peer dependencies,\nused by this plugin to provide support to multiple integrations without bundling them all,\nare known to be a bit lacking.\n\nIf you encounter the `ERESOLVE` error code while running `npm install` -\nyou can fallback to use the legacy dependency resolution algorithm and it should resolve the issue:\n\n```sh\nnpm install --legacy-peer-deps\n```\n\n## Usage with CSS Files/Imports\n\nThis plugin does not provide HMR for CSS.\nTo achieve that,\nyou should be using [`style-loader`](https://github.com/webpack-contrib/style-loader) or [`mini-css-extract-plugin`](https://github.com/webpack-contrib/mini-css-extract-plugin).\n\nBoth provides HMR capabilities out of the box for Webpack 5 -\nif are still on Webpack 4 and uses `mini-css-extract-plugin`, you might have to [do some setup](https://github.com/webpack-contrib/mini-css-extract-plugin/#hot-module-reloading-hmr).\n\n## Usage with Indirection (like Workers and JS Templates)\n\nIf you share the Babel config for files in an indirect code path (e.g. Web Workers, JS Templates with partial pre-render) and all your other source files,\nyou might experience this error:\n\n```\nUncaught ReferenceError: $RefreshReg$ is not defined\n```\n\nThe reason is that when using child compilers (e.g. `html-webpack-plugin`, `worker-plugin`), plugins are usually not applied (but loaders are).\nThis means that code processed by `react-refresh/babel` is not further transformed by this plugin and will lead to broken builds.\n\nTo solve this issue, you can choose one of the following workarounds:\n\n**Sloppy**\n\nIn the entry of your indirect code path (e.g. some `index.js`), add the following two lines:\n\n```js\nself.$RefreshReg$ = () => {};\nself.$RefreshSig$ = () => () => {};\n```\n\nThis basically acts as a \"polyfill\" for helpers expected by `react-refresh/babel`, so the worker can run properly.\n\n**Simple**\n\nEnsure all exports within the indirect code path are not named in `PascalCase`.\nThis will tell the Babel plugin to do nothing when it hits those files.\n\nIn general, the `PascalCase` naming scheme should be reserved for React components only,\nand it doesn't really make sense for them to exist within non-React-rendering contexts.\n\n**Robust but complex**\n\nIn your Webpack configuration, alter the Babel setup as follows:\n\n```js\n{\n  rules: [\n    // JS-related rules only\n    {\n      oneOf: [\n        {\n          test: /\\.[jt]s$/,\n          include: '<Your indirection files here>',\n          exclude: /node_modules/,\n          use: {\n            loader: 'babel-loader',\n            options: {\n              // Your Babel config here\n            },\n          },\n        },\n        {\n          test: /\\.[jt]sx?$/,\n          include: '<Your files here>',\n          exclude: ['<Your indirection files here>', /node_modules/],\n          use: {\n            loader: 'babel-loader',\n            options: {\n              // Your Babel config here\n              plugins: [isDevelopment && 'react-refresh/babel'].filter(Boolean),\n            },\n          },\n        },\n      ],\n    },\n    // Any other rules, such as CSS\n    {\n      test: /\\.css$/,\n      use: ['style-loader', 'css-loader'],\n    },\n  ];\n}\n```\n\nThis would ensure that your indirect code path will not be processed by `react-refresh/babel`,\nthus eliminating the problem completely.\n\n## Hot Module Replacement (HMR) is not enabled\n\nThis means that you have not enabled HMR for Webpack, or we are unable to detect a working HMR implementation from the compilation context.\n\n**Using `webpack-dev-server`**\n\nSet the `hot` or `hotOnly` options to `true`.\n\n**Using `webpack-hot-middleware`**\n\nAdd `HotModuleReplacementPlugin` to your list of plugins to use in development mode.\n\n**Using `webpack-plugin-serve`**\n\nSet the `hmr` option to `true`.\n\n## State not preserved for class components\n\nThis is intended behaviour.\nIf you're coming from [react-hot-loader](https://github.com/gaearon/react-hot-loader), this might be the biggest surprise for you.\n\nThe main rationale behind this is listed in [this wish list for hot reloading](https://overreacted.io/my-wishlist-for-hot-reloading/):\n\n> It is better to lose local state than to behave incorrectly.\n>\n> It is better to lose local state than use an old version.\n\nThe truth is, historically, hot reloading for class components was never reliable and maintainable.\nIt was implemented based on workarounds like wrapping components with Proxies.\n\nWhile these workarounds made hot reloading \"work\" on the surface, they led to inconsistencies in other departments:\n\n- Lifecycle methods will fire randomly at random times;\n- Type checks will fail randomly (`<Component />.type === Component` is `false`); and\n- Mutation of React's internals, which is difficult to manage and will need to play catch up with React as we move into the future (a-la Concurrent Mode).\n\nThus, to keep fast refresh reliable and resilient to errors (with recovery for most cases), class components will always be re-mounted on a hot update.\n\n## Edits always lead to full reload\n\nIn most cases, if the plugin is applied correctly, it would mean that we weren't able to set up boundaries to stop update propagation.\nIt can be narrowed down to a few unsupported patterns:\n\n1. Un-named/non-pascal-case-named components\n\n   See [this tweet](https://twitter.com/dan_abramov/status/1255229440860262400) for drawbacks of not giving component proper names.\n   They are impossible to support because we have no ways to statically determine they are React-related.\n   This issue also exist for other React developer tools, like the [hooks ESLint plugin](https://www.npmjs.com/package/eslint-plugin-react-hooks).\n   Internal components in HOCs also have to conform to this rule.\n\n   ```jsx\n   // won't work\n   export default () => <div />;\n   export default function () {\n     return <div />;\n   }\n   export default function divContainer() {\n     return <div />;\n   }\n   ```\n\n2. Chain of files leading to root with none containing React-related content only\n\n   This pattern cannot be supported because we cannot ensure non-React-related content are free of side effects.\n   Usually with this error you will see something like this in the browser console:\n\n   ```\n   Ignored an update to unaccepted module ... [a very long path]\n   ```\n\n3. `export * from 'namespace'` (TypeScript only)\n\n   This only affect users using TypeScript on Babel.\n   This pattern is only supported when you don't mix normal exports with type exports, or when all your exports conform to the `PascalCase` rule.\n   This is because we cannot statically analyse the exports from the namespace to determine whether we can set up a boundary and stop update propagation.\n\n## Component not updating with bundle splitting techniques\n\nWebpack allows various bundle splitting techniques to improve performance and cacheability.\nHowever, these techniques often result in a shuffled execution order, which will break fast refresh.\n\nTo make fast refresh work properly, make sure your Webpack configuration comply to the following rules:\n\n1. All React-related packages (including custom reconcilers) should be in the same chunk with `react-refresh/runtime`\n\n   Because fast refresh internally uses the React DevTools protocol and have to be registered before any React code runs,\n   all React-related stuff needs to be in the same chunk to ensure execution order and object equality in the form of `WeakMap` keys.\n\n   **Using DLL plugin**\n\n   Ensure the entries for the DLL include `react-refresh/runtime`,\n   and the `mode` option is set to `development`.\n\n   ```js\n   module.exports = {\n     mode: 'development',\n     entry: ['react', 'react-dom', 'react-refresh/runtime'],\n   };\n   ```\n\n   **Using multiple entries**\n\n   Ensure the `react` chunk includes `react-refresh/runtime`.\n\n   ```js\n   module.exports = {\n     entry: {\n       main: 'index.js',\n       vendors: ['react', 'react-dom', 'react-refresh/runtime'],\n     },\n   };\n   ```\n\n2. Only one copy of both the HMR runtime and the plugin's runtime should be embedded for one Webpack app\n\n   This concern only applies when you have multiple entry points.\n   You can use Webpack's `optimization.runtimeChunk` option to enforce this.\n\n   ```js\n   module.exports = {\n     optimization: {\n       runtimeChunk: 'single',\n     },\n   };\n   ```\n\n## Externalising React\n\nFast refresh relies on initialising code before **ANY** React code is ran.\nIf you externalise React, however, it is likely that this plugin cannot inject the necessary runtime code before it.\n\nYou can deal with this in a few ways (also see [#334](https://github.com/pmmmwh/react-refresh-webpack-plugin/issues/334) for relevant discussion).\n\n**Production-only externalisation**\n\nThe simplest solution to this issue is to simply not externalise React in development.\nThis would guarantee any code injected by this plugin run before any React code,\nand would require the least manual tweaking.\n\n**Use React DevTools**\n\nIf the execution environment is something you can control, and you wanted to externalise React in development,\nyou can use React DevTools which would inject hooks to the environment for React to attach to.\n\nReact Refresh should be able to hook into copies of React connected this way even it runs afterwards,\nbut do note that React DevTools does not inject hooks over a frame boundary (`iframe`).\n\n**Externalise React Refresh**\n\nIf all solutions above are not applicable, you can also externalise `react-refresh/runtime` together with React.\nWe provide an entrypoint to easily achieve this - `@pmmmwh/react-refresh-webpack-plugin/umd/client.min.js`.\n\nIf you would like to use the provided script, ensure that it is loaded before React and/or React-DOM.\nYou can load this script via any CDN for `npm`, such as `jsDelivr` and `unpkg`:\n\n```html\n<!-- if you prefer jsDelivr -->\n<script src=\" https://cdn.jsdelivr.net/npm/@pmmmwh/react-refresh-webpack-plugin@^0.6.2/umd/client.min.js \"></script>\n\n<!-- if you prefer unpkg -->\n<script src=\"https://unpkg.com/@pmmmwh/react-refresh-webpack-plugin@^0.6.2/umd/client.min.js\"></script>\n```\n\nIf you don't want to use the provided script,\nyou can check out [this sandbox](https://codesandbox.io/s/react-refresh-externals-14fpn) for an example on how this could be done manually.\n\n## Running multiple instances of React Refresh simultaneously\n\nIf you are running on a micro-frontend architecture (e.g. Module Federation in Webpack 5),\nyou should set the `library` output to ensure proper namespacing in the runtime injection script.\n\n**Using Webpack's `output.uniqueName` option (Webpack 5 only)**\n\n```js\nmodule.exports = {\n  output: {\n    uniqueName: 'YourLibrary',\n  },\n};\n```\n\n**Using Webpack's `output.library` option**\n\n```js\nmodule.exports = {\n  output: {\n    library: 'YourLibrary',\n  },\n};\n```\n\n**Using the plugin's `library` option**\n\n```js\nmodule.exports = {\n  plugins: [\n    new ReactRefreshPlugin({\n      library: 'YourLibrary',\n    }),\n  ],\n};\n```\n"
  },
  {
    "path": "examples/flow-with-babel/.flowconfig",
    "content": "[ignore]\n\n[include]\n\n[libs]\n\n[lints]\n\n[options]\n\n[strict]\n"
  },
  {
    "path": "examples/flow-with-babel/babel.config.js",
    "content": "module.exports = (api) => {\n  // This caches the Babel config\n  api.cache.using(() => process.env.NODE_ENV);\n  return {\n    presets: [\n      '@babel/preset-env',\n      '@babel/preset-flow',\n      // Enable development transform of React with new automatic runtime\n      ['@babel/preset-react', { development: !api.env('production'), runtime: 'automatic' }],\n    ],\n    // Applies the react-refresh Babel plugin on non-production modes only\n    ...(!api.env('production') && { plugins: ['react-refresh/babel'] }),\n  };\n};\n"
  },
  {
    "path": "examples/flow-with-babel/package.json",
    "content": "{\n  \"name\": \"using-flow-with-babel\",\n  \"version\": \"0.1.0\",\n  \"private\": true,\n  \"dependencies\": {\n    \"react\": \"^19.0.0\",\n    \"react-dom\": \"^19.0.0\"\n  },\n  \"devDependencies\": {\n    \"@babel/core\": \"^7.26.10\",\n    \"@babel/preset-env\": \"^7.26.9\",\n    \"@babel/preset-flow\": \"^7.25.9\",\n    \"@babel/preset-react\": \"^7.26.3\",\n    \"@pmmmwh/react-refresh-webpack-plugin\": \"^0.6.0\",\n    \"babel-loader\": \"^10.0.0\",\n    \"cross-env\": \"^7.0.3\",\n    \"flow-bin\": \"^0.266.1\",\n    \"html-webpack-plugin\": \"^5.6.3\",\n    \"react-refresh\": \"^0.17.0\",\n    \"webpack\": \"^5.98.0\",\n    \"webpack-cli\": \"^6.0.1\",\n    \"webpack-dev-server\": \"^5.2.1\"\n  },\n  \"scripts\": {\n    \"start\": \"webpack serve --hot\",\n    \"build\": \"cross-env NODE_ENV=production webpack\"\n  }\n}\n"
  },
  {
    "path": "examples/flow-with-babel/public/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"UTF-8\" />\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n    <title>Flow React App</title>\n  </head>\n  <body>\n    <div id=\"app\"></div>\n  </body>\n</html>\n"
  },
  {
    "path": "examples/flow-with-babel/src/App.jsx",
    "content": "// @flow\n\nimport { lazy, Suspense } from 'react';\nimport { ArrowFunction } from './ArrowFunction';\nimport ClassDefault from './ClassDefault';\nimport { ClassNamed } from './ClassNamed';\nimport FunctionDefault from './FunctionDefault';\nimport { FunctionNamed } from './FunctionNamed';\n\nconst LazyComponent = lazy(() => import('./LazyComponent'));\n\nfunction App() {\n  return (\n    <div>\n      <ClassDefault />\n      <ClassNamed />\n      <FunctionDefault />\n      <FunctionNamed />\n      <ArrowFunction />\n      <Suspense fallback={<h1>Loading</h1>}>\n        <LazyComponent />\n      </Suspense>\n    </div>\n  );\n}\n\nexport default App;\n"
  },
  {
    "path": "examples/flow-with-babel/src/ArrowFunction.jsx",
    "content": "// @flow\n\nexport const ArrowFunction = () => <h1>Arrow Function</h1>;\n"
  },
  {
    "path": "examples/flow-with-babel/src/ClassDefault.jsx",
    "content": "// @flow\n\nimport { Component } from 'react';\n\nclass ClassDefault extends Component<{}> {\n  render() {\n    return <h1>Default Export Class</h1>;\n  }\n}\n\nexport default ClassDefault;\n"
  },
  {
    "path": "examples/flow-with-babel/src/ClassNamed.jsx",
    "content": "// @flow\n\nimport { Component } from 'react';\n\nexport class ClassNamed extends Component<{}> {\n  render() {\n    return <h1>Named Export Class</h1>;\n  }\n}\n"
  },
  {
    "path": "examples/flow-with-babel/src/FunctionDefault.jsx",
    "content": "// @flow\n\nfunction FunctionDefault() {\n  return <h1>Default Export Function</h1>;\n}\n\nexport default FunctionDefault;\n"
  },
  {
    "path": "examples/flow-with-babel/src/FunctionNamed.jsx",
    "content": "// @flow\n\nexport function FunctionNamed() {\n  return <h1>Named Export Function</h1>;\n}\n"
  },
  {
    "path": "examples/flow-with-babel/src/LazyComponent.jsx",
    "content": "// @flow\n\nfunction LazyComponent() {\n  return <h1>Lazy Component</h1>;\n}\n\nexport default LazyComponent;\n"
  },
  {
    "path": "examples/flow-with-babel/src/index.js",
    "content": "// @flow\n\nimport { createRoot } from 'react-dom/client';\nimport App from './App';\n\nconst container = document.getElementById('app');\nconst root = createRoot(container);\nroot.render(<App />);\n"
  },
  {
    "path": "examples/flow-with-babel/webpack.config.js",
    "content": "const path = require('path');\nconst ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');\nconst HtmlWebpackPlugin = require('html-webpack-plugin');\n\nconst isDevelopment = process.env.NODE_ENV !== 'production';\n\nmodule.exports = {\n  mode: isDevelopment ? 'development' : 'production',\n  devServer: {\n    client: { overlay: false },\n  },\n  entry: {\n    main: './src/index.js',\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.jsx?$/,\n        include: path.join(__dirname, 'src'),\n        use: 'babel-loader',\n      },\n    ],\n  },\n  plugins: [\n    isDevelopment && new ReactRefreshPlugin(),\n    new HtmlWebpackPlugin({\n      filename: './index.html',\n      template: './public/index.html',\n    }),\n  ].filter(Boolean),\n  resolve: {\n    extensions: ['.js', '.jsx'],\n  },\n};\n"
  },
  {
    "path": "examples/typescript-with-babel/babel.config.js",
    "content": "module.exports = (api) => {\n  // This caches the Babel config\n  api.cache.using(() => process.env.NODE_ENV);\n  return {\n    presets: [\n      '@babel/preset-env',\n      '@babel/preset-typescript',\n      // Enable development transform of React with new automatic runtime\n      ['@babel/preset-react', { development: !api.env('production'), runtime: 'automatic' }],\n    ],\n    // Applies the react-refresh Babel plugin on non-production modes only\n    ...(!api.env('production') && { plugins: ['react-refresh/babel'] }),\n  };\n};\n"
  },
  {
    "path": "examples/typescript-with-babel/package.json",
    "content": "{\n  \"name\": \"using-typescript-with-babel\",\n  \"version\": \"0.1.0\",\n  \"private\": true,\n  \"dependencies\": {\n    \"react\": \"^19.0.0\",\n    \"react-dom\": \"^19.0.0\"\n  },\n  \"devDependencies\": {\n    \"@babel/core\": \"^7.26.10\",\n    \"@babel/preset-env\": \"^7.26.9\",\n    \"@babel/preset-react\": \"^7.26.3\",\n    \"@babel/preset-typescript\": \"^7.27.0\",\n    \"@pmmmwh/react-refresh-webpack-plugin\": \"^0.6.0\",\n    \"@types/react\": \"^19.0.0\",\n    \"@types/react-dom\": \"^19.0.0\",\n    \"babel-loader\": \"^10.0.0\",\n    \"cross-env\": \"^7.0.3\",\n    \"fork-ts-checker-webpack-plugin\": \"^9.1.0\",\n    \"html-webpack-plugin\": \"^5.6.3\",\n    \"react-refresh\": \"^0.17.0\",\n    \"typescript\": \"~5.8.3\",\n    \"webpack\": \"^5.98.0\",\n    \"webpack-cli\": \"^6.0.1\",\n    \"webpack-dev-server\": \"^5.2.1\"\n  },\n  \"scripts\": {\n    \"start\": \"webpack serve --hot\",\n    \"build\": \"cross-env NODE_ENV=production webpack\"\n  }\n}\n"
  },
  {
    "path": "examples/typescript-with-babel/public/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"UTF-8\" />\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n    <title>TS React App</title>\n  </head>\n  <body>\n    <div id=\"app\"></div>\n  </body>\n</html>\n"
  },
  {
    "path": "examples/typescript-with-babel/src/App.tsx",
    "content": "import { lazy, Suspense } from 'react';\nimport { ArrowFunction } from './ArrowFunction';\nimport ClassDefault from './ClassDefault';\nimport { ClassNamed } from './ClassNamed';\nimport FunctionDefault from './FunctionDefault';\nimport { FunctionNamed } from './FunctionNamed';\n\nconst LazyComponent = lazy(() => import('./LazyComponent'));\n\nfunction App() {\n  return (\n    <div>\n      <ClassDefault />\n      <ClassNamed />\n      <FunctionDefault />\n      <FunctionNamed />\n      <ArrowFunction />\n      <Suspense fallback={<h1>Loading</h1>}>\n        <LazyComponent />\n      </Suspense>\n    </div>\n  );\n}\n\nexport default App;\n"
  },
  {
    "path": "examples/typescript-with-babel/src/ArrowFunction.tsx",
    "content": "export const ArrowFunction = () => <h1>Arrow Function</h1>;\n"
  },
  {
    "path": "examples/typescript-with-babel/src/ClassDefault.tsx",
    "content": "import { Component } from 'react';\n\nclass ClassDefault extends Component {\n  render() {\n    return <h1>Default Export Class</h1>;\n  }\n}\n\nexport default ClassDefault;\n"
  },
  {
    "path": "examples/typescript-with-babel/src/ClassNamed.tsx",
    "content": "import { Component } from 'react';\n\nexport class ClassNamed extends Component {\n  render() {\n    return <h1>Named Export Class</h1>;\n  }\n}\n"
  },
  {
    "path": "examples/typescript-with-babel/src/FunctionDefault.tsx",
    "content": "function FunctionDefault() {\n  return <h1>Default Export Function</h1>;\n}\n\nexport default FunctionDefault;\n"
  },
  {
    "path": "examples/typescript-with-babel/src/FunctionNamed.tsx",
    "content": "export function FunctionNamed() {\n  return <h1>Named Export Function</h1>;\n}\n"
  },
  {
    "path": "examples/typescript-with-babel/src/LazyComponent.tsx",
    "content": "function LazyComponent() {\n  return <h1>Lazy Component</h1>;\n}\n\nexport default LazyComponent;\n"
  },
  {
    "path": "examples/typescript-with-babel/src/index.tsx",
    "content": "import { createRoot } from 'react-dom/client';\nimport App from './App';\n\nconst container = document.getElementById('app');\nconst root = createRoot(container!);\nroot.render(<App />);\n"
  },
  {
    "path": "examples/typescript-with-babel/tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"jsx\": \"react-jsx\",\n    \"lib\": [\"dom\", \"dom.iterable\", \"esnext\"],\n    \"module\": \"ESNext\",\n    \"moduleResolution\": \"node\",\n    \"outDir\": \"dist\",\n    \"target\": \"ESNext\",\n    \"sourceMap\": true\n  },\n  \"include\": [\"src\"]\n}\n"
  },
  {
    "path": "examples/typescript-with-babel/webpack.config.js",
    "content": "const path = require('path');\nconst ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');\nconst ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');\nconst HtmlWebpackPlugin = require('html-webpack-plugin');\n\nconst isDevelopment = process.env.NODE_ENV !== 'production';\n\nmodule.exports = {\n  mode: isDevelopment ? 'development' : 'production',\n  devServer: {\n    client: { overlay: false },\n  },\n  entry: {\n    main: './src/index.tsx',\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.tsx?$/,\n        include: path.join(__dirname, 'src'),\n        use: 'babel-loader',\n      },\n    ],\n  },\n  plugins: [\n    isDevelopment && new ReactRefreshPlugin(),\n    new ForkTsCheckerWebpackPlugin(),\n    new HtmlWebpackPlugin({\n      filename: './index.html',\n      template: './public/index.html',\n    }),\n  ].filter(Boolean),\n  resolve: {\n    extensions: ['.js', '.ts', '.tsx'],\n  },\n};\n"
  },
  {
    "path": "examples/typescript-with-swc/package.json",
    "content": "{\n  \"name\": \"using-typescript-with-swc\",\n  \"version\": \"0.1.0\",\n  \"private\": true,\n  \"dependencies\": {\n    \"react\": \"^19.0.0\",\n    \"react-dom\": \"^19.0.0\"\n  },\n  \"devDependencies\": {\n    \"@pmmmwh/react-refresh-webpack-plugin\": \"^0.6.0\",\n    \"@swc/core\": \"^1.11.16\",\n    \"@types/react\": \"^19.0.0\",\n    \"@types/react-dom\": \"^19.0.0\",\n    \"core-js\": \"^3.41.0\",\n    \"cross-env\": \"^7.0.3\",\n    \"fork-ts-checker-webpack-plugin\": \"^9.1.0\",\n    \"html-webpack-plugin\": \"^5.6.3\",\n    \"react-refresh\": \"^0.17.0\",\n    \"swc-loader\": \"^0.2.6\",\n    \"typescript\": \"~5.8.3\",\n    \"webpack\": \"^5.98.0\",\n    \"webpack-cli\": \"^6.0.1\",\n    \"webpack-dev-server\": \"^5.2.1\"\n  },\n  \"scripts\": {\n    \"start\": \"webpack serve --hot\",\n    \"build\": \"cross-env NODE_ENV=production webpack\"\n  }\n}\n"
  },
  {
    "path": "examples/typescript-with-swc/public/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"UTF-8\" />\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n    <title>swc React App</title>\n  </head>\n  <body>\n    <div id=\"app\"></div>\n  </body>\n</html>\n"
  },
  {
    "path": "examples/typescript-with-swc/src/App.tsx",
    "content": "import { lazy, Suspense } from 'react';\nimport { ArrowFunction } from './ArrowFunction';\nimport ClassDefault from './ClassDefault';\nimport { ClassNamed } from './ClassNamed';\nimport FunctionDefault from './FunctionDefault';\nimport { FunctionNamed } from './FunctionNamed';\n\nconst LazyComponent = lazy(() => import('./LazyComponent'));\n\nfunction App() {\n  return (\n    <div>\n      <ClassDefault />\n      <ClassNamed />\n      <FunctionDefault />\n      <FunctionNamed />\n      <ArrowFunction />\n      <Suspense fallback={<h1>Loading</h1>}>\n        <LazyComponent />\n      </Suspense>\n    </div>\n  );\n}\n\nexport default App;\n"
  },
  {
    "path": "examples/typescript-with-swc/src/ArrowFunction.tsx",
    "content": "export const ArrowFunction = () => <h1>Arrow Function</h1>;\n"
  },
  {
    "path": "examples/typescript-with-swc/src/ClassDefault.tsx",
    "content": "import { Component } from 'react';\n\nclass ClassDefault extends Component {\n  render() {\n    return <h1>Default Export Class</h1>;\n  }\n}\n\nexport default ClassDefault;\n"
  },
  {
    "path": "examples/typescript-with-swc/src/ClassNamed.tsx",
    "content": "import { Component } from 'react';\n\nexport class ClassNamed extends Component {\n  render() {\n    return <h1>Named Export Class</h1>;\n  }\n}\n"
  },
  {
    "path": "examples/typescript-with-swc/src/FunctionDefault.tsx",
    "content": "function FunctionDefault() {\n  return <h1>Default Export Function</h1>;\n}\n\nexport default FunctionDefault;\n"
  },
  {
    "path": "examples/typescript-with-swc/src/FunctionNamed.tsx",
    "content": "export function FunctionNamed() {\n  return <h1>Named Export Function</h1>;\n}\n"
  },
  {
    "path": "examples/typescript-with-swc/src/LazyComponent.tsx",
    "content": "function LazyComponent() {\n  return <h1>Lazy Component</h1>;\n}\n\nexport default LazyComponent;\n"
  },
  {
    "path": "examples/typescript-with-swc/src/index.tsx",
    "content": "import { createRoot } from 'react-dom/client';\nimport App from './App';\n\nconst container = document.getElementById('app');\nconst root = createRoot(container!);\nroot.render(<App />);\n"
  },
  {
    "path": "examples/typescript-with-swc/tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"jsx\": \"react-jsx\",\n    \"lib\": [\"dom\", \"dom.iterable\", \"esnext\"],\n    \"module\": \"ESNext\",\n    \"moduleResolution\": \"node\",\n    \"outDir\": \"dist\",\n    \"target\": \"ESNext\",\n    \"sourceMap\": true\n  },\n  \"include\": [\"src\"]\n}\n"
  },
  {
    "path": "examples/typescript-with-swc/webpack.config.js",
    "content": "const path = require('path');\nconst ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');\nconst ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');\nconst HtmlWebpackPlugin = require('html-webpack-plugin');\n\nconst isDevelopment = process.env.NODE_ENV !== 'production';\n\nmodule.exports = {\n  mode: isDevelopment ? 'development' : 'production',\n  devServer: {\n    client: { overlay: false },\n  },\n  entry: {\n    main: './src/index.tsx',\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.tsx?$/,\n        include: path.join(__dirname, 'src'),\n        use: [\n          {\n            loader: 'swc-loader',\n            options: {\n              env: { mode: 'usage' },\n              jsc: {\n                parser: {\n                  syntax: 'typescript',\n                  tsx: true,\n                  dynamicImport: true,\n                },\n                transform: {\n                  react: {\n                    // swc-loader will check whether webpack mode is 'development'\n                    // and set this automatically starting from 0.1.13. You could also set it yourself.\n                    // swc won't enable fast refresh when development is false\n                    runtime: 'automatic',\n                    refresh: isDevelopment,\n                  },\n                },\n              },\n            },\n          },\n        ],\n      },\n    ],\n  },\n  plugins: [\n    isDevelopment && new ReactRefreshPlugin(),\n    new ForkTsCheckerWebpackPlugin(),\n    new HtmlWebpackPlugin({\n      filename: './index.html',\n      template: './public/index.html',\n    }),\n  ].filter(Boolean),\n  resolve: {\n    extensions: ['.js', '.ts', '.tsx'],\n  },\n};\n"
  },
  {
    "path": "examples/typescript-with-tsc/package.json",
    "content": "{\n  \"name\": \"using-typescript-with-tsc\",\n  \"version\": \"0.1.0\",\n  \"private\": true,\n  \"dependencies\": {\n    \"react\": \"^19.0.0\",\n    \"react-dom\": \"^19.0.0\"\n  },\n  \"devDependencies\": {\n    \"@pmmmwh/react-refresh-webpack-plugin\": \"^0.6.0\",\n    \"@types/react\": \"^19.0.0\",\n    \"@types/react-dom\": \"^19.0.0\",\n    \"cross-env\": \"^7.0.3\",\n    \"fork-ts-checker-webpack-plugin\": \"^9.1.0\",\n    \"html-webpack-plugin\": \"^5.6.3\",\n    \"react-refresh\": \"^0.17.0\",\n    \"react-refresh-typescript\": \"^2.0.10\",\n    \"ts-loader\": \"^9.5.2\",\n    \"typescript\": \"~5.8.3\",\n    \"webpack\": \"^5.98.0\",\n    \"webpack-cli\": \"^6.0.1\",\n    \"webpack-dev-server\": \"^5.2.1\"\n  },\n  \"scripts\": {\n    \"start\": \"webpack serve --hot\",\n    \"build\": \"cross-env NODE_ENV=production webpack\"\n  }\n}\n"
  },
  {
    "path": "examples/typescript-with-tsc/public/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"UTF-8\" />\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n    <title>TSC React App</title>\n  </head>\n  <body>\n    <div id=\"app\"></div>\n  </body>\n</html>\n"
  },
  {
    "path": "examples/typescript-with-tsc/src/App.tsx",
    "content": "import { lazy, Suspense } from 'react';\nimport { ArrowFunction } from './ArrowFunction';\nimport ClassDefault from './ClassDefault';\nimport { ClassNamed } from './ClassNamed';\nimport FunctionDefault from './FunctionDefault';\nimport { FunctionNamed } from './FunctionNamed';\n\nconst LazyComponent = lazy(() => import('./LazyComponent'));\n\nfunction App() {\n  return (\n    <div>\n      <ClassDefault />\n      <ClassNamed />\n      <FunctionDefault />\n      <FunctionNamed />\n      <ArrowFunction />\n      <Suspense fallback={<h1>Loading</h1>}>\n        <LazyComponent />\n      </Suspense>\n    </div>\n  );\n}\n\nexport default App;\n"
  },
  {
    "path": "examples/typescript-with-tsc/src/ArrowFunction.tsx",
    "content": "export const ArrowFunction = () => <h1>Arrow Function</h1>;\n"
  },
  {
    "path": "examples/typescript-with-tsc/src/ClassDefault.tsx",
    "content": "import { Component } from 'react';\n\nclass ClassDefault extends Component {\n  render() {\n    return <h1>Default Export Class</h1>;\n  }\n}\n\nexport default ClassDefault;\n"
  },
  {
    "path": "examples/typescript-with-tsc/src/ClassNamed.tsx",
    "content": "import { Component } from 'react';\n\nexport class ClassNamed extends Component {\n  render() {\n    return <h1>Named Export Class</h1>;\n  }\n}\n"
  },
  {
    "path": "examples/typescript-with-tsc/src/FunctionDefault.tsx",
    "content": "function FunctionDefault() {\n  return <h1>Default Export Function</h1>;\n}\n\nexport default FunctionDefault;\n"
  },
  {
    "path": "examples/typescript-with-tsc/src/FunctionNamed.tsx",
    "content": "export function FunctionNamed() {\n  return <h1>Named Export Function</h1>;\n}\n"
  },
  {
    "path": "examples/typescript-with-tsc/src/LazyComponent.tsx",
    "content": "function LazyComponent() {\n  return <h1>Lazy Component</h1>;\n}\n\nexport default LazyComponent;\n"
  },
  {
    "path": "examples/typescript-with-tsc/src/index.tsx",
    "content": "import { createRoot } from 'react-dom/client';\nimport App from './App';\n\nconst container = document.getElementById('app');\nconst root = createRoot(container!);\nroot.render(<App />);\n"
  },
  {
    "path": "examples/typescript-with-tsc/tsconfig.dev.json",
    "content": "{\n  \"extends\": \"./tsconfig.json\",\n  \"compilerOptions\": {\n    \"jsx\": \"react-jsxdev\"\n  },\n  \"include\": [\"src\"]\n}\n"
  },
  {
    "path": "examples/typescript-with-tsc/tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"jsx\": \"react-jsx\",\n    \"lib\": [\"dom\", \"dom.iterable\", \"esnext\"],\n    \"module\": \"ESNext\",\n    \"moduleResolution\": \"node\",\n    \"outDir\": \"dist\",\n    \"target\": \"ESNext\",\n    \"sourceMap\": true\n  },\n  \"include\": [\"src\"]\n}\n"
  },
  {
    "path": "examples/typescript-with-tsc/webpack.config.js",
    "content": "const path = require('path');\nconst ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');\nconst ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');\nconst HtmlWebpackPlugin = require('html-webpack-plugin');\nconst ReactRefreshTypeScript = require('react-refresh-typescript');\n\nconst isDevelopment = process.env.NODE_ENV !== 'production';\n\nmodule.exports = {\n  mode: isDevelopment ? 'development' : 'production',\n  devServer: {\n    client: { overlay: false },\n  },\n  entry: {\n    main: './src/index.tsx',\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.tsx?$/,\n        include: path.join(__dirname, 'src'),\n        use: [\n          {\n            loader: 'ts-loader',\n            options: {\n              configFile: isDevelopment ? 'tsconfig.dev.json' : 'tsconfig.json',\n              transpileOnly: isDevelopment,\n              ...(isDevelopment && {\n                getCustomTransformers: () => ({\n                  before: [ReactRefreshTypeScript()],\n                }),\n              }),\n            },\n          },\n        ],\n      },\n    ],\n  },\n  plugins: [\n    isDevelopment && new ReactRefreshPlugin(),\n    new ForkTsCheckerWebpackPlugin(),\n    new HtmlWebpackPlugin({\n      filename: './index.html',\n      template: './public/index.html',\n    }),\n  ].filter(Boolean),\n  resolve: {\n    extensions: ['.js', '.ts', '.tsx'],\n  },\n};\n"
  },
  {
    "path": "examples/webpack-dev-server/babel.config.js",
    "content": "module.exports = (api) => {\n  // This caches the Babel config\n  api.cache.using(() => process.env.NODE_ENV);\n  return {\n    presets: [\n      '@babel/preset-env',\n      // Enable development transform of React with new automatic runtime\n      ['@babel/preset-react', { development: !api.env('production'), runtime: 'automatic' }],\n    ],\n    // Applies the react-refresh Babel plugin on non-production modes only\n    ...(!api.env('production') && { plugins: ['react-refresh/babel'] }),\n  };\n};\n"
  },
  {
    "path": "examples/webpack-dev-server/package.json",
    "content": "{\n  \"name\": \"using-webpack-dev-server\",\n  \"version\": \"0.1.0\",\n  \"private\": true,\n  \"dependencies\": {\n    \"react\": \"^19.0.0\",\n    \"react-dom\": \"^19.0.0\"\n  },\n  \"devDependencies\": {\n    \"@babel/core\": \"^7.26.10\",\n    \"@babel/preset-env\": \"^7.26.9\",\n    \"@babel/preset-react\": \"^7.26.3\",\n    \"@pmmmwh/react-refresh-webpack-plugin\": \"^0.6.0\",\n    \"babel-loader\": \"^10.0.0\",\n    \"cross-env\": \"^7.0.3\",\n    \"html-webpack-plugin\": \"^5.6.3\",\n    \"react-refresh\": \"^0.17.0\",\n    \"webpack\": \"^5.98.0\",\n    \"webpack-cli\": \"^6.0.1\",\n    \"webpack-dev-server\": \"^5.2.1\"\n  },\n  \"scripts\": {\n    \"start\": \"webpack serve --hot\",\n    \"build\": \"cross-env NODE_ENV=production webpack\"\n  }\n}\n"
  },
  {
    "path": "examples/webpack-dev-server/public/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"UTF-8\" />\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n    <title>WDS React App</title>\n  </head>\n  <body>\n    <div id=\"app\"></div>\n  </body>\n</html>\n"
  },
  {
    "path": "examples/webpack-dev-server/src/App.jsx",
    "content": "import { lazy, Suspense } from 'react';\nimport { ArrowFunction } from './ArrowFunction';\nimport ClassDefault from './ClassDefault';\nimport { ClassNamed } from './ClassNamed';\nimport FunctionDefault from './FunctionDefault';\nimport { FunctionNamed } from './FunctionNamed';\n\nconst LazyComponent = lazy(() => import('./LazyComponent'));\n\nfunction App() {\n  return (\n    <div>\n      <ClassDefault />\n      <ClassNamed />\n      <FunctionDefault />\n      <FunctionNamed />\n      <ArrowFunction />\n      <Suspense fallback={<h1>Loading</h1>}>\n        <LazyComponent />\n      </Suspense>\n    </div>\n  );\n}\n\nexport default App;\n"
  },
  {
    "path": "examples/webpack-dev-server/src/ArrowFunction.jsx",
    "content": "export const ArrowFunction = () => <h1>Arrow Function</h1>;\n"
  },
  {
    "path": "examples/webpack-dev-server/src/ClassDefault.jsx",
    "content": "import { Component } from 'react';\n\nclass ClassDefault extends Component {\n  render() {\n    return <h1>Default Export Class</h1>;\n  }\n}\n\nexport default ClassDefault;\n"
  },
  {
    "path": "examples/webpack-dev-server/src/ClassNamed.jsx",
    "content": "import { Component } from 'react';\n\nexport class ClassNamed extends Component {\n  render() {\n    return <h1>Named Export Class</h1>;\n  }\n}\n"
  },
  {
    "path": "examples/webpack-dev-server/src/FunctionDefault.jsx",
    "content": "function FunctionDefault() {\n  return <h1>Default Export Function</h1>;\n}\n\nexport default FunctionDefault;\n"
  },
  {
    "path": "examples/webpack-dev-server/src/FunctionNamed.jsx",
    "content": "export function FunctionNamed() {\n  return <h1>Named Export Function</h1>;\n}\n"
  },
  {
    "path": "examples/webpack-dev-server/src/LazyComponent.jsx",
    "content": "function LazyComponent() {\n  return <h1>Lazy Component</h1>;\n}\n\nexport default LazyComponent;\n"
  },
  {
    "path": "examples/webpack-dev-server/src/index.js",
    "content": "import { createRoot } from 'react-dom/client';\nimport App from './App';\n\nconst container = document.getElementById('app');\nconst root = createRoot(container);\nroot.render(<App />);\n"
  },
  {
    "path": "examples/webpack-dev-server/webpack.config.js",
    "content": "const path = require('path');\nconst ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');\nconst HtmlWebpackPlugin = require('html-webpack-plugin');\n\nconst isDevelopment = process.env.NODE_ENV !== 'production';\n\nmodule.exports = {\n  mode: isDevelopment ? 'development' : 'production',\n  devServer: {\n    client: { overlay: false },\n  },\n  entry: {\n    main: './src/index.js',\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.jsx?$/,\n        include: path.join(__dirname, 'src'),\n        use: 'babel-loader',\n      },\n    ],\n  },\n  plugins: [\n    isDevelopment && new ReactRefreshPlugin(),\n    new HtmlWebpackPlugin({\n      filename: './index.html',\n      template: './public/index.html',\n    }),\n  ].filter(Boolean),\n  resolve: {\n    extensions: ['.js', '.jsx'],\n  },\n};\n"
  },
  {
    "path": "examples/webpack-hot-middleware/babel.config.js",
    "content": "module.exports = (api) => {\n  // This caches the Babel config\n  api.cache.using(() => process.env.NODE_ENV);\n  return {\n    presets: [\n      '@babel/preset-env',\n      // Enable development transform of React with new automatic runtime\n      ['@babel/preset-react', { development: !api.env('production'), runtime: 'automatic' }],\n    ],\n    // Applies the react-refresh Babel plugin on non-production modes only\n    ...(!api.env('production') && { plugins: ['react-refresh/babel'] }),\n  };\n};\n"
  },
  {
    "path": "examples/webpack-hot-middleware/package.json",
    "content": "{\n  \"name\": \"using-webpack-hot-middleware\",\n  \"version\": \"0.1.0\",\n  \"private\": true,\n  \"dependencies\": {\n    \"react\": \"^19.0.0\",\n    \"react-dom\": \"^19.0.0\"\n  },\n  \"devDependencies\": {\n    \"@babel/core\": \"^7.26.10\",\n    \"@babel/preset-env\": \"^7.26.9\",\n    \"@babel/preset-react\": \"^7.26.3\",\n    \"@pmmmwh/react-refresh-webpack-plugin\": \"^0.6.0\",\n    \"babel-loader\": \"^10.0.0\",\n    \"cross-env\": \"^7.0.3\",\n    \"express\": \"^5.2.0\",\n    \"html-webpack-plugin\": \"^5.6.3\",\n    \"react-refresh\": \"^0.17.0\",\n    \"webpack\": \"^5.98.0\",\n    \"webpack-dev-middleware\": \"^7.4.2\",\n    \"webpack-hot-middleware\": \"^2.26.1\"\n  },\n  \"scripts\": {\n    \"start\": \"node ./server.js\",\n    \"build\": \"cross-env NODE_ENV=production webpack\"\n  }\n}\n"
  },
  {
    "path": "examples/webpack-hot-middleware/public/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"UTF-8\" />\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n    <title>WHM React App</title>\n  </head>\n  <body>\n    <div id=\"app\"></div>\n  </body>\n</html>\n"
  },
  {
    "path": "examples/webpack-hot-middleware/server.js",
    "content": "const path = require('path');\nconst express = require('express');\nconst webpack = require('webpack');\nconst config = require('./webpack.config.js');\n\nconst app = express();\nconst compiler = webpack(config);\n\napp.use(\n  require('webpack-dev-middleware')(compiler, {\n    publicPath: config.output.publicPath,\n  })\n);\n\napp.use(\n  require(`webpack-hot-middleware`)(compiler, {\n    log: false,\n    path: `/__webpack_hmr`,\n    heartbeat: 10 * 1000,\n  })\n);\n\napp.get('*', (req, res, next) => {\n  const filename = path.join(compiler.outputPath, 'index.html');\n  compiler.outputFileSystem.readFile(filename, (err, result) => {\n    if (err) {\n      return next(err);\n    }\n    res.set('content-type', 'text/html');\n    res.send(result);\n    res.end();\n  });\n});\n\napp.listen(8080, () => console.log('App is listening on port 8080!'));\n"
  },
  {
    "path": "examples/webpack-hot-middleware/src/App.jsx",
    "content": "import { lazy, Suspense } from 'react';\nimport { ArrowFunction } from './ArrowFunction';\nimport ClassDefault from './ClassDefault';\nimport { ClassNamed } from './ClassNamed';\nimport FunctionDefault from './FunctionDefault';\nimport { FunctionNamed } from './FunctionNamed';\n\nconst LazyComponent = lazy(() => import('./LazyComponent'));\n\nfunction App() {\n  return (\n    <div>\n      <ClassDefault />\n      <ClassNamed />\n      <FunctionDefault />\n      <FunctionNamed />\n      <ArrowFunction />\n      <Suspense fallback={<h1>Loading</h1>}>\n        <LazyComponent />\n      </Suspense>\n    </div>\n  );\n}\n\nexport default App;\n"
  },
  {
    "path": "examples/webpack-hot-middleware/src/ArrowFunction.jsx",
    "content": "export const ArrowFunction = () => <h1>Arrow Function</h1>;\n"
  },
  {
    "path": "examples/webpack-hot-middleware/src/ClassDefault.jsx",
    "content": "import { Component } from 'react';\n\nclass ClassDefault extends Component {\n  render() {\n    return <h1>Default Export Class</h1>;\n  }\n}\n\nexport default ClassDefault;\n"
  },
  {
    "path": "examples/webpack-hot-middleware/src/ClassNamed.jsx",
    "content": "import { Component } from 'react';\n\nexport class ClassNamed extends Component {\n  render() {\n    return <h1>Named Export Class</h1>;\n  }\n}\n"
  },
  {
    "path": "examples/webpack-hot-middleware/src/FunctionDefault.jsx",
    "content": "function FunctionDefault() {\n  return <h1>Default Export Function</h1>;\n}\n\nexport default FunctionDefault;\n"
  },
  {
    "path": "examples/webpack-hot-middleware/src/FunctionNamed.jsx",
    "content": "export function FunctionNamed() {\n  return <h1>Named Export Function</h1>;\n}\n"
  },
  {
    "path": "examples/webpack-hot-middleware/src/LazyComponent.jsx",
    "content": "function LazyComponent() {\n  return <h1>Lazy Component</h1>;\n}\n\nexport default LazyComponent;\n"
  },
  {
    "path": "examples/webpack-hot-middleware/src/index.js",
    "content": "import { createRoot } from 'react-dom/client';\nimport App from './App';\n\nconst container = document.getElementById('app');\nconst root = createRoot(container);\nroot.render(<App />);\n"
  },
  {
    "path": "examples/webpack-hot-middleware/webpack.config.js",
    "content": "const path = require('path');\nconst ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');\nconst HtmlWebpackPlugin = require('html-webpack-plugin');\nconst webpack = require('webpack');\n\nconst isDevelopment = process.env.NODE_ENV !== 'production';\n\nmodule.exports = {\n  mode: isDevelopment ? 'development' : 'production',\n  entry: {\n    main: ['webpack-hot-middleware/client', './src/index.js'],\n  },\n  output: {\n    filename: 'bundle.js',\n    path: path.resolve(__dirname, 'dist'),\n    publicPath: '/',\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.jsx?$/,\n        include: path.join(__dirname, 'src'),\n        use: 'babel-loader',\n      },\n    ],\n  },\n  plugins: [\n    isDevelopment && new webpack.HotModuleReplacementPlugin(),\n    isDevelopment &&\n      new ReactRefreshPlugin({\n        overlay: {\n          sockIntegration: 'whm',\n        },\n      }),\n    new HtmlWebpackPlugin({\n      filename: './index.html',\n      template: './public/index.html',\n    }),\n  ].filter(Boolean),\n  resolve: {\n    extensions: ['.js', '.jsx'],\n  },\n};\n"
  },
  {
    "path": "examples/webpack-plugin-serve/babel.config.js",
    "content": "module.exports = (api) => {\n  // This caches the Babel config\n  api.cache.using(() => process.env.NODE_ENV);\n  return {\n    presets: [\n      '@babel/preset-env',\n      // Enable development transform of React with new automatic runtime\n      ['@babel/preset-react', { development: !api.env('production'), runtime: 'automatic' }],\n    ],\n    // Applies the react-refresh Babel plugin on non-production modes only\n    ...(!api.env('production') && { plugins: ['react-refresh/babel'] }),\n  };\n};\n"
  },
  {
    "path": "examples/webpack-plugin-serve/package.json",
    "content": "{\n  \"name\": \"using-webpack-plugin-serve\",\n  \"version\": \"0.1.0\",\n  \"private\": true,\n  \"dependencies\": {\n    \"react\": \"^19.0.0\",\n    \"react-dom\": \"^19.0.0\"\n  },\n  \"devDependencies\": {\n    \"@babel/core\": \"^7.26.10\",\n    \"@babel/preset-env\": \"^7.26.9\",\n    \"@babel/preset-react\": \"^7.26.3\",\n    \"@pmmmwh/react-refresh-webpack-plugin\": \"^0.6.0\",\n    \"babel-loader\": \"^10.0.0\",\n    \"cross-env\": \"^7.0.3\",\n    \"html-webpack-plugin\": \"^5.6.3\",\n    \"react-refresh\": \"^0.17.0\",\n    \"webpack\": \"^5.104.1\",\n    \"webpack-cli\": \"^6.0.1\",\n    \"webpack-plugin-serve\": \"^1.6.0\"\n  },\n  \"scripts\": {\n    \"start\": \"webpack --watch\",\n    \"build\": \"cross-env NODE_ENV=production webpack\"\n  }\n}\n"
  },
  {
    "path": "examples/webpack-plugin-serve/public/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"UTF-8\" />\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n    <title>WPS React App</title>\n  </head>\n  <body>\n    <div id=\"app\"></div>\n  </body>\n</html>\n"
  },
  {
    "path": "examples/webpack-plugin-serve/src/App.jsx",
    "content": "import { lazy, Suspense } from 'react';\nimport { ArrowFunction } from './ArrowFunction';\nimport ClassDefault from './ClassDefault';\nimport { ClassNamed } from './ClassNamed';\nimport FunctionDefault from './FunctionDefault';\nimport { FunctionNamed } from './FunctionNamed';\n\nconst LazyComponent = lazy(() => import('./LazyComponent'));\n\nfunction App() {\n  return (\n    <div>\n      <ClassDefault />\n      <ClassNamed />\n      <FunctionDefault />\n      <FunctionNamed />\n      <ArrowFunction />\n      <Suspense fallback={<h1>Loading</h1>}>\n        <LazyComponent />\n      </Suspense>\n    </div>\n  );\n}\n\nexport default App;\n"
  },
  {
    "path": "examples/webpack-plugin-serve/src/ArrowFunction.jsx",
    "content": "export const ArrowFunction = () => <h1>Arrow Function</h1>;\n"
  },
  {
    "path": "examples/webpack-plugin-serve/src/ClassDefault.jsx",
    "content": "import { Component } from 'react';\n\nclass ClassDefault extends Component {\n  render() {\n    return <h1>Default Export Class</h1>;\n  }\n}\n\nexport default ClassDefault;\n"
  },
  {
    "path": "examples/webpack-plugin-serve/src/ClassNamed.jsx",
    "content": "import { Component } from 'react';\n\nexport class ClassNamed extends Component {\n  render() {\n    return <h1>Named Export Class</h1>;\n  }\n}\n"
  },
  {
    "path": "examples/webpack-plugin-serve/src/FunctionDefault.jsx",
    "content": "function FunctionDefault() {\n  return <h1>Default Export Function</h1>;\n}\n\nexport default FunctionDefault;\n"
  },
  {
    "path": "examples/webpack-plugin-serve/src/FunctionNamed.jsx",
    "content": "export function FunctionNamed() {\n  return <h1>Named Export Function</h1>;\n}\n"
  },
  {
    "path": "examples/webpack-plugin-serve/src/LazyComponent.jsx",
    "content": "function LazyComponent() {\n  return <h1>Lazy Component</h1>;\n}\n\nexport default LazyComponent;\n"
  },
  {
    "path": "examples/webpack-plugin-serve/src/index.js",
    "content": "import { createRoot } from 'react-dom/client';\nimport App from './App';\n\nconst container = document.getElementById('app');\nconst root = createRoot(container);\nroot.render(<App />);\n"
  },
  {
    "path": "examples/webpack-plugin-serve/webpack.config.js",
    "content": "const path = require('path');\nconst ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');\nconst HtmlWebpackPlugin = require('html-webpack-plugin');\nconst { WebpackPluginServe: ServePlugin } = require('webpack-plugin-serve');\n\nconst isDevelopment = process.env.NODE_ENV !== 'production';\nconst outputPath = path.resolve(__dirname, 'dist');\n\nmodule.exports = {\n  mode: isDevelopment ? 'development' : 'production',\n  entry: {\n    main: ['webpack-plugin-serve/client', './src/index.js'],\n  },\n  output: {\n    filename: 'bundle.js',\n    path: outputPath,\n    publicPath: '/',\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.jsx?$/,\n        include: path.join(__dirname, 'src'),\n        use: 'babel-loader',\n      },\n    ],\n  },\n  plugins: [\n    isDevelopment &&\n      new ServePlugin({\n        port: 8080,\n        static: outputPath,\n        status: false,\n      }),\n    isDevelopment &&\n      new ReactRefreshPlugin({\n        overlay: {\n          sockIntegration: 'wps',\n        },\n      }),\n    new HtmlWebpackPlugin({\n      filename: './index.html',\n      template: './public/index.html',\n    }),\n  ].filter(Boolean),\n  resolve: {\n    extensions: ['.js', '.jsx'],\n  },\n};\n"
  },
  {
    "path": "jest.config.js",
    "content": "module.exports = {\n  globalSetup: '<rootDir>/jest-global-setup.js',\n  globalTeardown: '<rootDir>/jest-global-teardown.js',\n  prettierPath: null,\n  resolver: '<rootDir>/jest-resolver.js',\n  rootDir: 'test',\n  setupFilesAfterEnv: ['<rootDir>/jest-test-setup.js'],\n  testEnvironment: '<rootDir>/jest-environment.js',\n  testMatch: ['<rootDir>/**/*.test.js'],\n};\n"
  },
  {
    "path": "lib/globals.js",
    "content": "/**\n * Gets current bundle's global scope identifier for React Refresh.\n * @param {Record<string, string>} runtimeGlobals The Webpack runtime globals.\n * @returns {string} The React Refresh global scope within the Webpack bundle.\n */\nmodule.exports.getRefreshGlobalScope = (runtimeGlobals) => {\n  return `${runtimeGlobals.require || '__webpack_require__'}.$Refresh$`;\n};\n"
  },
  {
    "path": "lib/index.js",
    "content": "const { validate: validateOptions } = require('schema-utils');\nconst { getRefreshGlobalScope } = require('./globals');\nconst {\n  getAdditionalEntries,\n  getIntegrationEntry,\n  getSocketIntegration,\n  injectRefreshLoader,\n  makeRefreshRuntimeModule,\n  normalizeOptions,\n} = require('./utils');\nconst schema = require('./options.json');\n\nclass ReactRefreshPlugin {\n  /**\n   * @param {import('./types').ReactRefreshPluginOptions} [options] Options for react-refresh-plugin.\n   */\n  constructor(options = {}) {\n    validateOptions(schema, options, {\n      name: 'React Refresh Plugin',\n      baseDataPath: 'options',\n    });\n\n    /**\n     * @readonly\n     * @type {import('./types').NormalizedPluginOptions}\n     */\n    this.options = normalizeOptions(options);\n  }\n\n  /**\n   * Applies the plugin.\n   * @param {import('webpack').Compiler} compiler A webpack compiler object.\n   * @returns {void}\n   */\n  apply(compiler) {\n    // Skip processing in non-development mode, but allow manual force-enabling\n    if (\n      // Webpack do not set process.env.NODE_ENV, so we need to check for mode.\n      // Ref: https://github.com/webpack/webpack/issues/7074\n      (compiler.options.mode !== 'development' ||\n        // We also check for production process.env.NODE_ENV,\n        // in case it was set and mode is non-development (e.g. 'none')\n        (process.env.NODE_ENV && process.env.NODE_ENV === 'production')) &&\n      !this.options.forceEnable\n    ) {\n      return;\n    }\n\n    const logger = compiler.getInfrastructureLogger(this.constructor.name);\n\n    // Get Webpack imports from compiler instance (if available) -\n    // this allow mono-repos to use different versions of Webpack without conflicts.\n    const webpack = compiler.webpack || require('webpack');\n    const {\n      DefinePlugin,\n      EntryDependency,\n      EntryPlugin,\n      ModuleFilenameHelpers,\n      NormalModule,\n      ProvidePlugin,\n      RuntimeGlobals,\n      Template,\n    } = webpack;\n\n    // Inject react-refresh context to all Webpack entry points.\n    const { overlayEntries, prependEntries } = getAdditionalEntries(this.options);\n    // Prepended entries does not care about injection order,\n    // so we can utilise EntryPlugin for simpler logic.\n    for (const entry of prependEntries) {\n      new EntryPlugin(compiler.context, entry, { name: undefined }).apply(compiler);\n    }\n\n    const integrationEntry = getIntegrationEntry(this.options.overlay.sockIntegration);\n    const socketEntryData = [];\n    compiler.hooks.make.tap(\n      { name: this.constructor.name, stage: Number.POSITIVE_INFINITY },\n      (compilation) => {\n        // Exhaustively search all entries for `integrationEntry`.\n        // If found, mark those entries and the index of `integrationEntry`.\n        for (const [name, entryData] of compilation.entries.entries()) {\n          const index = entryData.dependencies.findIndex(\n            (dep) => dep.request && dep.request.includes(integrationEntry)\n          );\n          if (index !== -1) {\n            socketEntryData.push({ name, index });\n          }\n        }\n      }\n    );\n\n    // Overlay entries need to be injected AFTER integration's entry,\n    // so we will loop through everything in `finishMake` instead of `make`.\n    // This ensures we can traverse all entry points and inject stuff with the correct order.\n    for (const [idx, entry] of overlayEntries.entries()) {\n      compiler.hooks.finishMake.tapPromise(\n        {\n          name: this.constructor.name,\n          stage: Number.MIN_SAFE_INTEGER + (overlayEntries.length - idx - 1),\n        },\n        (compilation) => {\n          // Only hook into the current compiler\n          if (compilation.compiler !== compiler) {\n            return Promise.resolve();\n          }\n\n          const injectData = socketEntryData.length ? socketEntryData : [{ name: undefined }];\n          return Promise.all(\n            injectData.map(({ name, index }) => {\n              return new Promise((resolve, reject) => {\n                const options = { name };\n                const dep = EntryPlugin.createDependency(entry, options);\n                compilation.addEntry(compiler.context, dep, options, (err) => {\n                  if (err) return reject(err);\n\n                  // If the entry is not a global one,\n                  // and we have registered the index for integration entry,\n                  // we will reorder all entry dependencies to our desired order.\n                  // That is, to have additional entries DIRECTLY behind integration entry.\n                  if (name && typeof index !== 'undefined') {\n                    const entryData = compilation.entries.get(name);\n                    entryData.dependencies.splice(\n                      index + 1,\n                      0,\n                      entryData.dependencies.splice(entryData.dependencies.length - 1, 1)[0]\n                    );\n                  }\n\n                  resolve();\n                });\n              });\n            })\n          );\n        }\n      );\n    }\n\n    // Inject necessary modules and variables to bundle's global scope\n    const refreshGlobal = getRefreshGlobalScope(RuntimeGlobals || {});\n    /** @type {Record<string, string | boolean>}*/\n    const definedModules = {\n      // Mapping of react-refresh globals to Webpack runtime globals\n      $RefreshReg$: `${refreshGlobal}.register`,\n      $RefreshSig$: `${refreshGlobal}.signature`,\n      'typeof $RefreshReg$': 'function',\n      'typeof $RefreshSig$': 'function',\n\n      // Library mode\n      __react_refresh_library__: JSON.stringify(\n        Template.toIdentifier(\n          this.options.library ||\n            compiler.options.output.uniqueName ||\n            compiler.options.output.library\n        )\n      ),\n    };\n    /** @type {Record<string, string>} */\n    const providedModules = {\n      __react_refresh_utils__: require.resolve('./runtime/RefreshUtils'),\n    };\n\n    if (this.options.overlay === false) {\n      // Stub errorOverlay module so their calls can be erased\n      definedModules.__react_refresh_error_overlay__ = false;\n      definedModules.__react_refresh_socket__ = false;\n    } else {\n      if (this.options.overlay.module) {\n        providedModules.__react_refresh_error_overlay__ = require.resolve(\n          this.options.overlay.module\n        );\n      }\n      if (this.options.overlay.sockIntegration) {\n        providedModules.__react_refresh_socket__ = getSocketIntegration(\n          this.options.overlay.sockIntegration\n        );\n      }\n    }\n\n    new DefinePlugin(definedModules).apply(compiler);\n    new ProvidePlugin(providedModules).apply(compiler);\n\n    const match = ModuleFilenameHelpers.matchObject.bind(undefined, this.options);\n    let loggedHotWarning = false;\n    compiler.hooks.compilation.tap(\n      this.constructor.name,\n      (compilation, { normalModuleFactory }) => {\n        // Only hook into the current compiler\n        if (compilation.compiler !== compiler) {\n          return;\n        }\n\n        // Set factory for EntryDependency which is used to initialise the module\n        compilation.dependencyFactories.set(EntryDependency, normalModuleFactory);\n\n        const ReactRefreshRuntimeModule = makeRefreshRuntimeModule(webpack);\n        compilation.hooks.additionalTreeRuntimeRequirements.tap(\n          this.constructor.name,\n          // Setup react-refresh globals with a Webpack runtime module\n          (chunk, runtimeRequirements) => {\n            runtimeRequirements.add(RuntimeGlobals.interceptModuleExecution);\n            runtimeRequirements.add(RuntimeGlobals.moduleCache);\n            runtimeRequirements.add(refreshGlobal);\n            compilation.addRuntimeModule(chunk, new ReactRefreshRuntimeModule());\n          }\n        );\n\n        normalModuleFactory.hooks.afterResolve.tap(\n          this.constructor.name,\n          // Add react-refresh loader to process files that matches specified criteria\n          (resolveData) => {\n            injectRefreshLoader(resolveData.createData, {\n              match,\n              options: {\n                const: compilation.runtimeTemplate.supportsConst(),\n                esModule: this.options.esModule,\n              },\n            });\n          }\n        );\n\n        NormalModule.getCompilationHooks(compilation).loader.tap(\n          // `Infinity` ensures this check will run only after all other taps\n          { name: this.constructor.name, stage: Infinity },\n          // Check for existence of the HMR runtime -\n          // it is the foundation to this plugin working correctly\n          (context) => {\n            if (!context.hot && !loggedHotWarning) {\n              logger.warn(\n                [\n                  'Hot Module Replacement (HMR) is not enabled!',\n                  'React Refresh requires HMR to function properly.',\n                ].join(' ')\n              );\n              loggedHotWarning = true;\n            }\n          }\n        );\n      }\n    );\n  }\n}\n\nmodule.exports.ReactRefreshPlugin = ReactRefreshPlugin;\nmodule.exports = ReactRefreshPlugin;\n"
  },
  {
    "path": "lib/options.json",
    "content": "{\n  \"additionalProperties\": false,\n  \"type\": \"object\",\n  \"definitions\": {\n    \"Path\": { \"type\": \"string\" },\n    \"MatchCondition\": {\n      \"anyOf\": [{ \"instanceof\": \"RegExp\" }, { \"$ref\": \"#/definitions/Path\" }]\n    },\n    \"MatchConditions\": {\n      \"type\": \"array\",\n      \"items\": { \"$ref\": \"#/definitions/MatchCondition\" },\n      \"minItems\": 1\n    },\n    \"ESModuleOptions\": {\n      \"additionalProperties\": false,\n      \"type\": \"object\",\n      \"properties\": {\n        \"exclude\": {\n          \"anyOf\": [\n            { \"$ref\": \"#/definitions/MatchCondition\" },\n            { \"$ref\": \"#/definitions/MatchConditions\" }\n          ]\n        },\n        \"include\": {\n          \"anyOf\": [\n            { \"$ref\": \"#/definitions/MatchCondition\" },\n            { \"$ref\": \"#/definitions/MatchConditions\" }\n          ]\n        }\n      }\n    },\n    \"OverlayOptions\": {\n      \"additionalProperties\": false,\n      \"type\": \"object\",\n      \"properties\": {\n        \"entry\": {\n          \"anyOf\": [{ \"const\": false }, { \"$ref\": \"#/definitions/Path\" }]\n        },\n        \"module\": {\n          \"anyOf\": [{ \"const\": false }, { \"$ref\": \"#/definitions/Path\" }]\n        },\n        \"sockIntegration\": {\n          \"anyOf\": [\n            { \"const\": false },\n            { \"enum\": [\"wds\", \"whm\", \"wps\"] },\n            { \"$ref\": \"#/definitions/Path\" }\n          ]\n        }\n      }\n    }\n  },\n  \"properties\": {\n    \"esModule\": {\n      \"anyOf\": [{ \"type\": \"boolean\" }, { \"$ref\": \"#/definitions/ESModuleOptions\" }]\n    },\n    \"exclude\": {\n      \"anyOf\": [\n        { \"$ref\": \"#/definitions/MatchCondition\" },\n        { \"$ref\": \"#/definitions/MatchConditions\" }\n      ]\n    },\n    \"forceEnable\": { \"type\": \"boolean\" },\n    \"include\": {\n      \"anyOf\": [\n        { \"$ref\": \"#/definitions/MatchCondition\" },\n        { \"$ref\": \"#/definitions/MatchConditions\" }\n      ]\n    },\n    \"library\": { \"type\": \"string\" },\n    \"overlay\": {\n      \"anyOf\": [{ \"type\": \"boolean\" }, { \"$ref\": \"#/definitions/OverlayOptions\" }]\n    }\n  }\n}\n"
  },
  {
    "path": "lib/runtime/RefreshUtils.js",
    "content": "/* global __webpack_require__ */\nvar Refresh = require('react-refresh/runtime');\n\n/**\n * Extracts exports from a webpack module object.\n * @param {string} moduleId A Webpack module ID.\n * @returns {*} An exports object from the module.\n */\nfunction getModuleExports(moduleId) {\n  if (typeof moduleId === 'undefined') {\n    // `moduleId` is unavailable, which indicates that this module is not in the cache,\n    // which means we won't be able to capture any exports,\n    // and thus they cannot be refreshed safely.\n    // These are likely runtime or dynamically generated modules.\n    return {};\n  }\n\n  var maybeModule = __webpack_require__.c[moduleId];\n  if (typeof maybeModule === 'undefined') {\n    // `moduleId` is available but the module in cache is unavailable,\n    // which indicates the module is somehow corrupted (e.g. broken Webpacak `module` globals).\n    // We will warn the user (as this is likely a mistake) and assume they cannot be refreshed.\n    console.warn('[React Refresh] Failed to get exports for module: ' + moduleId + '.');\n    return {};\n  }\n\n  var exportsOrPromise = maybeModule.exports;\n  if (typeof Promise !== 'undefined' && exportsOrPromise instanceof Promise) {\n    return exportsOrPromise.then(function (exports) {\n      return exports;\n    });\n  }\n  return exportsOrPromise;\n}\n\n/**\n * Calculates the signature of a React refresh boundary.\n * If this signature changes, it's unsafe to accept the boundary.\n *\n * This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/907d6af22ac6ebe58572be418e9253a90665ecbd/packages/metro/src/lib/polyfills/require.js#L795-L816).\n * @param {*} moduleExports A Webpack module exports object.\n * @returns {string[]} A React refresh boundary signature array.\n */\nfunction getReactRefreshBoundarySignature(moduleExports) {\n  var signature = [];\n  signature.push(Refresh.getFamilyByType(moduleExports));\n\n  if (moduleExports == null || typeof moduleExports !== 'object') {\n    // Exit if we can't iterate over exports.\n    return signature;\n  }\n\n  for (var key in moduleExports) {\n    if (key === '__esModule') {\n      continue;\n    }\n\n    signature.push(key);\n    signature.push(Refresh.getFamilyByType(moduleExports[key]));\n  }\n\n  return signature;\n}\n\n/**\n * Creates a data object to be retained across refreshes.\n * This object should not transtively reference previous exports,\n * which can form infinite chain of objects across refreshes, which can pressure RAM.\n *\n * @param {*} moduleExports A Webpack module exports object.\n * @returns {*} A React refresh boundary signature array.\n */\nfunction getWebpackHotData(moduleExports) {\n  return {\n    signature: getReactRefreshBoundarySignature(moduleExports),\n    isReactRefreshBoundary: isReactRefreshBoundary(moduleExports),\n  };\n}\n\n/**\n * Creates a helper that performs a delayed React refresh.\n * @returns {function(function(): void): void} A debounced React refresh function.\n */\nfunction createDebounceUpdate() {\n  /**\n   * A cached setTimeout handler.\n   * @type {number | undefined}\n   */\n  var refreshTimeout;\n\n  /**\n   * Performs react refresh on a delay and clears the error overlay.\n   * @param {function(): void} callback\n   * @returns {void}\n   */\n  function enqueueUpdate(callback) {\n    if (typeof refreshTimeout === 'undefined') {\n      refreshTimeout = setTimeout(function () {\n        refreshTimeout = undefined;\n        Refresh.performReactRefresh();\n        callback();\n      }, 30);\n    }\n  }\n\n  return enqueueUpdate;\n}\n\n/**\n * Checks if all exports are likely a React component.\n *\n * This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/febdba2383113c88296c61e28e4ef6a7f4939fda/packages/metro/src/lib/polyfills/require.js#L748-L774).\n * @param {*} moduleExports A Webpack module exports object.\n * @returns {boolean} Whether the exports are React component like.\n */\nfunction isReactRefreshBoundary(moduleExports) {\n  if (Refresh.isLikelyComponentType(moduleExports)) {\n    return true;\n  }\n  if (moduleExports === undefined || moduleExports === null || typeof moduleExports !== 'object') {\n    // Exit if we can't iterate over exports.\n    return false;\n  }\n\n  var hasExports = false;\n  var areAllExportsComponents = true;\n  for (var key in moduleExports) {\n    hasExports = true;\n\n    // This is the ES Module indicator flag\n    if (key === '__esModule') {\n      continue;\n    }\n\n    // We can (and have to) safely execute getters here,\n    // as Webpack manually assigns harmony exports to getters,\n    // without any side-effects attached.\n    // Ref: https://github.com/webpack/webpack/blob/b93048643fe74de2a6931755911da1212df55897/lib/MainTemplate.js#L281\n    var exportValue = moduleExports[key];\n    if (!Refresh.isLikelyComponentType(exportValue)) {\n      areAllExportsComponents = false;\n    }\n  }\n\n  return hasExports && areAllExportsComponents;\n}\n\n/**\n * Checks if exports are likely a React component and registers them.\n *\n * This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/febdba2383113c88296c61e28e4ef6a7f4939fda/packages/metro/src/lib/polyfills/require.js#L818-L835).\n * @param {*} moduleExports A Webpack module exports object.\n * @param {string} moduleId A Webpack module ID.\n * @returns {void}\n */\nfunction registerExportsForReactRefresh(moduleExports, moduleId) {\n  if (Refresh.isLikelyComponentType(moduleExports)) {\n    // Register module.exports if it is likely a component\n    Refresh.register(moduleExports, moduleId + ' %exports%');\n  }\n\n  if (moduleExports === undefined || moduleExports === null || typeof moduleExports !== 'object') {\n    // Exit if we can't iterate over the exports.\n    return;\n  }\n\n  for (var key in moduleExports) {\n    // Skip registering the ES Module indicator\n    if (key === '__esModule') {\n      continue;\n    }\n\n    var exportValue = moduleExports[key];\n    if (Refresh.isLikelyComponentType(exportValue)) {\n      var typeID = moduleId + ' %exports% ' + key;\n      Refresh.register(exportValue, typeID);\n    }\n  }\n}\n\n/**\n * Compares previous and next module objects to check for mutated boundaries.\n *\n * This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/907d6af22ac6ebe58572be418e9253a90665ecbd/packages/metro/src/lib/polyfills/require.js#L776-L792).\n * @param {*} prevSignature The signature of the current Webpack module exports object.\n * @param {*} nextSignature The signature of the next Webpack module exports object.\n * @returns {boolean} Whether the React refresh boundary should be invalidated.\n */\nfunction shouldInvalidateReactRefreshBoundary(prevSignature, nextSignature) {\n  if (prevSignature.length !== nextSignature.length) {\n    return true;\n  }\n\n  for (var i = 0; i < nextSignature.length; i += 1) {\n    if (prevSignature[i] !== nextSignature[i]) {\n      return true;\n    }\n  }\n\n  return false;\n}\n\nvar enqueueUpdate = createDebounceUpdate();\nfunction executeRuntime(moduleExports, moduleId, webpackHot, refreshOverlay, isTest) {\n  registerExportsForReactRefresh(moduleExports, moduleId);\n\n  if (webpackHot) {\n    var isHotUpdate = !!webpackHot.data;\n    var prevData;\n    if (isHotUpdate) {\n      prevData = webpackHot.data.prevData;\n    }\n\n    if (isReactRefreshBoundary(moduleExports)) {\n      webpackHot.dispose(\n        /**\n         * A callback to performs a full refresh if React has unrecoverable errors,\n         * and also caches the to-be-disposed module.\n         * @param {*} data A hot module data object from Webpack HMR.\n         * @returns {void}\n         */\n        function hotDisposeCallback(data) {\n          // We have to mutate the data object to get data registered and cached\n          data.prevData = getWebpackHotData(moduleExports);\n        }\n      );\n      webpackHot.accept(\n        /**\n         * An error handler to allow self-recovering behaviours.\n         * @param {Error} error An error occurred during evaluation of a module.\n         * @returns {void}\n         */\n        function hotErrorHandler(error) {\n          if (typeof refreshOverlay !== 'undefined' && refreshOverlay) {\n            refreshOverlay.handleRuntimeError(error);\n          }\n\n          if (typeof isTest !== 'undefined' && isTest) {\n            if (window.onHotAcceptError) {\n              window.onHotAcceptError(error.message);\n            }\n          }\n\n          __webpack_require__.c[moduleId].hot.accept(hotErrorHandler);\n        }\n      );\n\n      if (isHotUpdate) {\n        if (\n          prevData &&\n          prevData.isReactRefreshBoundary &&\n          shouldInvalidateReactRefreshBoundary(\n            prevData.signature,\n            getReactRefreshBoundarySignature(moduleExports)\n          )\n        ) {\n          webpackHot.invalidate();\n        } else {\n          enqueueUpdate(\n            /**\n             * A function to dismiss the error overlay after performing React refresh.\n             * @returns {void}\n             */\n            function updateCallback() {\n              if (typeof refreshOverlay !== 'undefined' && refreshOverlay) {\n                refreshOverlay.clearRuntimeErrors();\n              }\n            }\n          );\n        }\n      }\n    } else {\n      if (isHotUpdate && typeof prevData !== 'undefined') {\n        webpackHot.invalidate();\n      }\n    }\n  }\n}\n\nmodule.exports = Object.freeze({\n  enqueueUpdate: enqueueUpdate,\n  executeRuntime: executeRuntime,\n  getModuleExports: getModuleExports,\n  isReactRefreshBoundary: isReactRefreshBoundary,\n  registerExportsForReactRefresh: registerExportsForReactRefresh,\n});\n"
  },
  {
    "path": "lib/types.js",
    "content": "/**\n * @typedef {Object} ErrorOverlayOptions\n * @property {string | false} [entry] Path to a JS file that sets up the error overlay integration.\n * @property {string | false} [module] The error overlay module to use.\n * @property {import('type-fest').LiteralUnion<'wds' | 'whm' | 'wps' | false, string>} [sockIntegration] Path to a JS file that sets up the Webpack socket integration.\n */\n\n/**\n * @typedef {import('type-fest').SetRequired<ErrorOverlayOptions, 'entry' | 'module' | 'sockIntegration'>} NormalizedErrorOverlayOptions\n */\n\n/**\n * @typedef {Object} ReactRefreshPluginOptions\n * @property {boolean | import('../loader/types').ESModuleOptions} [esModule] Enables strict ES Modules compatible runtime.\n * @property {string | RegExp | Array<string | RegExp>} [exclude] Files to explicitly exclude from processing.\n * @property {boolean} [forceEnable] Enables the plugin forcefully.\n * @property {string | RegExp | Array<string | RegExp>} [include] Files to explicitly include for processing.\n * @property {string} [library] Name of the library bundle.\n * @property {boolean | ErrorOverlayOptions} [overlay] Modifies how the error overlay integration works in the plugin.\n */\n\n/**\n * @typedef {Object} OverlayOverrides\n * @property {false | NormalizedErrorOverlayOptions} overlay Modifies how the error overlay integration works in the plugin.\n */\n\n/**\n * @typedef {import('type-fest').SetRequired<import('type-fest').Except<ReactRefreshPluginOptions, 'overlay'>, 'exclude' | 'include'> & OverlayOverrides} NormalizedPluginOptions\n */\n\nmodule.exports = {};\n"
  },
  {
    "path": "lib/utils/getAdditionalEntries.js",
    "content": "/**\n * @typedef {Object} AdditionalEntries\n * @property {string[]} prependEntries\n * @property {string[]} overlayEntries\n */\n\n/**\n * Creates an object that contains two entry arrays: the prependEntries and overlayEntries\n * @param {import('../types').NormalizedPluginOptions} options Configuration options for this plugin.\n * @returns {AdditionalEntries} An object that contains the Webpack entries for prepending and the overlay feature\n */\nfunction getAdditionalEntries(options) {\n  const prependEntries = [\n    // React-refresh runtime\n    require.resolve('../../client/ReactRefreshEntry'),\n  ];\n\n  const overlayEntries = [\n    // Error overlay runtime\n    options.overlay && options.overlay.entry && require.resolve(options.overlay.entry),\n  ].filter(Boolean);\n\n  return { prependEntries, overlayEntries };\n}\n\nmodule.exports = getAdditionalEntries;\n"
  },
  {
    "path": "lib/utils/getIntegrationEntry.js",
    "content": "/**\n * Gets entry point of a supported socket integration.\n * @param {'wds' | 'whm' | 'wps' | string} integrationType A valid socket integration type or a path to a module.\n * @returns {string | undefined} Path to the resolved integration entry point.\n */\nfunction getIntegrationEntry(integrationType) {\n  let resolvedEntry;\n  switch (integrationType) {\n    case 'whm': {\n      resolvedEntry = 'webpack-hot-middleware/client';\n      break;\n    }\n    case 'wps': {\n      resolvedEntry = 'webpack-plugin-serve/client';\n      break;\n    }\n  }\n\n  return resolvedEntry;\n}\n\nmodule.exports = getIntegrationEntry;\n"
  },
  {
    "path": "lib/utils/getSocketIntegration.js",
    "content": "/**\n * Gets the socket integration to use for Webpack messages.\n * @param {'wds' | 'whm' | 'wps' | string} integrationType A valid socket integration type or a path to a module.\n * @returns {string} Path to the resolved socket integration module.\n */\nfunction getSocketIntegration(integrationType) {\n  let resolvedSocketIntegration;\n  switch (integrationType) {\n    case 'wds': {\n      resolvedSocketIntegration = require.resolve('../../sockets/WDSSocket');\n      break;\n    }\n    case 'whm': {\n      resolvedSocketIntegration = require.resolve('../../sockets/WHMEventSource');\n      break;\n    }\n    case 'wps': {\n      resolvedSocketIntegration = require.resolve('../../sockets/WPSSocket');\n      break;\n    }\n    default: {\n      resolvedSocketIntegration = require.resolve(integrationType);\n      break;\n    }\n  }\n\n  return resolvedSocketIntegration;\n}\n\nmodule.exports = getSocketIntegration;\n"
  },
  {
    "path": "lib/utils/index.js",
    "content": "const getAdditionalEntries = require('./getAdditionalEntries');\nconst getIntegrationEntry = require('./getIntegrationEntry');\nconst getSocketIntegration = require('./getSocketIntegration');\nconst injectRefreshLoader = require('./injectRefreshLoader');\nconst makeRefreshRuntimeModule = require('./makeRefreshRuntimeModule');\nconst normalizeOptions = require('./normalizeOptions');\n\nmodule.exports = {\n  getAdditionalEntries,\n  getIntegrationEntry,\n  getSocketIntegration,\n  injectRefreshLoader,\n  makeRefreshRuntimeModule,\n  normalizeOptions,\n};\n"
  },
  {
    "path": "lib/utils/injectRefreshLoader.js",
    "content": "const path = require('node:path');\n\n/**\n * @callback MatchObject\n * @param {string} [str]\n * @returns {boolean}\n */\n\n/**\n * @typedef {Object} InjectLoaderOptions\n * @property {MatchObject} match A function to include/exclude files to be processed.\n * @property {import('../../loader/types').ReactRefreshLoaderOptions} [options] Options passed to the loader.\n */\n\nconst resolvedLoader = require.resolve('../../loader');\nconst reactRefreshPath = path.dirname(require.resolve('react-refresh'));\nconst refreshUtilsPath = path.join(__dirname, '../runtime/RefreshUtils');\n\n/**\n * Injects refresh loader to all JavaScript-like and user-specified files.\n * @param {*} moduleData Module factory creation data.\n * @param {InjectLoaderOptions} injectOptions Options to alter how the loader is injected.\n * @returns {*} The injected module factory creation data.\n */\nfunction injectRefreshLoader(moduleData, injectOptions) {\n  const { match, options } = injectOptions;\n\n  // Include and exclude user-specified files\n  if (!match(moduleData.matchResource || moduleData.resource)) return moduleData;\n  // Include and exclude dynamically generated modules from other loaders\n  if (moduleData.matchResource && !match(moduleData.request)) return moduleData;\n  // Exclude files referenced as assets\n  if (moduleData.type.includes('asset')) return moduleData;\n  // Check to prevent double injection\n  if (moduleData.loaders.find(({ loader }) => loader === resolvedLoader)) return moduleData;\n  // Skip react-refresh and the plugin's runtime utils to prevent self-referencing -\n  // this is useful when using the plugin as a direct dependency,\n  // or when node_modules are specified to be processed.\n  if (\n    moduleData.resource.includes(reactRefreshPath) ||\n    moduleData.resource.includes(refreshUtilsPath)\n  ) {\n    return moduleData;\n  }\n\n  // As we inject runtime code for each module,\n  // it is important to run the injected loader after everything.\n  // This way we can ensure that all code-processing have been done,\n  // and we won't risk breaking tools like Flow or ESLint.\n  moduleData.loaders.unshift({\n    loader: resolvedLoader,\n    options,\n  });\n\n  return moduleData;\n}\n\nmodule.exports = injectRefreshLoader;\n"
  },
  {
    "path": "lib/utils/makeRefreshRuntimeModule.js",
    "content": "/**\n * Makes a runtime module to intercept module execution for React Refresh.\n * This module creates an isolated `__webpack_require__` function for each module,\n * and injects a `$Refresh$` object into it for use by React Refresh.\n * @param {import('webpack')} webpack The Webpack exports.\n * @returns {typeof import('webpack').RuntimeModule} The runtime module class.\n */\nfunction makeRefreshRuntimeModule(webpack) {\n  return class ReactRefreshRuntimeModule extends webpack.RuntimeModule {\n    constructor() {\n      // Second argument is the `stage` for this runtime module -\n      // we'll use the same stage as Webpack's HMR runtime module for safety.\n      super('react refresh', webpack.RuntimeModule.STAGE_BASIC);\n    }\n\n    /**\n     * @returns {string} runtime code\n     */\n    generate() {\n      if (!this.compilation) throw new Error('Webpack compilation missing!');\n\n      const { runtimeTemplate } = this.compilation;\n      const constDeclaration = runtimeTemplate.supportsConst() ? 'const' : 'var';\n      return webpack.Template.asString([\n        `${constDeclaration} setup = ${runtimeTemplate.basicFunction('moduleId', [\n          `${constDeclaration} refresh = {`,\n          webpack.Template.indent([\n            `moduleId: moduleId,`,\n            `register: ${runtimeTemplate.basicFunction('type, id', [\n              `${constDeclaration} typeId = moduleId + ' ' + id;`,\n              'refresh.runtime.register(type, typeId);',\n            ])},`,\n            `signature: ${runtimeTemplate.returningFunction(\n              'refresh.runtime.createSignatureFunctionForTransform()'\n            )},`,\n            `runtime: {`,\n            webpack.Template.indent([\n              `createSignatureFunctionForTransform: ${runtimeTemplate.returningFunction(\n                runtimeTemplate.returningFunction('type', 'type')\n              )},`,\n              `register: ${runtimeTemplate.emptyFunction()}`,\n            ]),\n            `},`,\n          ]),\n          `};`,\n          `return refresh;`,\n        ])};`,\n        '',\n        `${webpack.RuntimeGlobals.interceptModuleExecution}.push(${runtimeTemplate.basicFunction(\n          'options',\n          [\n            `${constDeclaration} originalFactory = options.factory;`,\n            // Using a function declaration -\n            // ensures `this` would propagate for modules relying on it\n            `options.factory = function(moduleObject, moduleExports, webpackRequire) {`,\n            webpack.Template.indent([\n              // Our require function delegates to the original require function\n              `${constDeclaration} hotRequire = ${runtimeTemplate.returningFunction(\n                'webpackRequire(request)',\n                'request'\n              )};`,\n              // The propery descriptor factory below ensures all properties but `$Refresh$`\n              // are proxied through to the original require function\n              `${constDeclaration} createPropertyDescriptor = ${runtimeTemplate.basicFunction(\n                'name',\n                [\n                  `return {`,\n                  webpack.Template.indent([\n                    `configurable: true,`,\n                    `enumerable: true,`,\n                    `get: ${runtimeTemplate.returningFunction('webpackRequire[name]')},`,\n                    `set: ${runtimeTemplate.basicFunction('value', [\n                      'webpackRequire[name] = value;',\n                    ])},`,\n                  ]),\n                  `};`,\n                ]\n              )};`,\n              `for (${constDeclaration} name in webpackRequire) {`,\n              webpack.Template.indent([\n                'if (name === \"$Refresh$\") continue;',\n                'if (Object.prototype.hasOwnProperty.call(webpackRequire, name)) {',\n                webpack.Template.indent([\n                  `Object.defineProperty(hotRequire, name, createPropertyDescriptor(name));`,\n                ]),\n                `}`,\n              ]),\n              `}`,\n              `hotRequire.$Refresh$ = setup(options.id);`,\n              `originalFactory.call(this, moduleObject, moduleExports, hotRequire);`,\n            ]),\n            '};',\n          ]\n        )});`,\n      ]);\n    }\n  };\n}\n\nmodule.exports = makeRefreshRuntimeModule;\n"
  },
  {
    "path": "lib/utils/normalizeOptions.js",
    "content": "const { d, n } = require('../../options');\n\n/**\n * Normalizes the options for the plugin.\n * @param {import('../types').ReactRefreshPluginOptions} options Non-normalized plugin options.\n * @returns {import('../types').NormalizedPluginOptions} Normalized plugin options.\n */\nconst normalizeOptions = (options) => {\n  d(options, 'exclude', /node_modules/i);\n  d(options, 'include', /\\.([cm]js|[jt]sx?|flow)$/i);\n  d(options, 'forceEnable');\n  d(options, 'library');\n\n  n(options, 'overlay', (overlay) => {\n    /** @type {import('../types').NormalizedErrorOverlayOptions} */\n    const defaults = {\n      entry: require.resolve('../../client/ErrorOverlayEntry'),\n      module: require.resolve('../../overlay'),\n      sockIntegration: 'wds',\n    };\n\n    if (overlay === false) {\n      return false;\n    }\n    if (typeof overlay === 'undefined' || overlay === true) {\n      return defaults;\n    }\n\n    d(overlay, 'entry', defaults.entry);\n    d(overlay, 'module', defaults.module);\n    d(overlay, 'sockIntegration', defaults.sockIntegration);\n\n    return overlay;\n  });\n\n  return options;\n};\n\nmodule.exports = normalizeOptions;\n"
  },
  {
    "path": "loader/index.js",
    "content": "// This is a patch for mozilla/source-map#349 -\n// internally, it uses the existence of the `fetch` global to toggle browser behaviours.\n// That check, however, will break when `fetch` polyfills are used for SSR setups.\n// We \"reset\" the polyfill here to ensure it won't interfere with source-map generation.\nconst originalFetch = global.fetch;\ndelete global.fetch;\n\nconst { validate: validateOptions } = require('schema-utils');\nconst { SourceMapConsumer, SourceNode } = require('source-map');\nconst {\n  getIdentitySourceMap,\n  getModuleSystem,\n  getRefreshModuleRuntime,\n  normalizeOptions,\n  webpackGlobal,\n} = require('./utils');\nconst schema = require('./options.json');\n\nconst RefreshRuntimePath = require\n  .resolve('react-refresh')\n  .replace(/\\\\/g, '/')\n  .replace(/'/g, \"\\\\'\");\n\n/**\n * A simple Webpack loader to inject react-refresh HMR code into modules.\n *\n * [Reference for Loader API](https://webpack.js.org/api/loaders/)\n * @this {import('webpack').LoaderContext<import('./types').ReactRefreshLoaderOptions>}\n * @param {string} source The original module source code.\n * @param {import('source-map').RawSourceMap} [inputSourceMap] The source map of the module.\n * @param {*} [meta] The loader metadata passed in.\n * @returns {void}\n */\nfunction ReactRefreshLoader(source, inputSourceMap, meta) {\n  let options = this.getOptions();\n  validateOptions(schema, options, {\n    baseDataPath: 'options',\n    name: 'React Refresh Loader',\n  });\n\n  options = normalizeOptions(options);\n\n  const callback = this.async();\n\n  const { ModuleFilenameHelpers, Template } = this._compiler.webpack || require('webpack');\n\n  const RefreshSetupRuntimes = {\n    cjs: Template.asString(\n      `${webpackGlobal}.$Refresh$.runtime = require('${RefreshRuntimePath}');`\n    ),\n    esm: Template.asString([\n      `import * as __react_refresh_runtime__ from '${RefreshRuntimePath}';`,\n      `${webpackGlobal}.$Refresh$.runtime = __react_refresh_runtime__;`,\n    ]),\n  };\n\n  /**\n   * @this {import('webpack').LoaderContext<import('./types').ReactRefreshLoaderOptions>}\n   * @param {string} source\n   * @param {import('source-map').RawSourceMap} [inputSourceMap]\n   * @returns {Promise<[string, import('source-map').RawSourceMap]>}\n   */\n  async function _loader(source, inputSourceMap) {\n    /** @type {'esm' | 'cjs'} */\n    const moduleSystem = await getModuleSystem.call(this, ModuleFilenameHelpers, options);\n\n    const RefreshSetupRuntime = RefreshSetupRuntimes[moduleSystem];\n    const RefreshModuleRuntime = getRefreshModuleRuntime(Template, {\n      const: options.const,\n      moduleSystem,\n    });\n\n    if (this.sourceMap) {\n      let originalSourceMap = inputSourceMap;\n      if (!originalSourceMap) {\n        originalSourceMap = getIdentitySourceMap(source, this.resourcePath);\n      }\n\n      return SourceMapConsumer.with(originalSourceMap, undefined, (consumer) => {\n        const node = SourceNode.fromStringWithSourceMap(source, consumer);\n\n        node.prepend([RefreshSetupRuntime, '\\n\\n']);\n        node.add(['\\n\\n', RefreshModuleRuntime]);\n\n        const { code, map } = node.toStringWithSourceMap();\n        return [code, map.toJSON()];\n      });\n    } else {\n      return [[RefreshSetupRuntime, source, RefreshModuleRuntime].join('\\n\\n'), inputSourceMap];\n    }\n  }\n\n  _loader.call(this, source, inputSourceMap).then(\n    ([code, map]) => {\n      callback(null, code, map, meta);\n    },\n    (error) => {\n      callback(error);\n    }\n  );\n}\n\nmodule.exports = ReactRefreshLoader;\n\n// Restore the original value of the `fetch` global, if it exists\nif (originalFetch) {\n  global.fetch = originalFetch;\n}\n"
  },
  {
    "path": "loader/options.json",
    "content": "{\n  \"additionalProperties\": false,\n  \"type\": \"object\",\n  \"definitions\": {\n    \"MatchCondition\": {\n      \"anyOf\": [{ \"instanceof\": \"RegExp\", \"tsType\": \"RegExp\" }, { \"$ref\": \"#/definitions/Path\" }]\n    },\n    \"MatchConditions\": {\n      \"type\": \"array\",\n      \"items\": { \"$ref\": \"#/definitions/MatchCondition\" },\n      \"minItems\": 1\n    },\n    \"Path\": { \"type\": \"string\" },\n    \"ESModuleOptions\": {\n      \"additionalProperties\": false,\n      \"type\": \"object\",\n      \"properties\": {\n        \"exclude\": {\n          \"anyOf\": [\n            { \"$ref\": \"#/definitions/MatchCondition\" },\n            { \"$ref\": \"#/definitions/MatchConditions\" }\n          ]\n        },\n        \"include\": {\n          \"anyOf\": [\n            { \"$ref\": \"#/definitions/MatchCondition\" },\n            { \"$ref\": \"#/definitions/MatchConditions\" }\n          ]\n        }\n      }\n    }\n  },\n  \"properties\": {\n    \"const\": { \"type\": \"boolean\" },\n    \"esModule\": { \"anyOf\": [{ \"type\": \"boolean\" }, { \"$ref\": \"#/definitions/ESModuleOptions\" }] }\n  }\n}\n"
  },
  {
    "path": "loader/types.js",
    "content": "/**\n * @typedef {Object} ESModuleOptions\n * @property {string | RegExp | Array<string | RegExp>} [exclude] Files to explicitly exclude from flagged as ES Modules.\n * @property {string | RegExp | Array<string | RegExp>} [include] Files to explicitly include for flagged as ES Modules.\n */\n\n/**\n * @typedef {Object} ReactRefreshLoaderOptions\n * @property {boolean} [const] Enables usage of ES6 `const` and `let` in generated runtime code.\n * @property {boolean | ESModuleOptions} [esModule] Enables strict ES Modules compatible runtime.\n */\n\n/**\n * @typedef {import('type-fest').SetRequired<ReactRefreshLoaderOptions, 'const'>} NormalizedLoaderOptions\n */\n\nmodule.exports = {};\n"
  },
  {
    "path": "loader/utils/getIdentitySourceMap.js",
    "content": "const { SourceMapGenerator } = require('source-map');\n\n/**\n * Generates an identity source map from a source file.\n * @param {string} source The content of the source file.\n * @param {string} resourcePath The name of the source file.\n * @returns {import('source-map').RawSourceMap} The identity source map.\n */\nfunction getIdentitySourceMap(source, resourcePath) {\n  const sourceMap = new SourceMapGenerator();\n  sourceMap.setSourceContent(resourcePath, source);\n\n  source.split('\\n').forEach((_, index) => {\n    sourceMap.addMapping({\n      source: resourcePath,\n      original: {\n        line: index + 1,\n        column: 0,\n      },\n      generated: {\n        line: index + 1,\n        column: 0,\n      },\n    });\n  });\n\n  return sourceMap.toJSON();\n}\n\nmodule.exports = getIdentitySourceMap;\n"
  },
  {
    "path": "loader/utils/getModuleSystem.js",
    "content": "const fs = require('node:fs/promises');\nconst path = require('node:path');\n\n/** @type {Map<string, string | undefined>} */\nlet packageJsonTypeMap = new Map();\n\n/**\n * Infers the current active module system from loader context and options.\n * @this {import('webpack').loader.LoaderContext}\n * @param {import('webpack').ModuleFilenameHelpers} ModuleFilenameHelpers Webpack's module filename helpers.\n * @param {import('../types').NormalizedLoaderOptions} options The normalized loader options.\n * @return {Promise<'esm' | 'cjs'>} The inferred module system.\n */\nasync function getModuleSystem(ModuleFilenameHelpers, options) {\n  // Check loader options -\n  // if `esModule` is set we don't have to do extra guess work.\n  switch (typeof options.esModule) {\n    case 'boolean': {\n      return options.esModule ? 'esm' : 'cjs';\n    }\n    case 'object': {\n      if (\n        options.esModule.include &&\n        ModuleFilenameHelpers.matchPart(this.resourcePath, options.esModule.include)\n      ) {\n        return 'esm';\n      }\n      if (\n        options.esModule.exclude &&\n        ModuleFilenameHelpers.matchPart(this.resourcePath, options.esModule.exclude)\n      ) {\n        return 'cjs';\n      }\n\n      break;\n    }\n    default: // Do nothing\n  }\n\n  // Check current resource's extension\n  if (/\\.mjs$/.test(this.resourcePath)) return 'esm';\n  if (/\\.cjs$/.test(this.resourcePath)) return 'cjs';\n\n  if (typeof this.addMissingDependency !== 'function') {\n    // This is Webpack 4 which does not support `import.meta`.\n    // We assume `.js` files are CommonJS because the output cannot be ESM anyway.\n    return 'cjs';\n  }\n\n  // We will assume CommonJS if we cannot determine otherwise\n  let packageJsonType = '';\n\n  // We begin our search for relevant `package.json` files,\n  // at the directory of the resource being loaded.\n  // These paths should already be resolved,\n  // but we resolve them again to ensure we are dealing with an aboslute path.\n  const resourceContext = path.dirname(this.resourcePath);\n  let searchPath = resourceContext;\n  let previousSearchPath = '';\n  // We start our search just above the root context of the webpack compilation\n  const stopPath = path.dirname(this.rootContext);\n\n  // If the module context is a resolved symlink outside the `rootContext` path,\n  // then we will never find the `stopPath` - so we also halt when we hit the root.\n  // Note that there is a potential that the wrong `package.json` is found in some pathalogical cases,\n  // such as a folder that is conceptually a package + does not have an ancestor `package.json`,\n  // but there exists a `package.json` higher up.\n  // This might happen if you have a folder of utility JS files that you symlink but did not organize as a package.\n  // We consider this an unsupported edge case for now.\n  while (searchPath !== stopPath && searchPath !== previousSearchPath) {\n    // If we have already determined the `package.json` type for this path we can stop searching.\n    // We do however still need to cache the found value,\n    // from the `resourcePath` folder up to the matching `searchPath`,\n    // to avoid retracing these steps when processing sibling resources.\n    if (packageJsonTypeMap.has(searchPath)) {\n      packageJsonType = packageJsonTypeMap.get(searchPath);\n\n      let currentPath = resourceContext;\n      while (currentPath !== searchPath) {\n        // We set the found type at least level from `resourcePath` folder up to the matching `searchPath`\n        packageJsonTypeMap.set(currentPath, packageJsonType);\n        currentPath = path.dirname(currentPath);\n      }\n      break;\n    }\n\n    let packageJsonPath = path.join(searchPath, 'package.json');\n    try {\n      const packageSource = await fs.readFile(packageJsonPath, 'utf-8');\n      try {\n        const packageObject = JSON.parse(packageSource);\n\n        // Any package.json is sufficient as long as it can be parsed.\n        // If it does not explicitly have a `type: \"module\"` it will be assumed to be CommonJS.\n        packageJsonType = typeof packageObject.type === 'string' ? packageObject.type : '';\n        packageJsonTypeMap.set(searchPath, packageJsonType);\n\n        // We set the type in the cache for all paths from the `resourcePath` folder,\n        // up to the matching `searchPath` to avoid retracing these steps when processing sibling resources.\n        let currentPath = resourceContext;\n        while (currentPath !== searchPath) {\n          packageJsonTypeMap.set(currentPath, packageJsonType);\n          currentPath = path.dirname(currentPath);\n        }\n      } catch (e) {\n        // `package.json` exists but could not be parsed.\n        // We track it as a dependency so we can reload if this file changes.\n      }\n\n      this.addDependency(packageJsonPath);\n      break;\n    } catch (e) {\n      // `package.json` does not exist.\n      // We track it as a missing dependency so we can reload if this file is added.\n      this.addMissingDependency(packageJsonPath);\n    }\n\n    // Try again at the next level up\n    previousSearchPath = searchPath;\n    searchPath = path.dirname(searchPath);\n  }\n\n  // Check `package.json` for the `type` field -\n  // fallback to use `cjs` for anything ambiguous.\n  return packageJsonType === 'module' ? 'esm' : 'cjs';\n}\n\nmodule.exports = getModuleSystem;\n"
  },
  {
    "path": "loader/utils/getRefreshModuleRuntime.js",
    "content": "const webpackGlobal = require('./webpackGlobal');\n\n/**\n * @typedef ModuleRuntimeOptions {Object}\n * @property {boolean} const Use ES6 `const` and `let` in generated runtime code.\n * @property {'cjs' | 'esm'} moduleSystem The module system to be used.\n */\n\n/**\n * Generates code appended to each JS-like module for react-refresh capabilities.\n *\n * `__react_refresh_utils__` will be replaced with actual utils during source parsing by `webpack.ProvidePlugin`.\n *\n * [Reference for Runtime Injection](https://github.com/webpack/webpack/blob/b07d3b67d2252f08e4bb65d354a11c9b69f8b434/lib/HotModuleReplacementPlugin.js#L419)\n * [Reference for HMR Error Recovery](https://github.com/webpack/webpack/issues/418#issuecomment-490296365)\n *\n * @param {import('webpack').Template} Webpack's templating helpers.\n * @param {ModuleRuntimeOptions} options The refresh module runtime options.\n * @returns {string} The refresh module runtime template.\n */\nfunction getRefreshModuleRuntime(Template, options) {\n  const constDeclaration = options.const ? 'const' : 'var';\n  const letDeclaration = options.const ? 'let' : 'var';\n  const webpackHot = options.moduleSystem === 'esm' ? 'import.meta.webpackHot' : 'module.hot';\n  return Template.asString([\n    `${constDeclaration} $ReactRefreshModuleId$ = ${webpackGlobal}.$Refresh$.moduleId;`,\n    `${constDeclaration} $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports(`,\n    Template.indent('$ReactRefreshModuleId$'),\n    ');',\n    '',\n    'function $ReactRefreshModuleRuntime$(exports) {',\n    Template.indent([\n      `if (${webpackHot}) {`,\n      Template.indent([\n        `${letDeclaration} errorOverlay;`,\n        \"if (typeof __react_refresh_error_overlay__ !== 'undefined') {\",\n        Template.indent('errorOverlay = __react_refresh_error_overlay__;'),\n        '}',\n        `${letDeclaration} testMode;`,\n        \"if (typeof __react_refresh_test__ !== 'undefined') {\",\n        Template.indent('testMode = __react_refresh_test__;'),\n        '}',\n        'return __react_refresh_utils__.executeRuntime(',\n        Template.indent([\n          'exports,',\n          '$ReactRefreshModuleId$,',\n          `${webpackHot},`,\n          'errorOverlay,',\n          'testMode',\n        ]),\n        ');',\n      ]),\n      '}',\n    ]),\n    '}',\n    '',\n    \"if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) {\",\n    Template.indent('$ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$);'),\n    '} else {',\n    Template.indent('$ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$);'),\n    '}',\n  ]);\n}\n\nmodule.exports = getRefreshModuleRuntime;\n"
  },
  {
    "path": "loader/utils/index.js",
    "content": "const getIdentitySourceMap = require('./getIdentitySourceMap');\nconst getModuleSystem = require('./getModuleSystem');\nconst getRefreshModuleRuntime = require('./getRefreshModuleRuntime');\nconst normalizeOptions = require('./normalizeOptions');\nconst webpackGlobal = require('./webpackGlobal');\n\nmodule.exports = {\n  getIdentitySourceMap,\n  getModuleSystem,\n  getRefreshModuleRuntime,\n  normalizeOptions,\n  webpackGlobal,\n};\n"
  },
  {
    "path": "loader/utils/normalizeOptions.js",
    "content": "const { d, n } = require('../../options');\n\n/**\n * Normalizes the options for the loader.\n * @param {import('../types').ReactRefreshLoaderOptions} options Non-normalized loader options.\n * @returns {import('../types').NormalizedLoaderOptions} Normalized loader options.\n */\nconst normalizeOptions = (options) => {\n  d(options, 'const', false);\n\n  n(options, 'esModule', (esModule) => {\n    if (typeof esModule === 'boolean' || typeof esModule === 'undefined') {\n      return esModule;\n    }\n\n    d(esModule, 'include');\n    d(esModule, 'exclude');\n\n    return esModule;\n  });\n\n  return options;\n};\n\nmodule.exports = normalizeOptions;\n"
  },
  {
    "path": "loader/utils/webpackGlobal.js",
    "content": "// When available, use `__webpack_global__` which is a stable runtime function to use `__webpack_require__` in this compilation\n// See: https://github.com/webpack/webpack/issues/20139\nconst webpackGlobal = `(typeof __webpack_global__ !== 'undefined' ? __webpack_global__ : __webpack_require__)`;\n\nmodule.exports = webpackGlobal;\n"
  },
  {
    "path": "options/index.js",
    "content": "/**\n * Sets a constant default value for the property when it is undefined.\n * @template T\n * @template {keyof T} Property\n * @param {T} object An object.\n * @param {Property} property A property of the provided object.\n * @param {T[Property]} [defaultValue] The default value to set for the property.\n * @returns {T[Property]} The defaulted property value.\n */\nconst d = (object, property, defaultValue) => {\n  if (typeof object[property] === 'undefined' && typeof defaultValue !== 'undefined') {\n    object[property] = defaultValue;\n  }\n  return object[property];\n};\n\n/**\n * Resolves the value for a nested object option.\n * @template T\n * @template {keyof T} Property\n * @template Result\n * @param {T} object An object.\n * @param {Property} property A property of the provided object.\n * @param {function(T | undefined): Result} fn The handler to resolve the property's value.\n * @returns {Result} The resolved option value.\n */\nconst n = (object, property, fn) => {\n  object[property] = fn(object[property]);\n  return object[property];\n};\n\nmodule.exports = { d, n };\n"
  },
  {
    "path": "overlay/components/CompileErrorTrace.js",
    "content": "const Anser = require('anser');\nconst entities = require('html-entities');\nconst utils = require('../utils.js');\n\n/**\n * @typedef {Object} CompileErrorTraceProps\n * @property {string} errorMessage\n */\n\n/**\n * A formatter that turns Webpack compile error messages into highlighted HTML source traces.\n * @param {Document} document\n * @param {HTMLElement} root\n * @param {CompileErrorTraceProps} props\n * @returns {void}\n */\nfunction CompileErrorTrace(document, root, props) {\n  const errorParts = props.errorMessage.split('\\n');\n  if (errorParts.length) {\n    if (errorParts[0]) {\n      errorParts[0] = utils.formatFilename(errorParts[0]);\n    }\n\n    const errorMessage = errorParts.splice(1, 1)[0];\n    if (errorMessage) {\n      // Strip filename from the error message\n      errorParts.unshift(errorMessage.replace(/^(.*:)\\s.*:(\\s.*)$/, '$1$2'));\n    }\n  }\n\n  const stackContainer = document.createElement('pre');\n  stackContainer.style.fontFamily = [\n    '\"SFMono-Regular\"',\n    'Consolas',\n    'Liberation Mono',\n    'Menlo',\n    'Courier',\n    'monospace',\n  ].join(', ');\n  stackContainer.style.margin = '0';\n  stackContainer.style.whiteSpace = 'pre-wrap';\n\n  const entries = Anser.ansiToJson(\n    entities.encode(errorParts.join('\\n'), { level: 'html5', mode: 'nonAscii' }),\n    {\n      json: true,\n      remove_empty: true,\n      use_classes: true,\n    }\n  );\n  for (let i = 0; i < entries.length; i += 1) {\n    const entry = entries[i];\n    const elem = document.createElement('span');\n    elem.innerHTML = entry.content;\n    elem.style.color = entry.fg ? `var(--color-${entry.fg})` : undefined;\n    elem.style.wordBreak = 'break-word';\n    switch (entry.decoration) {\n      case 'bold':\n        elem.style.fontWeight = 800;\n        break;\n      case 'italic':\n        elem.style.fontStyle = 'italic';\n        break;\n    }\n\n    stackContainer.appendChild(elem);\n  }\n\n  root.appendChild(stackContainer);\n}\n\nmodule.exports = CompileErrorTrace;\n"
  },
  {
    "path": "overlay/components/PageHeader.js",
    "content": "const Spacer = require('./Spacer.js');\nconst theme = require('../theme.js');\n\n/**\n * @typedef {Object} PageHeaderProps\n * @property {string} [message]\n * @property {string} title\n * @property {string} [topOffset]\n */\n\n/**\n * The header of the overlay.\n * @param {Document} document\n * @param {HTMLElement} root\n * @param {PageHeaderProps} props\n * @returns {void}\n */\nfunction PageHeader(document, root, props) {\n  const pageHeaderContainer = document.createElement('div');\n  pageHeaderContainer.style.background = theme['dark-background'];\n  pageHeaderContainer.style.boxShadow = '0 1px 4px rgba(0, 0, 0, 0.3)';\n  pageHeaderContainer.style.color = theme.white;\n  pageHeaderContainer.style.left = '0';\n  pageHeaderContainer.style.right = '0';\n  pageHeaderContainer.style.padding = '1rem 1.5rem';\n  pageHeaderContainer.style.paddingLeft = 'max(1.5rem, env(safe-area-inset-left))';\n  pageHeaderContainer.style.paddingRight = 'max(1.5rem, env(safe-area-inset-right))';\n  pageHeaderContainer.style.position = 'fixed';\n  pageHeaderContainer.style.top = props.topOffset || '0';\n\n  const title = document.createElement('h3');\n  title.innerText = props.title;\n  title.style.color = theme.red;\n  title.style.fontSize = '1.125rem';\n  title.style.lineHeight = '1.3';\n  title.style.margin = '0';\n  pageHeaderContainer.appendChild(title);\n\n  if (props.message) {\n    title.style.margin = '0 0 0.5rem';\n\n    const message = document.createElement('span');\n    message.innerText = props.message;\n    message.style.color = theme.white;\n    message.style.wordBreak = 'break-word';\n    pageHeaderContainer.appendChild(message);\n  }\n\n  root.appendChild(pageHeaderContainer);\n\n  // This has to run after appending elements to root\n  // because we need to actual mounted height.\n  Spacer(document, root, {\n    space: pageHeaderContainer.offsetHeight.toString(10),\n  });\n}\n\nmodule.exports = PageHeader;\n"
  },
  {
    "path": "overlay/components/RuntimeErrorFooter.js",
    "content": "const Spacer = require('./Spacer.js');\nconst theme = require('../theme.js');\n\n/**\n * @typedef {Object} RuntimeErrorFooterProps\n * @property {string} [initialFocus]\n * @property {boolean} multiple\n * @property {function(MouseEvent): void} onClickCloseButton\n * @property {function(MouseEvent): void} onClickNextButton\n * @property {function(MouseEvent): void} onClickPrevButton\n */\n\n/**\n * A fixed footer that handles pagination of runtime errors.\n * @param {Document} document\n * @param {HTMLElement} root\n * @param {RuntimeErrorFooterProps} props\n * @returns {void}\n */\nfunction RuntimeErrorFooter(document, root, props) {\n  const footer = document.createElement('div');\n  footer.style.backgroundColor = theme['dark-background'];\n  footer.style.bottom = '0';\n  footer.style.boxShadow = '0 -1px 4px rgba(0, 0, 0, 0.3)';\n  footer.style.height = '2.5rem';\n  footer.style.left = '0';\n  footer.style.right = '0';\n  footer.style.lineHeight = '2.5rem';\n  footer.style.paddingBottom = '0';\n  footer.style.paddingBottom = 'env(safe-area-inset-bottom)';\n  footer.style.position = 'fixed';\n  footer.style.textAlign = 'center';\n  footer.style.zIndex = '2';\n\n  const BUTTON_CONFIGS = {\n    prev: {\n      id: 'prev',\n      label: '◀&ensp;Prev',\n      onClick: props.onClickPrevButton,\n    },\n    close: {\n      id: 'close',\n      label: '×&ensp;Close',\n      onClick: props.onClickCloseButton,\n    },\n    next: {\n      id: 'next',\n      label: 'Next&ensp;▶',\n      onClick: props.onClickNextButton,\n    },\n  };\n\n  let buttons = [BUTTON_CONFIGS.close];\n  if (props.multiple) {\n    buttons = [BUTTON_CONFIGS.prev, BUTTON_CONFIGS.close, BUTTON_CONFIGS.next];\n  }\n\n  /** @type {HTMLButtonElement | undefined} */\n  let initialFocusButton;\n  for (let i = 0; i < buttons.length; i += 1) {\n    const buttonConfig = buttons[i];\n\n    const button = document.createElement('button');\n    button.id = buttonConfig.id;\n    button.innerHTML = buttonConfig.label;\n    button.tabIndex = 1;\n    button.style.backgroundColor = theme['dark-background'];\n    button.style.border = 'none';\n    button.style.color = theme.white;\n    button.style.cursor = 'pointer';\n    button.style.fontSize = 'inherit';\n    button.style.height = '100%';\n    button.style.padding = '0.5rem 0.75rem';\n    button.style.width = `${(100 / buttons.length).toString(10)}%`;\n    button.addEventListener('click', buttonConfig.onClick);\n\n    if (buttonConfig.id === props.initialFocus) {\n      initialFocusButton = button;\n    }\n\n    footer.appendChild(button);\n  }\n\n  root.appendChild(footer);\n\n  Spacer(document, root, { space: '2.5rem' });\n\n  if (initialFocusButton) {\n    initialFocusButton.focus();\n  }\n}\n\nmodule.exports = RuntimeErrorFooter;\n"
  },
  {
    "path": "overlay/components/RuntimeErrorHeader.js",
    "content": "const Spacer = require('./Spacer.js');\nconst theme = require('../theme.js');\n\n/**\n * @typedef {Object} RuntimeErrorHeaderProps\n * @property {number} currentErrorIndex\n * @property {number} totalErrors\n */\n\n/**\n * A fixed header that shows the total runtime error count.\n * @param {Document} document\n * @param {HTMLElement} root\n * @param {RuntimeErrorHeaderProps} props\n * @returns {void}\n */\nfunction RuntimeErrorHeader(document, root, props) {\n  const header = document.createElement('div');\n  header.innerText = `Error ${props.currentErrorIndex + 1} of ${props.totalErrors}`;\n  header.style.backgroundColor = theme.red;\n  header.style.color = theme.white;\n  header.style.fontWeight = '500';\n  header.style.height = '2.5rem';\n  header.style.left = '0';\n  header.style.lineHeight = '2.5rem';\n  header.style.position = 'fixed';\n  header.style.textAlign = 'center';\n  header.style.top = '0';\n  header.style.width = '100vw';\n  header.style.zIndex = '2';\n\n  root.appendChild(header);\n\n  Spacer(document, root, { space: '2.5rem' });\n}\n\nmodule.exports = RuntimeErrorHeader;\n"
  },
  {
    "path": "overlay/components/RuntimeErrorStack.js",
    "content": "const ErrorStackParser = require('error-stack-parser');\nconst theme = require('../theme.js');\nconst utils = require('../utils.js');\n\n/**\n * @typedef {Object} RuntimeErrorStackProps\n * @property {Error} error\n */\n\n/**\n * A formatter that turns runtime error stacks into highlighted HTML stacks.\n * @param {Document} document\n * @param {HTMLElement} root\n * @param {RuntimeErrorStackProps} props\n * @returns {void}\n */\nfunction RuntimeErrorStack(document, root, props) {\n  const stackTitle = document.createElement('h4');\n  stackTitle.innerText = 'Call Stack';\n  stackTitle.style.color = theme.white;\n  stackTitle.style.fontSize = '1.0625rem';\n  stackTitle.style.fontWeight = '500';\n  stackTitle.style.lineHeight = '1.3';\n  stackTitle.style.margin = '0 0 0.5rem';\n\n  const stackContainer = document.createElement('div');\n  stackContainer.style.fontSize = '0.8125rem';\n  stackContainer.style.lineHeight = '1.3';\n  stackContainer.style.whiteSpace = 'pre-wrap';\n\n  let errorStacks;\n  try {\n    errorStacks = ErrorStackParser.parse(props.error);\n  } catch (e) {\n    errorStacks = [];\n    stackContainer.innerHTML = 'No stack trace is available for this error!';\n  }\n\n  for (let i = 0; i < Math.min(errorStacks.length, 10); i += 1) {\n    const currentStack = errorStacks[i];\n\n    const functionName = document.createElement('code');\n    functionName.innerHTML = `&emsp;${currentStack.functionName || '(anonymous function)'}`;\n    functionName.style.color = theme.yellow;\n    functionName.style.fontFamily = [\n      '\"SFMono-Regular\"',\n      'Consolas',\n      'Liberation Mono',\n      'Menlo',\n      'Courier',\n      'monospace',\n    ].join(', ');\n\n    const fileName = document.createElement('div');\n    fileName.innerHTML =\n      '&emsp;&emsp;' +\n      utils.formatFilename(currentStack.fileName) +\n      ':' +\n      currentStack.lineNumber +\n      ':' +\n      currentStack.columnNumber;\n    fileName.style.color = theme.white;\n    fileName.style.fontSize = '0.6875rem';\n    fileName.style.marginBottom = '0.25rem';\n\n    stackContainer.appendChild(functionName);\n    stackContainer.appendChild(fileName);\n  }\n\n  root.appendChild(stackTitle);\n  root.appendChild(stackContainer);\n}\n\nmodule.exports = RuntimeErrorStack;\n"
  },
  {
    "path": "overlay/components/Spacer.js",
    "content": "/**\n * @typedef {Object} SpacerProps\n * @property {string} space\n */\n\n/**\n * An empty element to add spacing manually.\n * @param {Document} document\n * @param {HTMLElement} root\n * @param {SpacerProps} props\n * @returns {void}\n */\nfunction Spacer(document, root, props) {\n  const spacer = document.createElement('div');\n  spacer.style.paddingBottom = props.space;\n  root.appendChild(spacer);\n}\n\nmodule.exports = Spacer;\n"
  },
  {
    "path": "overlay/containers/CompileErrorContainer.js",
    "content": "const CompileErrorTrace = require('../components/CompileErrorTrace.js');\nconst PageHeader = require('../components/PageHeader.js');\nconst Spacer = require('../components/Spacer.js');\n\n/**\n * @typedef {Object} CompileErrorContainerProps\n * @property {string} errorMessage\n */\n\n/**\n * A container to render Webpack compilation error messages with source trace.\n * @param {Document} document\n * @param {HTMLElement} root\n * @param {CompileErrorContainerProps} props\n * @returns {void}\n */\nfunction CompileErrorContainer(document, root, props) {\n  PageHeader(document, root, {\n    title: 'Failed to compile.',\n  });\n  CompileErrorTrace(document, root, { errorMessage: props.errorMessage });\n  Spacer(document, root, { space: '1rem' });\n}\n\nmodule.exports = CompileErrorContainer;\n"
  },
  {
    "path": "overlay/containers/RuntimeErrorContainer.js",
    "content": "const PageHeader = require('../components/PageHeader.js');\nconst RuntimeErrorStack = require('../components/RuntimeErrorStack.js');\nconst Spacer = require('../components/Spacer.js');\n\n/**\n * @typedef {Object} RuntimeErrorContainerProps\n * @property {Error} currentError\n */\n\n/**\n * A container to render runtime error messages with stack trace.\n * @param {Document} document\n * @param {HTMLElement} root\n * @param {RuntimeErrorContainerProps} props\n * @returns {void}\n */\nfunction RuntimeErrorContainer(document, root, props) {\n  PageHeader(document, root, {\n    message: props.currentError.message,\n    title: props.currentError.name,\n    topOffset: '2.5rem',\n  });\n  RuntimeErrorStack(document, root, {\n    error: props.currentError,\n  });\n  Spacer(document, root, { space: '1rem' });\n}\n\nmodule.exports = RuntimeErrorContainer;\n"
  },
  {
    "path": "overlay/index.js",
    "content": "const RuntimeErrorFooter = require('./components/RuntimeErrorFooter.js');\nconst RuntimeErrorHeader = require('./components/RuntimeErrorHeader.js');\nconst CompileErrorContainer = require('./containers/CompileErrorContainer.js');\nconst RuntimeErrorContainer = require('./containers/RuntimeErrorContainer.js');\nconst theme = require('./theme.js');\nconst utils = require('./utils.js');\n\n/**\n * @callback RenderFn\n * @returns {void}\n */\n\n/* ===== Cached elements for DOM manipulations ===== */\n/**\n * The iframe that contains the overlay.\n * @type {HTMLIFrameElement}\n */\nlet iframeRoot = null;\n/**\n * The document object from the iframe root, used to create and render elements.\n * @type {Document}\n */\nlet rootDocument = null;\n/**\n * The root div elements will attach to.\n * @type {HTMLDivElement}\n */\nlet root = null;\n/**\n * A Cached function to allow deferred render.\n * @type {RenderFn | null}\n */\nlet scheduledRenderFn = null;\n\n/* ===== Overlay State ===== */\n/**\n * The latest error message from Webpack compilation.\n * @type {string}\n */\nlet currentCompileErrorMessage = '';\n/**\n * Index of the error currently shown by the overlay.\n * @type {number}\n */\nlet currentRuntimeErrorIndex = 0;\n/**\n * The latest runtime error objects.\n * @type {Error[]}\n */\nlet currentRuntimeErrors = [];\n/**\n * The render mode the overlay is currently in.\n * @type {'compileError' | 'runtimeError' | null}\n */\nlet currentMode = null;\n\n/**\n * @typedef {Object} IframeProps\n * @property {function(): void} onIframeLoad\n */\n\n/**\n * Creates the main `iframe` the overlay will attach to.\n * Accepts a callback to be ran after iframe is initialized.\n * @param {Document} document\n * @param {HTMLElement} root\n * @param {IframeProps} props\n * @returns {HTMLIFrameElement}\n */\nfunction IframeRoot(document, root, props) {\n  const iframe = document.createElement('iframe');\n  iframe.id = 'react-refresh-overlay';\n  iframe.src = 'about:blank';\n\n  iframe.style.border = 'none';\n  iframe.style.height = '100%';\n  iframe.style.left = '0';\n  iframe.style.minHeight = '100vh';\n  iframe.style.minHeight = '-webkit-fill-available';\n  iframe.style.position = 'fixed';\n  iframe.style.top = '0';\n  iframe.style.width = '100vw';\n  iframe.style.zIndex = '2147483647';\n  iframe.addEventListener('load', function onLoad() {\n    // Reset margin of iframe body\n    iframe.contentDocument.body.style.margin = '0';\n    props.onIframeLoad();\n  });\n\n  // We skip mounting and returns as we need to ensure\n  // the load event is fired after we setup the global variable\n  return iframe;\n}\n\n/**\n * Creates the main `div` element for the overlay to render.\n * @param {Document} document\n * @param {HTMLElement} root\n * @returns {HTMLDivElement}\n */\nfunction OverlayRoot(document, root) {\n  const div = document.createElement('div');\n  div.id = 'react-refresh-overlay-error';\n\n  // Apply ANSI theme\n  div.style.setProperty('--color-ansi-selection', theme.selection);\n  div.style.setProperty('--color-ansi-bg', theme.background);\n  div.style.setProperty('--color-ansi-fg', theme.white);\n  div.style.setProperty('--color-ansi-white', theme.white);\n  div.style.setProperty('--color-ansi-black', theme.black);\n  div.style.setProperty('--color-ansi-blue', theme.blue);\n  div.style.setProperty('--color-ansi-cyan', theme.cyan);\n  div.style.setProperty('--color-ansi-green', theme.green);\n  div.style.setProperty('--color-ansi-magenta', theme.magenta);\n  div.style.setProperty('--color-ansi-red', theme.red);\n  div.style.setProperty('--color-ansi-yellow', theme.yellow);\n  div.style.setProperty('--color-ansi-bright-white', theme['bright-white']);\n  div.style.setProperty('--color-ansi-bright-black', theme['bright-black']);\n  div.style.setProperty('--color-ansi-bright-blue', theme['bright-blue']);\n  div.style.setProperty('--color-ansi-bright-cyan', theme['bright-cyan']);\n  div.style.setProperty('--color-ansi-bright-green', theme['bright-green']);\n  div.style.setProperty('--color-ansi-bright-magenta', theme['bright-magenta']);\n  div.style.setProperty('--color-ansi-bright-red', theme['bright-red']);\n  div.style.setProperty('--color-ansi-bright-yellow', theme['bright-yellow']);\n\n  // Style the contents container\n  div.style.backgroundColor = theme.background;\n  div.style.boxSizing = 'border-box';\n  div.style.color = theme.white;\n  div.style.fontFamily = ['-apple-system', '\"Source Sans Pro\"', 'sans-serif'].join(', ');\n  div.style.fontSize = '0.875rem';\n  div.style.height = '100%';\n  div.style.lineHeight = '1.3';\n  div.style.overflow = 'auto';\n  div.style.padding = '1rem 1.5rem 0';\n  div.style.paddingTop = 'max(1rem, env(safe-area-inset-top))';\n  div.style.paddingRight = 'max(1.5rem, env(safe-area-inset-right))';\n  div.style.paddingBottom = 'env(safe-area-inset-bottom)';\n  div.style.paddingLeft = 'max(1.5rem, env(safe-area-inset-left))';\n  div.style.width = '100vw';\n\n  root.appendChild(div);\n  return div;\n}\n\n/**\n * Ensures the iframe root and the overlay root are both initialized before render.\n * If check fails, render will be deferred until both roots are initialized.\n * @param {RenderFn} renderFn A function that triggers a DOM render.\n * @returns {void}\n */\nfunction ensureRootExists(renderFn) {\n  if (root) {\n    // Overlay root is ready, we can render right away.\n    renderFn();\n    return;\n  }\n\n  // Creating an iframe may be asynchronous so we'll defer render.\n  // In case of multiple calls, function from the last call will be used.\n  scheduledRenderFn = renderFn;\n\n  if (iframeRoot) {\n    // Iframe is already ready, it will fire the load event.\n    return;\n  }\n\n  // Create the iframe root, and, the overlay root inside it when it is ready.\n  iframeRoot = IframeRoot(document, document.body, {\n    onIframeLoad: function onIframeLoad() {\n      rootDocument = iframeRoot.contentDocument;\n      root = OverlayRoot(rootDocument, rootDocument.body);\n      scheduledRenderFn();\n    },\n  });\n\n  // We have to mount here to ensure `iframeRoot` is set when `onIframeLoad` fires.\n  // This is because onIframeLoad() will be called synchronously\n  // or asynchronously depending on the browser.\n  document.body.appendChild(iframeRoot);\n}\n\n/**\n * Creates the main `div` element for the overlay to render.\n * @returns {void}\n */\nfunction render() {\n  ensureRootExists(function () {\n    const currentFocus = rootDocument.activeElement;\n    let currentFocusId;\n    if (currentFocus.localName === 'button' && currentFocus.id) {\n      currentFocusId = currentFocus.id;\n    }\n\n    utils.removeAllChildren(root);\n\n    if (currentCompileErrorMessage) {\n      currentMode = 'compileError';\n\n      CompileErrorContainer(rootDocument, root, {\n        errorMessage: currentCompileErrorMessage,\n      });\n    } else if (currentRuntimeErrors.length) {\n      currentMode = 'runtimeError';\n\n      RuntimeErrorHeader(rootDocument, root, {\n        currentErrorIndex: currentRuntimeErrorIndex,\n        totalErrors: currentRuntimeErrors.length,\n      });\n      RuntimeErrorContainer(rootDocument, root, {\n        currentError: currentRuntimeErrors[currentRuntimeErrorIndex],\n      });\n      RuntimeErrorFooter(rootDocument, root, {\n        initialFocus: currentFocusId,\n        multiple: currentRuntimeErrors.length > 1,\n        onClickCloseButton: function onClose() {\n          clearRuntimeErrors();\n        },\n        onClickNextButton: function onNext() {\n          if (currentRuntimeErrorIndex === currentRuntimeErrors.length - 1) {\n            return;\n          }\n          currentRuntimeErrorIndex += 1;\n          ensureRootExists(render);\n        },\n        onClickPrevButton: function onPrev() {\n          if (currentRuntimeErrorIndex === 0) {\n            return;\n          }\n          currentRuntimeErrorIndex -= 1;\n          ensureRootExists(render);\n        },\n      });\n    }\n  });\n}\n\n/**\n * Destroys the state of the overlay.\n * @returns {void}\n */\nfunction cleanup() {\n  // Clean up and reset all internal state.\n  document.body.removeChild(iframeRoot);\n  scheduledRenderFn = null;\n  root = null;\n  iframeRoot = null;\n}\n\n/**\n * Clears Webpack compilation errors and dismisses the compile error overlay.\n * @returns {void}\n */\nfunction clearCompileError() {\n  if (!root || currentMode !== 'compileError') {\n    return;\n  }\n\n  currentCompileErrorMessage = '';\n  currentMode = null;\n  cleanup();\n}\n\n/**\n * Clears runtime error records and dismisses the runtime error overlay.\n * @param {boolean} [dismissOverlay] Whether to dismiss the overlay or not.\n * @returns {void}\n */\nfunction clearRuntimeErrors(dismissOverlay) {\n  if (!root || currentMode !== 'runtimeError') {\n    return;\n  }\n\n  currentRuntimeErrorIndex = 0;\n  currentRuntimeErrors = [];\n\n  if (typeof dismissOverlay === 'undefined' || dismissOverlay) {\n    currentMode = null;\n    cleanup();\n  }\n}\n\n/**\n * Shows the compile error overlay with the specific Webpack error message.\n * @param {string} message\n * @returns {void}\n */\nfunction showCompileError(message) {\n  if (!message) {\n    return;\n  }\n\n  currentCompileErrorMessage = message;\n\n  render();\n}\n\n/**\n * Shows the runtime error overlay with the specific error records.\n * @param {Error[]} errors\n * @returns {void}\n */\nfunction showRuntimeErrors(errors) {\n  if (!errors || !errors.length) {\n    return;\n  }\n\n  currentRuntimeErrors = errors;\n\n  render();\n}\n\n/**\n * The debounced version of `showRuntimeErrors` to prevent frequent renders\n * due to rapid firing listeners.\n * @param {Error[]} errors\n * @returns {void}\n */\nconst debouncedShowRuntimeErrors = utils.debounce(showRuntimeErrors, 30);\n\n/**\n * Detects if an error is a Webpack compilation error.\n * @param {Error} error The error of interest.\n * @returns {boolean} If the error is a Webpack compilation error.\n */\nfunction isWebpackCompileError(error) {\n  return /Module [A-z ]+\\(from/.test(error.message) || /Cannot find module/.test(error.message);\n}\n\n/**\n * Handles runtime error contexts captured with EventListeners.\n * Integrates with a runtime error overlay.\n * @param {Error} error A valid error object.\n * @returns {void}\n */\nfunction handleRuntimeError(error) {\n  if (error && !isWebpackCompileError(error) && currentRuntimeErrors.indexOf(error) === -1) {\n    currentRuntimeErrors = currentRuntimeErrors.concat(error);\n  }\n  debouncedShowRuntimeErrors(currentRuntimeErrors);\n}\n\nmodule.exports = Object.freeze({\n  clearCompileError: clearCompileError,\n  clearRuntimeErrors: clearRuntimeErrors,\n  handleRuntimeError: handleRuntimeError,\n  showCompileError: showCompileError,\n  showRuntimeErrors: showRuntimeErrors,\n});\n"
  },
  {
    "path": "overlay/package.json",
    "content": "{\n  \"type\": \"commonjs\"\n}\n"
  },
  {
    "path": "overlay/theme.js",
    "content": "/**\n * @typedef {Object} Theme\n * @property {string} black\n * @property {string} bright-black\n * @property {string} red\n * @property {string} bright-red\n * @property {string} green\n * @property {string} bright-green\n * @property {string} yellow\n * @property {string} bright-yellow\n * @property {string} blue\n * @property {string} bright-blue\n * @property {string} magenta\n * @property {string} bright-magenta\n * @property {string} cyan\n * @property {string} bright-cyan\n * @property {string} white\n * @property {string} bright-white\n * @property {string} lightgrey\n * @property {string} darkgrey\n * @property {string} grey\n * @property {string} dimgrey\n */\n\n/**\n * @type {Theme} theme\n * A collection of colors to be used by the overlay.\n * Partially adopted from Tomorrow Night Bright.\n */\nconst theme = {\n  black: '#000000',\n  'bright-black': '#474747',\n  red: '#D34F56',\n  'bright-red': '#dd787d',\n  green: '#B9C954',\n  'bright-green': '#c9d57b',\n  yellow: '#E6C452',\n  'bright-yellow': '#ecd37f',\n  blue: '#7CA7D8',\n  'bright-blue': '#a3c1e4',\n  magenta: '#C299D6',\n  'bright-magenta': '#d8bde5',\n  cyan: '#73BFB1',\n  'bright-cyan': '#96cfc5',\n  white: '#FFFFFF',\n  'bright-white': '#FFFFFF',\n  background: '#474747',\n  'dark-background': '#343434',\n  selection: 'rgba(234, 234, 234, 0.5)',\n};\n\nmodule.exports = theme;\n"
  },
  {
    "path": "overlay/utils.js",
    "content": "/**\n * Debounce a function to delay invoking until wait (ms) have elapsed since the last invocation.\n * @param {function(...*): *} fn The function to be debounced.\n * @param {number} wait Milliseconds to wait before invoking again.\n * @return {function(...*): void} The debounced function.\n */\nfunction debounce(fn, wait) {\n  /**\n   * A cached setTimeout handler.\n   * @type {number | undefined}\n   */\n  let timer;\n\n  /**\n   * @returns {void}\n   */\n  function debounced() {\n    const context = this;\n    const args = arguments;\n\n    clearTimeout(timer);\n    timer = setTimeout(function () {\n      return fn.apply(context, args);\n    }, wait);\n  }\n\n  return debounced;\n}\n\n/**\n * Prettify a filename from error stacks into the desired format.\n * @param {string} filename The filename to be formatted.\n * @returns {string} The formatted filename.\n */\nfunction formatFilename(filename) {\n  // Strip away protocol and domain for compiled files\n  const htmlMatch = /^https?:\\/\\/(.*)\\/(.*)/.exec(filename);\n  if (htmlMatch && htmlMatch[1] && htmlMatch[2]) {\n    return htmlMatch[2];\n  }\n\n  // Strip everything before the first directory for source files\n  const sourceMatch = /\\/.*?([^./]+[/|\\\\].*)$/.exec(filename);\n  if (sourceMatch && sourceMatch[1]) {\n    return sourceMatch[1].replace(/\\?$/, '');\n  }\n\n  // Unknown filename type, use it as is\n  return filename;\n}\n\n/**\n * Remove all children of an element.\n * @param {HTMLElement} element A valid HTML element.\n * @param {number} [skip] Number of elements to skip removing.\n * @returns {void}\n */\nfunction removeAllChildren(element, skip) {\n  /** @type {Node[]} */\n  const childList = Array.prototype.slice.call(\n    element.childNodes,\n    typeof skip !== 'undefined' ? skip : 0\n  );\n\n  for (let i = 0; i < childList.length; i += 1) {\n    element.removeChild(childList[i]);\n  }\n}\n\nmodule.exports = {\n  debounce: debounce,\n  formatFilename: formatFilename,\n  removeAllChildren: removeAllChildren,\n};\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"@pmmmwh/react-refresh-webpack-plugin\",\n  \"version\": \"0.6.2\",\n  \"description\": \"An **EXPERIMENTAL** Webpack plugin to enable \\\"Fast Refresh\\\" (also previously known as _Hot Reloading_) for React components.\",\n  \"keywords\": [\n    \"react\",\n    \"javascript\",\n    \"webpack\",\n    \"refresh\",\n    \"hmr\",\n    \"hotreload\",\n    \"livereload\",\n    \"live\",\n    \"edit\",\n    \"hot\",\n    \"reload\"\n  ],\n  \"homepage\": \"https://github.com/pmmmwh/react-refresh-webpack-plugin#readme\",\n  \"bugs\": {\n    \"url\": \"https://github.com/pmmmwh/react-refresh-webpack-plugin/issues\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/pmmmwh/react-refresh-webpack-plugin.git\"\n  },\n  \"license\": \"MIT\",\n  \"author\": \"Michael Mok\",\n  \"main\": \"lib/index.js\",\n  \"types\": \"types/lib/index.d.ts\",\n  \"files\": [\n    \"client\",\n    \"lib\",\n    \"loader\",\n    \"options\",\n    \"overlay\",\n    \"sockets\",\n    \"types\",\n    \"umd\"\n  ],\n  \"packageManager\": \"yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610\",\n  \"scripts\": {\n    \"test\": \"run-s -c test:pre \\\"test:exec {@}\\\" test:post --\",\n    \"test:wds-4\": \"cross-env WDS_VERSION=4 yarn test\",\n    \"test:exec\": \"node --experimental-vm-modules scripts/test.js\",\n    \"test:pre\": \"run-s -c test:pre:*\",\n    \"test:pre:0\": \"yarn link\",\n    \"test:pre:1\": \"yarn link @pmmmwh/react-refresh-webpack-plugin\",\n    \"test:post\": \"run-s -c test:post:*\",\n    \"test:post:0\": \"yarn unlink @pmmmwh/react-refresh-webpack-plugin\",\n    \"test:post:1\": \"yarn unlink\",\n    \"lint\": \"eslint --report-unused-disable-directives --ext .js,.jsx .\",\n    \"lint:fix\": \"yarn lint --fix\",\n    \"format\": \"prettier --write \\\"**/*.{js,jsx,ts,tsx,json,md}\\\"\",\n    \"format:check\": \"prettier --check \\\"**/*.{js,jsx,ts,tsx,json,md}\\\"\",\n    \"types:clean\": \"del types\",\n    \"types:compile\": \"tsc\",\n    \"types:prune-private\": \"del \\\"types/*/*\\\" \\\"!types/{lib,loader,options}/{index,types}.d.ts\\\"\",\n    \"generate:client-external\": \"webpack\",\n    \"generate:types\": \"run-s types:clean types:compile types:prune-private \\\"format --log-level=silent\\\"\",\n    \"prepublishOnly\": \"run-p generate:*\"\n  },\n  \"dependencies\": {\n    \"anser\": \"^2.1.1\",\n    \"core-js-pure\": \"^3.23.3\",\n    \"error-stack-parser\": \"^2.0.6\",\n    \"html-entities\": \"^2.1.0\",\n    \"schema-utils\": \"^4.2.0\",\n    \"source-map\": \"^0.7.3\"\n  },\n  \"devDependencies\": {\n    \"@babel/core\": \"^7.24.6\",\n    \"@babel/plugin-transform-modules-commonjs\": \"^7.24.6\",\n    \"@types/cross-spawn\": \"^6.0.6\",\n    \"@types/fs-extra\": \"^11.0.4\",\n    \"@types/jest\": \"^29.5.12\",\n    \"@types/json-schema\": \"^7.0.15\",\n    \"@types/module-alias\": \"^2.0.4\",\n    \"@types/node\": \"^24.10.1\",\n    \"@types/webpack\": \"^5.28.5\",\n    \"babel-loader\": \"^10.0.0\",\n    \"cross-env\": \"^7.0.3\",\n    \"cross-spawn\": \"^7.0.5\",\n    \"del-cli\": \"^6.0.0\",\n    \"eslint\": \"^8.6.0\",\n    \"eslint-config-prettier\": \"^10.1.1\",\n    \"eslint-plugin-prettier\": \"^5.1.3\",\n    \"fs-extra\": \"^11.2.0\",\n    \"get-port\": \"^7.1.0\",\n    \"jest\": \"^29.7.0\",\n    \"jest-environment-jsdom\": \"^29.7.0\",\n    \"jest-environment-node\": \"^29.7.0\",\n    \"jest-junit\": \"^16.0.0\",\n    \"jest-location-mock\": \"^2.0.0\",\n    \"memfs\": \"^4.9.2\",\n    \"module-alias\": \"^2.2.3\",\n    \"nanoid\": \"^3.3.8\",\n    \"npm-run-all2\": \"^7.0.2\",\n    \"prettier\": \"^3.3.0\",\n    \"puppeteer\": \"^24.4.0\",\n    \"react-refresh\": \"^0.18.0\",\n    \"sourcemap-validator\": \"^2.1.0\",\n    \"terser-webpack-plugin\": \"^5.3.10\",\n    \"type-fest\": \"^4.41.0\",\n    \"typescript\": \"~5.9.3\",\n    \"webpack\": \"^5.94.0\",\n    \"webpack-cli\": \"^6.0.1\",\n    \"webpack-dev-server\": \"^5.0.4\",\n    \"webpack-dev-server-v4\": \"npm:webpack-dev-server@^4.8.0\",\n    \"webpack-hot-middleware\": \"^2.26.1\",\n    \"webpack-plugin-serve\": \"^1.6.0\",\n    \"yn\": \"^4.0.0\"\n  },\n  \"peerDependencies\": {\n    \"@types/webpack\": \"5.x\",\n    \"react-refresh\": \">=0.10.0 <1.0.0\",\n    \"sockjs-client\": \"^1.4.0\",\n    \"type-fest\": \">=0.17.0 <6.0.0\",\n    \"webpack\": \"^5.0.0\",\n    \"webpack-dev-server\": \"^4.8.0 || 5.x\",\n    \"webpack-hot-middleware\": \"2.x\",\n    \"webpack-plugin-serve\": \"1.x\"\n  },\n  \"peerDependenciesMeta\": {\n    \"@types/webpack\": {\n      \"optional\": true\n    },\n    \"sockjs-client\": {\n      \"optional\": true\n    },\n    \"type-fest\": {\n      \"optional\": true\n    },\n    \"webpack-dev-server\": {\n      \"optional\": true\n    },\n    \"webpack-hot-middleware\": {\n      \"optional\": true\n    },\n    \"webpack-plugin-serve\": {\n      \"optional\": true\n    }\n  },\n  \"resolutions\": {\n    \"memfs\": \"^4.0.0\",\n    \"rimraf\": \"^5.0.0\",\n    \"type-fest\": \"^4.41.0\"\n  },\n  \"engines\": {\n    \"node\": \">=18.12\"\n  }\n}\n"
  },
  {
    "path": "scripts/test.js",
    "content": "// Setup environment before any code -\n// this makes sure everything coming after will run in the correct env.\nprocess.env.NODE_ENV = 'test';\n\n// Crash on unhandled rejections instead of failing silently.\nprocess.on('unhandledRejection', (reason) => {\n  throw reason;\n});\n\nconst jest = require('jest');\nconst yn = require('yn');\n\nlet argv = process.argv.slice(2);\n\nif (yn(process.env.CI)) {\n  // Use CI mode\n  argv.push('--ci');\n  // Parallelized puppeteer tests have high memory overhead in CI environments.\n  // Fall back to run in series so tests could run faster.\n  argv.push('--runInBand');\n  // Add JUnit reporter\n  argv.push('--reporters=\"default\"');\n  argv.push('--reporters=\"jest-junit\"');\n}\n\nif (yn(process.env.DEBUG)) {\n  argv.push('--verbose');\n}\n\nvoid jest.run(argv);\n"
  },
  {
    "path": "sockets/WDSSocket.js",
    "content": "/**\n * Initializes a socket server for HMR for webpack-dev-server.\n * @param {function(*): void} messageHandler A handler to consume Webpack compilation messages.\n * @returns {void}\n */\nfunction initWDSSocket(messageHandler) {\n  const { default: SockJSClient } = require('webpack-dev-server/client/clients/SockJSClient');\n  const { default: WebSocketClient } = require('webpack-dev-server/client/clients/WebSocketClient');\n  const { client } = require('webpack-dev-server/client/socket');\n\n  /** @type {WebSocket} */\n  let connection;\n  if (client instanceof SockJSClient) {\n    connection = client.sock;\n  } else if (client instanceof WebSocketClient) {\n    connection = client.client;\n  } else {\n    throw new Error('Failed to determine WDS client type');\n  }\n\n  connection.addEventListener('message', function onSocketMessage(message) {\n    messageHandler(JSON.parse(message.data));\n  });\n}\n\nmodule.exports = { init: initWDSSocket };\n"
  },
  {
    "path": "sockets/WHMEventSource.js",
    "content": "/**\n * The hard-coded singleton key for webpack-hot-middleware's client instance.\n *\n * [Ref](https://github.com/webpack-contrib/webpack-hot-middleware/blob/cb29abb9dde435a1ac8e9b19f82d7d36b1093198/client.js#L152)\n */\nconst singletonKey = '__webpack_hot_middleware_reporter__';\n\n/**\n * Initializes a socket server for HMR for webpack-hot-middleware.\n * @param {function(*): void} messageHandler A handler to consume Webpack compilation messages.\n * @returns {void}\n */\nfunction initWHMEventSource(messageHandler) {\n  const client = window[singletonKey];\n\n  client.useCustomOverlay({\n    showProblems: function showProblems(type, data) {\n      const error = {\n        data: data,\n        type: type,\n      };\n\n      messageHandler(error);\n    },\n    clear: function clear() {\n      messageHandler({ type: 'ok' });\n    },\n  });\n}\n\nmodule.exports = { init: initWHMEventSource };\n"
  },
  {
    "path": "sockets/WPSSocket.js",
    "content": "/* global ʎɐɹɔosǝʌɹǝs */\nconst { ClientSocket } = require('webpack-plugin-serve/lib/client/ClientSocket');\n\n/**\n * Initializes a socket server for HMR for webpack-plugin-serve.\n * @param {function(*): void} messageHandler A handler to consume Webpack compilation messages.\n * @returns {void}\n */\nfunction initWPSSocket(messageHandler) {\n  /**\n   * The hard-coded options injection key from webpack-plugin-serve.\n   *\n   * [Ref](https://github.com/shellscape/webpack-plugin-serve/blob/aeb49f14e900802c98df4a4607a76bc67b1cffdf/lib/index.js#L258)\n   * @type {Object | undefined}\n   */\n  let options;\n  try {\n    options = ʎɐɹɔosǝʌɹǝs;\n  } catch (e) {\n    // Bail out because this indicates the plugin is not included\n    return;\n  }\n\n  const { address, client = {}, secure } = options;\n  const protocol = secure ? 'wss' : 'ws';\n  const socket = new ClientSocket(client, protocol + '://' + (client.address || address) + '/wps');\n\n  socket.addEventListener('message', function listener(message) {\n    const { action, data } = JSON.parse(message.data);\n\n    switch (action) {\n      case 'done': {\n        messageHandler({ type: 'ok' });\n        break;\n      }\n      case 'problems': {\n        if (data.errors.length) {\n          messageHandler({ type: 'errors', data: data.errors });\n        } else if (data.warnings.length) {\n          messageHandler({ type: 'warnings', data: data.warnings });\n        }\n        break;\n      }\n      default: {\n        // Do nothing\n      }\n    }\n  });\n}\n\nmodule.exports = { init: initWPSSocket };\n"
  },
  {
    "path": "sockets/package.json",
    "content": "{\n  \"type\": \"commonjs\"\n}\n"
  },
  {
    "path": "test/conformance/ReactRefresh.test.js",
    "content": "/**\n * @jest-environment <rootDir>/conformance/environment\n */\n\nconst getSandbox = require('../helpers/sandbox');\n\n// https://github.com/facebook/metro/blob/c083da2a9465ef53f10ded04bb7c0b748c8b90cb/packages/metro/src/lib/polyfills/__tests__/require-test.js#L1028-L1087\nit('re-runs accepted modules', async () => {\n  const [session] = await getSandbox();\n\n  // Bootstrap test and reload session to not rely on auto-refresh semantics\n  await session.write('index.js', `module.exports = function Noop() { return null; };`);\n  await session.reload();\n\n  await session.write('foo.js', `window.log('init FooV1'); require('./bar');`);\n  await session.write(\n    'bar.js',\n    `window.log('init BarV1'); module.exports = function Bar() { return null; };`\n  );\n\n  session.resetState();\n  await session.patch(\n    'index.js',\n    `require('./foo'); module.exports = function Noop() { return null; };`\n  );\n  expect(session.logs).toStrictEqual(['init FooV1', 'init BarV1']);\n\n  // We only edited Bar, and it accepted.\n  // So we expect it to re-run alone.\n  session.resetState();\n  await session.patch(\n    'bar.js',\n    `window.log('init BarV2'); module.exports = function Bar() { return null; };`\n  );\n  expect(session.logs).toStrictEqual(['init BarV2']);\n\n  // We only edited Bar, and it accepted.\n  // So we expect it to re-run alone.\n  session.resetState();\n  await session.patch(\n    'bar.js',\n    `window.log('init BarV3'); module.exports = function Bar() { return null; };`\n  );\n  expect(session.logs).toStrictEqual(['init BarV3']);\n\n  // TODO:\n  // expect(Refresh.performReactRefresh).toHaveBeenCalled();\n  // expect(Refresh.performFullRefresh).not.toHaveBeenCalled();\n  expect(session.didFullRefresh).toBe(false);\n});\n\n// https://github.com/facebook/metro/blob/c083da2a9465ef53f10ded04bb7c0b748c8b90cb/packages/metro/src/lib/polyfills/__tests__/require-test.js#L1089-L1176\nit('propagates a hot update to closest accepted module', async () => {\n  const [session] = await getSandbox();\n\n  await session.write('index.js', `module.exports = function Noop() { return null; };`);\n  await session.reload();\n\n  await session.write(\n    'foo.js',\n    // Exporting a component marks it as auto-accepting.\n    `window.log('init FooV1'); require('./bar'); module.exports = function Foo() {};`\n  );\n  await session.write('bar.js', `window.log('init BarV1');`);\n\n  session.resetState();\n  await session.patch(\n    'index.js',\n    `require('./foo'); module.exports = function Noop() { return null; };`\n  );\n  expect(session.logs).toStrictEqual(['init FooV1', 'init BarV1']);\n\n  // We edited Bar, but it doesn't accept.\n  // So we expect it to re-run together with Foo which does.\n  session.resetState();\n  await session.patch('bar.js', `window.log('init BarV2');`);\n  expect(session.logs).toStrictEqual([\n    // FIXME: Metro order:\n    // 'init BarV2',\n    // 'init FooV1',\n    'init FooV1',\n    'init BarV2',\n    // Webpack runs in this order because it evaluates modules parent down, not\n    // child up. Parents will re-run child modules in the order that they're\n    // imported from the parent.\n  ]);\n\n  // We edited Bar, but it doesn't accept.\n  // So we expect it to re-run together with Foo which does.\n  session.resetState();\n  await session.patch('bar.js', `window.log('init BarV3');`);\n  expect(session.logs).toStrictEqual([\n    // // FIXME: Metro order:\n    // 'init BarV3',\n    // 'init FooV1',\n    'init FooV1',\n    'init BarV3',\n    // Webpack runs in this order because it evaluates modules parent down, not\n    // child up. Parents will re-run child modules in the order that they're\n    // imported from the parent.\n  ]);\n\n  // We edited Bar so that it accepts itself.\n  // We still re-run Foo because the exports of Bar changed.\n  session.resetState();\n  await session.patch(\n    'bar.js',\n    // Exporting a component marks it as auto-accepting.\n    `window.log('init BarV4'); module.exports = function Bar() {};`\n  );\n  expect(session.logs).toStrictEqual([\n    // // FIXME: Metro order:\n    // 'init BarV4',\n    // 'init FooV1',\n    'init FooV1',\n    'init BarV4',\n    // Webpack runs in this order because it evaluates modules parent down, not\n    // child up. Parents will re-run child modules in the order that they're\n    // imported from the parent.\n  ]);\n\n  // Further edits to Bar don't re-run Foo.\n  session.resetState();\n  await session.patch('bar.js', `window.log('init BarV5'); module.exports = function Bar() {};`);\n  expect(session.logs).toStrictEqual(['init BarV5']);\n\n  // TODO:\n  // expect(Refresh.performReactRefresh).toHaveBeenCalled();\n  // expect(Refresh.performFullRefresh).not.toHaveBeenCalled();\n  expect(session.didFullRefresh).toBe(false);\n});\n\n// https://github.com/facebook/metro/blob/c083da2a9465ef53f10ded04bb7c0b748c8b90cb/packages/metro/src/lib/polyfills/__tests__/require-test.js#L1178-L1346\nit('propagates hot update to all inverse dependencies', async () => {\n  const [session] = await getSandbox();\n\n  await session.write('index.js', `module.exports = function Noop() { return null; };`);\n  await session.reload();\n\n  // This is the module graph:\n  //         MiddleA*\n  //     /              \\\n  // Root* - MiddleB* - Leaf\n  //     \\\n  //        MiddleC\n  //\n  // * - accepts update\n  //\n  // We expect that editing Leaf will propagate to\n  // MiddleA and MiddleB both of which can handle updates.\n\n  await session.write(\n    'root.js',\n    `\n    window.log('init RootV1');\n\n    require('./middleA');\n    require('./middleB');\n    require('./middleC');\n\n    module.exports = function Root() {};\n    `\n  );\n  await session.write(\n    'middleA.js',\n    `window.log('init MiddleAV1'); require('./leaf'); module.exports = function MiddleA() {};`\n  );\n  await session.write(\n    'middleB.js',\n    `window.log('init MiddleBV1'); require('./leaf'); module.exports = function MiddleB() {};\n    `\n  );\n  // This one doesn't import leaf and also doesn't export a component,\n  // so, it doesn't accept its own updates.\n  await session.write('middleC.js', `window.log('init MiddleCV1'); module.exports = {};`);\n  // Doesn't accept its own updates; they will propagate.\n  await session.write('leaf.js', `window.log('init LeafV1'); module.exports = {};`);\n\n  session.resetState();\n  await session.patch(\n    'index.js',\n    `require('./root'); module.exports = function Noop() { return null; };`\n  );\n  expect(session.logs).toStrictEqual([\n    'init RootV1',\n    'init MiddleAV1',\n    'init LeafV1',\n    'init MiddleBV1',\n    'init MiddleCV1',\n  ]);\n\n  // We edited Leaf, but it doesn't accept.\n  // So we expect it to re-run together with MiddleA and MiddleB which do.\n  session.resetState();\n  await session.patch('leaf.js', `window.log('init LeafV2'); module.exports = {};`);\n  expect(session.logs).toStrictEqual(['init MiddleAV1', 'init LeafV2', 'init MiddleBV1']);\n\n  // Let's try the same one more time.\n  session.resetState();\n  await session.patch('leaf.js', `window.log('init LeafV3'); module.exports = {};`);\n  expect(session.logs).toStrictEqual(['init MiddleAV1', 'init LeafV3', 'init MiddleBV1']);\n\n  // Now edit MiddleB. It should accept and re-run alone.\n  session.resetState();\n  await session.patch(\n    'middleB.js',\n    `window.log('init MiddleBV2'); require('./leaf'); module.exports = function MiddleB() {};\n    `\n  );\n  expect(session.logs).toStrictEqual(['init MiddleBV2']);\n\n  // Finally, edit MiddleC. It didn't accept so it should bubble to Root.\n  session.resetState();\n  await session.patch('middleC.js', `window.log('init MiddleCV2'); module.exports = {};`);\n  expect(session.logs).toStrictEqual(['init RootV1', 'init MiddleCV2']);\n\n  // TODO:\n  // expect(Refresh.performReactRefresh).toHaveBeenCalled()\n  // expect(Refresh.performFullRefresh).not.toHaveBeenCalled()\n  expect(session.didFullRefresh).toBe(false);\n});\n\n// https://github.com/facebook/metro/blob/c083da2a9465ef53f10ded04bb7c0b748c8b90cb/packages/metro/src/lib/polyfills/__tests__/require-test.js#L1348-L1445\nit('runs dependencies before dependents', async () => {\n  const [session] = await getSandbox();\n\n  await session.write('index.js', `module.exports = function Noop() { return null; };`);\n  await session.reload();\n\n  // This is the module graph:\n  //        MiddleA* ----\n  //     /      |         \\\n  // Root    MiddleB ----- Leaf\n  //\n  // * - refresh boundary (exports a component)\n  //\n  // We expect that editing Leaf will propagate to\n  // MiddleA which is a Refresh Boundary.\n  //\n  // However, it's essential that code for MiddleB executes *before* MiddleA on updates.\n\n  await session.write(\n    'root.js',\n    `window.log('init RootV1'); require('./middleA'); module.exports = function Root() {};`\n  );\n  await session.write(\n    'middleA.js',\n    `window.log('init MiddleAV1');\n     const Leaf = require('./leaf');\n     const MiddleB = require('./middleB');\n     module.exports = function MiddleA() {\n       return Leaf * MiddleB;\n     };`\n  );\n  await session.write(\n    'middleB.js',\n    `window.log('init MiddleBV1'); const Leaf = require('./leaf'); module.exports = Leaf;`\n  );\n  await session.write(\n    'leaf.js',\n    // Doesn't accept its own updates; they will propagate.\n    `window.log('init LeafV1'); module.exports = 2;`\n  );\n\n  session.resetState();\n  await session.patch(\n    'index.js',\n    `require('./root'); module.exports = function Noop() { return null; };`\n  );\n  expect(session.logs).toStrictEqual([\n    'init RootV1',\n    'init MiddleAV1',\n    'init LeafV1',\n    'init MiddleBV1',\n  ]);\n\n  session.resetState();\n  await session.patch('leaf.js', `window.log('init LeafV2'); module.exports = 3;`);\n  expect(session.logs).toStrictEqual(['init MiddleAV1', 'init LeafV2', 'init MiddleBV1']);\n\n  // TODO:\n  // expect(Refresh.performReactRefresh).toHaveBeenCalled()\n  // expect(Refresh.performFullRefresh).not.toHaveBeenCalled()\n  expect(session.didFullRefresh).toBe(false);\n});\n\n// https://github.com/facebook/metro/blob/c083da2a9465ef53f10ded04bb7c0b748c8b90cb/packages/metro/src/lib/polyfills/__tests__/require-test.js#L1447-L1537\nit('provides fresh value for module.exports in parents', async () => {\n  const [session] = await getSandbox();\n\n  await session.write('index.js', `module.exports = function Noop() { return null; };`);\n  await session.reload();\n\n  await session.write(\n    'foo.js',\n    // This module accepts itself\n    `const BarValue = require('./bar');\n     window.log('init FooV1 with BarValue = ' + BarValue);\n     module.exports = function Foo() {};`\n  );\n  await session.write(\n    'bar.js',\n    // This module will propagate to the parent\n    `window.log('init BarV1'); module.exports = 1;`\n  );\n\n  session.resetState();\n  await session.patch(\n    'index.js',\n    `require('./foo'); module.exports = function Noop() { return null; };`\n  );\n  expect(session.logs).toStrictEqual(['init BarV1', 'init FooV1 with BarValue = 1']);\n\n  // We edited Bar, but it doesn't accept.\n  // So we expect it to re-run together with Foo which does.\n  session.resetState();\n  await session.patch('bar.js', `window.log('init BarV2'); module.exports = 2;`);\n  expect(session.logs).toStrictEqual(['init BarV2', 'init FooV1 with BarValue = 2']);\n\n  // Let's try this again.\n  session.resetState();\n  await session.patch('bar.js', `window.log('init BarV3'); module.exports = 3;`);\n  expect(session.logs).toStrictEqual(['init BarV3', 'init FooV1 with BarValue = 3']);\n\n  // Now let's edit the parent which accepts itself\n  session.resetState();\n  await session.patch(\n    'foo.js',\n    `const BarValue = require('./bar');\n     window.log('init FooV2 with BarValue = ' + BarValue);\n     module.exports = function Foo() {};`\n  );\n  expect(session.logs).toStrictEqual(['init FooV2 with BarValue = 3']);\n\n  // Verify editing the child didn't break after parent update.\n  session.resetState();\n  await session.patch('bar.js', `window.log('init BarV4'); module.exports = 4;`);\n  expect(session.logs).toStrictEqual(['init BarV4', 'init FooV2 with BarValue = 4']);\n\n  // TODO:\n  // expect(Refresh.performReactRefresh).toHaveBeenCalled()\n  // expect(Refresh.performFullRefresh).not.toHaveBeenCalled()\n  expect(session.didFullRefresh).toBe(false);\n});\n\n// https://github.com/facebook/metro/blob/c083da2a9465ef53f10ded04bb7c0b748c8b90cb/packages/metro/src/lib/polyfills/__tests__/require-test.js#L1539-L1629\nit('provides fresh value for exports.* in parents', async () => {\n  const [session] = await getSandbox();\n\n  await session.write('index.js', `module.exports = function Noop() { return null; };`);\n  await session.reload();\n\n  await session.write(\n    'foo.js',\n    // This module accepts itself\n    `\n    const BarValue = require('./bar').value;\n    window.log('init FooV1 with BarValue = ' + BarValue);\n    exports.Foo = function Foo() {};`\n  );\n  await session.write(\n    'bar.js',\n    // This module will propagate to the parent\n    `window.log('init BarV1'); exports.value = 1;`\n  );\n\n  session.resetState();\n  await session.patch(\n    'index.js',\n    `require('./foo'); module.exports = function Noop() { return null; };`\n  );\n  expect(session.logs).toStrictEqual(['init BarV1', 'init FooV1 with BarValue = 1']);\n\n  // We edited Bar, but it doesn't accept.\n  // So we expect it to re-run together with Foo which does.\n  session.resetState();\n  await session.patch('bar.js', `window.log('init BarV2'); exports.value = 2;`);\n  expect(session.logs).toStrictEqual(['init BarV2', 'init FooV1 with BarValue = 2']);\n\n  // Let's try this again\n  session.resetState();\n  await session.patch('bar.js', `window.log('init BarV3'); exports.value = 3;`);\n  expect(session.logs).toStrictEqual(['init BarV3', 'init FooV1 with BarValue = 3']);\n\n  // Now let's edit the parent which accepts itself\n  session.resetState();\n  await session.patch(\n    'foo.js',\n    `\n    const BarValue = require('./bar').value;\n    window.log('init FooV2 with BarValue = ' + BarValue);\n    exports.Foo = function Foo() {};`\n  );\n  expect(session.logs).toStrictEqual(['init FooV2 with BarValue = 3']);\n\n  // Verify editing the child didn't break after parent update\n  session.resetState();\n  await session.patch('bar.js', `window.log('init BarV4'); exports.value = 4;`);\n  expect(session.logs).toStrictEqual(['init BarV4', 'init FooV2 with BarValue = 4']);\n\n  // TODO:\n  // expect(Refresh.performReactRefresh).toHaveBeenCalled()\n  // expect(Refresh.performFullRefresh).not.toHaveBeenCalled()\n  expect(session.didFullRefresh).toBe(false);\n});\n\n// https://github.com/facebook/metro/blob/c083da2a9465ef53f10ded04bb7c0b748c8b90cb/packages/metro/src/lib/polyfills/__tests__/require-test.js#L1631-L1727\nit('provides fresh value for ES6 named import in parents', async () => {\n  const [session] = await getSandbox({ esModule: true });\n\n  await session.write('root.js', `export default function Noop() { return null; };`);\n  await session.write('index.js', `import Root from './root.js'; Root();`);\n  await session.reload();\n\n  await session.write(\n    'foo.js',\n    // This module accepts itself\n    `\n    import { value as BarValue } from './bar.js';\n    window.log('init FooV1 with BarValue = ' + BarValue);\n    export function Foo() {};`\n  );\n  await session.write(\n    'bar.js',\n    // This module will propagate to the parent\n    `window.log('init BarV1'); export const value = 1;`\n  );\n\n  session.resetState();\n  await session.patch(\n    'root.js',\n    `import './foo.js'; export default function Noop() { return null; };`\n  );\n  expect(session.logs).toStrictEqual(['init BarV1', 'init FooV1 with BarValue = 1']);\n\n  // We edited Bar, but it doesn't accept.\n  // So we expect it to re-run together with Foo which does.\n  session.resetState();\n  await session.patch('bar.js', `window.log('init BarV2'); export const value = 2;`);\n  expect(session.logs).toStrictEqual(['init BarV2', 'init FooV1 with BarValue = 2']);\n\n  // Let's try this again\n  session.resetState();\n  await session.patch('bar.js', `window.log('init BarV3'); export const value = 3;`);\n  expect(session.logs).toStrictEqual(['init BarV3', 'init FooV1 with BarValue = 3']);\n\n  // Now let's edit the parent which accepts itself\n  session.resetState();\n  await session.patch(\n    'foo.js',\n    `\n    import { value as BarValue } from './bar.js';\n    window.log('init FooV2 with BarValue = ' + BarValue);\n    export function Foo() {};`\n  );\n  expect(session.logs).toStrictEqual(['init FooV2 with BarValue = 3']);\n\n  // Verify editing the child didn't break after parent update\n  session.resetState();\n  await session.patch('bar.js', `window.log('init BarV4'); export const value = 4;`);\n  expect(session.logs).toStrictEqual(['init BarV4', 'init FooV2 with BarValue = 4']);\n\n  // TODO:\n  // expect(Refresh.performReactRefresh).toHaveBeenCalled()\n  // expect(Refresh.performFullRefresh).not.toHaveBeenCalled()\n  expect(session.didFullRefresh).toBe(false);\n});\n\n// https://github.com/facebook/metro/blob/c083da2a9465ef53f10ded04bb7c0b748c8b90cb/packages/metro/src/lib/polyfills/__tests__/require-test.js#L1729-L1825\nit('provides fresh value for ES6 default import in parents', async () => {\n  const [session] = await getSandbox({ esModule: true });\n\n  await session.write('root.js', `export default function Noop() { return null; };`);\n  await session.write('index.js', `import Root from './root.js'; Root();`);\n  await session.reload();\n\n  await session.write(\n    'foo.js',\n    // This module accepts itself\n    `\n    import BarValue from './bar.js';\n    window.log('init FooV1 with BarValue = ' + BarValue);\n    export default function Foo() {};`\n  );\n  await session.write(\n    'bar.js',\n    // This module will propagate to the parent\n    `window.log('init BarV1'); export default 1;`\n  );\n\n  session.resetState();\n  await session.patch(\n    'root.js',\n    `import './foo.js'; export default function Noop() { return null; };`\n  );\n  expect(session.logs).toStrictEqual(['init BarV1', 'init FooV1 with BarValue = 1']);\n\n  // We edited Bar, but it doesn't accept.\n  // So we expect it to re-run together with Foo which does.\n  session.resetState();\n  await session.patch('bar.js', `window.log('init BarV2'); export default 2;`);\n  expect(session.logs).toStrictEqual(['init BarV2', 'init FooV1 with BarValue = 2']);\n\n  // Let's try this again\n  session.resetState();\n  await session.patch('bar.js', `window.log('init BarV3'); export default 3;`);\n  expect(session.logs).toStrictEqual(['init BarV3', 'init FooV1 with BarValue = 3']);\n\n  // Now let's edit the parent which accepts itself\n  session.resetState();\n  await session.patch(\n    'foo.js',\n    `\n    import BarValue from './bar.js';\n    window.log('init FooV2 with BarValue = ' + BarValue);\n    export default function Foo() {};`\n  );\n  expect(session.logs).toStrictEqual(['init FooV2 with BarValue = 3']);\n\n  // Verify editing the child didn't break after parent update\n  session.resetState();\n  await session.patch('bar.js', `window.log('init BarV4'); export default 4;`);\n  expect(session.logs).toStrictEqual(['init BarV4', 'init FooV2 with BarValue = 4']);\n\n  // TODO:\n  // expect(Refresh.performReactRefresh).toHaveBeenCalled()\n  // expect(Refresh.performFullRefresh).not.toHaveBeenCalled()\n  expect(session.didFullRefresh).toBe(false);\n});\n\n// Currently, webpack does not stop propagation after errors,\n// but rather stops execution in parent after the errored module.\n// https://github.com/facebook/metro/blob/c083da2a9465ef53f10ded04bb7c0b748c8b90cb/packages/metro/src/lib/polyfills/__tests__/require-test.js#L1827-L1938\nit('stops execution after module-level errors', async () => {\n  const [session] = await getSandbox();\n\n  await session.write('index.js', `module.exports = function Noop() { return null; };`);\n  await session.reload();\n\n  await session.write(\n    'foo.js',\n    `const Bar = require('./bar');\n     window.log('init FooV1');\n     module.exports = function Foo() {};`\n  );\n  await session.write(\n    'bar.js',\n    // This module normally propagates to the parent.\n    `module.exports = 'V1'; window.log('init BarV1');`\n  );\n\n  session.resetState();\n  await session.patch(\n    'index.js',\n    `require('./foo'); module.exports = function Noop() { return null; };`\n  );\n  expect(session.logs).toStrictEqual(['init BarV1', 'init FooV1']);\n  expect(session.errors).toHaveLength(0);\n\n  // We only edited Bar.\n  // Normally it would propagate to the parent.\n  // But the error should stop the execution early.\n  session.resetState();\n  await session.patch(\n    'bar.js',\n    `window.log('init BarV2'); module.exports = 'V2'; throw new Error('init error during BarV2');`\n  );\n  expect(session.logs).toStrictEqual(['init BarV2']);\n  expect(session.errors).toHaveLength(1);\n  expect(session.errors[0]).toStrictEqual('init error during BarV2');\n\n  // Let's make another error.\n  session.resetState();\n  await session.patch(\n    'bar.js',\n    `window.log('init BarV3'); throw new Error('init error during BarV3');`\n  );\n  expect(session.logs).toStrictEqual(['init BarV3']);\n  expect(session.errors).toHaveLength(1);\n  expect(session.errors[0]).toStrictEqual('init error during BarV3');\n\n  // Finally, let's fix the code.\n  session.resetState();\n  await session.patch('bar.js', `window.log('init BarV4'); module.exports = 'V4';`);\n  expect(session.logs).toStrictEqual(['init BarV4', 'init FooV1']);\n  expect(session.errors).toHaveLength(0);\n\n  // TODO:\n  // expect(Refresh.performReactRefresh).toHaveBeenCalled()\n  // expect(Refresh.performFullRefresh).not.toHaveBeenCalled()\n  expect(session.didFullRefresh).toBe(false);\n});\n\n// https://github.com/facebook/metro/blob/c083da2a9465ef53f10ded04bb7c0b748c8b90cb/packages/metro/src/lib/polyfills/__tests__/require-test.js#L1940-L2049\nit('can continue hot updates after module-level errors with module.exports', async () => {\n  const [session] = await getSandbox();\n\n  await session.write('index.js', `module.exports = function Noop() { return null; };`);\n  await session.reload();\n\n  await session.write('foo.js', `require('./bar'); window.log('init FooV1');`);\n  await session.write(\n    'bar.js',\n    // This module accepts itself\n    `window.log('init BarV1'); module.exports = function Bar() {};`\n  );\n\n  session.resetState();\n  await session.patch(\n    'index.js',\n    `require('./foo'); module.exports = function Noop() { return null; };`\n  );\n  expect(session.logs).toStrictEqual(['init BarV1', 'init FooV1']);\n  expect(session.errors).toHaveLength(0);\n\n  // We only edited Bar, and it accepted.\n  // So we expect it to re-run alone.\n  session.resetState();\n  await session.patch(\n    'bar.js',\n    `window.log('init BarV2'); module.exports = function Bar() {}; throw new Error('init error during BarV2');`\n  );\n  expect(session.logs).toStrictEqual(['init BarV2']);\n  expect(session.errors).toHaveLength(1);\n  expect(session.errors[0]).toBe('init error during BarV2');\n\n  // Let's fix the code.\n  session.resetState();\n  await session.patch('bar.js', `window.log('init BarV4'); module.exports = function Bar() {};`);\n  expect(session.logs).toStrictEqual(['init BarV4']);\n  expect(session.errors).toHaveLength(0);\n\n  // TODO:\n  // expect(Refresh.performReactRefresh).toHaveBeenCalled()\n  // expect(Refresh.performFullRefresh).not.toHaveBeenCalled()\n  expect(session.didFullRefresh).toBe(false);\n});\n\n// https://github.com/facebook/metro/blob/c083da2a9465ef53f10ded04bb7c0b748c8b90cb/packages/metro/src/lib/polyfills/__tests__/require-test.js#L2051-L2162\nit('can continue hot updates after module-level errors with ES6 exports', async () => {\n  const [session] = await getSandbox({ esModule: true });\n\n  await session.write('root.js', `export default function Noop() { return null; };`);\n  await session.write('index.js', `import Root from './root.js'; Root();`);\n  await session.reload();\n\n  await session.write('foo.js', `import Bar from './bar.js'; Bar(); window.log('init FooV1');`);\n  await session.write(\n    'bar.js',\n    // This module accepts itself\n    `window.log('init BarV1'); export default function Bar() {};`\n  );\n\n  session.resetState();\n  await session.patch(\n    'root.js',\n    `import './foo.js'; export default function Noop() { return null; };`\n  );\n  expect(session.logs).toStrictEqual(['init BarV1', 'init FooV1']);\n  expect(session.errors).toHaveLength(0);\n\n  // We only edited Bar, and it accepted.\n  // So we expect it to re-run alone.\n  session.resetState();\n  await session.patch(\n    'bar.js',\n    `window.log('init BarV2'); export default function Bar() {}; throw new Error('init error during BarV2');`\n  );\n  expect(session.logs).toStrictEqual(['init BarV2']);\n  expect(session.errors).toHaveLength(1);\n  expect(session.errors[0]).toBe('init error during BarV2');\n\n  // Let's fix the code.\n  session.resetState();\n  await session.patch('bar.js', `window.log('init BarV3'); export default function Bar() {};`);\n  expect(session.logs).toStrictEqual(['init BarV3']);\n  expect(session.errors).toHaveLength(0);\n\n  // TODO:\n  // expect(Refresh.performReactRefresh).toHaveBeenCalled()\n  // expect(Refresh.performFullRefresh).not.toHaveBeenCalled()\n  expect(session.didFullRefresh).toBe(false);\n});\n\n// https://github.com/facebook/metro/blob/c083da2a9465ef53f10ded04bb7c0b748c8b90cb/packages/metro/src/lib/polyfills/__tests__/require-test.js#L2164-L2272\nit('does not accumulate stale exports over time', async () => {\n  const [session] = await getSandbox();\n\n  await session.write('index.js', `module.exports = function Noop() { return null; };`);\n  await session.reload();\n\n  await session.write(\n    'foo.js',\n    // This module accepts itself\n    `const BarExports = require('./bar');\n     window.log('init FooV1 with BarExports = ' + JSON.stringify(BarExports));\n     module.exports = function Foo() {};`\n  );\n  await session.write(\n    'bar.js',\n    // This module will propagate to the parent\n    `window.log('init BarV1'); exports.a = 1; exports.b = 2;`\n  );\n\n  session.resetState();\n  await session.patch(\n    'index.js',\n    `require('./foo'); module.exports = function Noop() { return null; };`\n  );\n  expect(session.logs).toStrictEqual(['init BarV1', 'init FooV1 with BarExports = {\"a\":1,\"b\":2}']);\n\n  session.resetState();\n  await session.patch(\n    'bar.js',\n    // These are completely different exports\n    `window.log('init BarV2'); exports.c = 3; exports.d = 4;`\n  );\n  // Make sure we don't see {a, b} anymore.\n  expect(session.logs).toStrictEqual(['init BarV2', 'init FooV1 with BarExports = {\"c\":3,\"d\":4}']);\n\n  // Also edit the parent and verify the same again\n  session.resetState();\n  await session.patch(\n    'foo.js',\n    `const BarExports = require('./bar');\n     window.log('init FooV2 with BarExports = ' + JSON.stringify(BarExports));\n     module.exports = function Foo() {};`\n  );\n  expect(session.logs).toStrictEqual(['init FooV2 with BarExports = {\"c\":3,\"d\":4}']);\n\n  // Temporarily crash the child.\n  session.resetState();\n  await session.patch('bar.js', `throw new Error('oh no');`);\n  expect(session.logs).toStrictEqual([]);\n\n  // Try one last time to edit the child.\n  session.resetState();\n  await session.patch(\n    'bar.js',\n    // These are completely different exports\n    `window.log('init BarV3'); exports.e = 5; exports.f = 6;`\n  );\n  expect(session.logs).toStrictEqual(['init BarV3', 'init FooV2 with BarExports = {\"e\":5,\"f\":6}']);\n\n  // TODO:\n  // expect(Refresh.performReactRefresh).toHaveBeenCalled()\n  // expect(Refresh.performFullRefresh).not.toHaveBeenCalled()\n  expect(session.didFullRefresh).toBe(false);\n});\n\n// https://github.com/facebook/metro/blob/c083da2a9465ef53f10ded04bb7c0b748c8b90cb/packages/metro/src/lib/polyfills/__tests__/require-test.js#L2274-L2318\nit('bails out if update bubbles to the root via the only path', async () => {\n  const [session] = await getSandbox();\n\n  await session.write('index.js', `module.exports = () => null;`);\n  await session.reload();\n\n  await session.write('foo.js', `window.log('init FooV1'); require('./bar');`);\n  await session.write('bar.js', `window.log('init BarV1');`);\n\n  session.resetState();\n  await session.patch('index.js', `require('./foo'); module.exports = () => null;`);\n  expect(session.logs).toStrictEqual(['init FooV1', 'init BarV1']);\n\n  // Because root will not except,\n  // we need to reload the session to make sure the app is in an updated state.\n  await session.reload();\n\n  // Neither Bar nor Foo accepted, so update reached the root.\n  session.resetState();\n  await session.patch(\n    'bar.js',\n    `if (typeof window !== 'undefined' && window.localStorage) {\n      window.localStorage.setItem('init', 'init BarV2');\n    }`\n  );\n  await expect(session.evaluate(() => window.localStorage.getItem('init'))).resolves.toEqual(\n    'init BarV2'\n  );\n\n  // Expect full refresh.\n  // TODO:\n  // expect(Refresh.performReactRefresh).not.toHaveBeenCalled()\n  // expect(Refresh.performFullRefresh).toHaveBeenCalled()\n  expect(session.didFullRefresh).toBe(true);\n});\n\n// https://github.com/facebook/metro/blob/c083da2a9465ef53f10ded04bb7c0b748c8b90cb/packages/metro/src/lib/polyfills/__tests__/require-test.js#L2320-L2410\nit('bails out if the update bubbles to the root via one of the paths', async () => {\n  const [session] = await getSandbox();\n\n  await session.write('index.js', `module.exports = () => null;`);\n  await session.reload();\n\n  await session.write('foo.js', `window.log('init FooV1'); require('./bar'); require('./baz');`);\n  await session.write(\n    'bar.js',\n    // This module accepts itself\n    `window.log('init BarV1'); require('./qux'); module.exports = function Bar() {};`\n  );\n  await session.write(\n    'baz.js',\n    // This one doesn't accept itself,\n    // causing updates to Qux to bubble through the root.\n    `window.log('init BazV1'); require('./qux');`\n  );\n  await session.write(\n    'qux.js',\n    // Doesn't accept itself, and only one its parent path accepts.\n    `window.log('init QuxV1');`\n  );\n\n  session.resetState();\n  await session.patch('index.js', `require('./foo'); module.exports = () => null;`);\n  expect(session.logs).toStrictEqual(['init FooV1', 'init BarV1', 'init QuxV1', 'init BazV1']);\n\n  // Because root will not except,\n  // we need to reload the session to make sure the app is in an updated state.\n  await session.reload();\n\n  // Edit Bar. It should self-accept.\n  session.resetState();\n  await session.patch(\n    'bar.js',\n    `window.log('init BarV2'); require('./qux'); module.exports = function Bar() {};`\n  );\n  expect(session.logs).toStrictEqual(['init BarV2']);\n\n  // TODO:\n  // expect(Refresh.performFullRefresh).not.toHaveBeenCalled();\n  expect(session.didFullRefresh).toBe(false);\n\n  // Edit Qux. It should bubble. Baz accepts the update, Bar won't.\n  // So this update should bubble through the root.\n  session.resetState();\n  await session.patch(\n    'qux.js',\n    `if (typeof window !== 'undefined' && window.localStorage) {\n      window.localStorage.setItem('init', 'init QuxV2');\n    }`\n  );\n  await expect(session.evaluate(() => window.localStorage.getItem('init'))).resolves.toEqual(\n    'init QuxV2'\n  );\n\n  // Expect full refresh.\n  // TODO:\n  // expect(Refresh.performReactRefresh).not.toHaveBeenCalled()\n  // expect(Refresh.performFullRefresh).toHaveBeenCalled()\n  expect(session.didFullRefresh).toBe(true);\n});\n\n// https://github.com/facebook/metro/blob/c083da2a9465ef53f10ded04bb7c0b748c8b90cb/packages/metro/src/lib/polyfills/__tests__/require-test.js#L2412-L2511\nit('propagates a module that stops accepting in next version', async () => {\n  const [session] = await getSandbox();\n\n  await session.write('index.js', `module.exports = () => null;`);\n  await session.reload();\n\n  // Accept in parent\n  await session.write(\n    'foo.js',\n    `window.log('init FooV1'); require('./bar'); module.exports = function Foo() {};`\n  );\n  // Accept in child\n  await session.write('bar.js', `window.log('init BarV1'); module.exports = function Bar() {};`);\n\n  await session.patch('index.js', `require('./foo'); module.exports = () => null;`);\n  expect(session.logs).toStrictEqual(['init FooV1', 'init BarV1']);\n\n  // Because root will not except,\n  // we need to reload the session to make sure the app is in an updated state.\n  await session.reload();\n\n  // Verify the child can accept itself\n  session.resetState();\n  await session.patch('bar.js', `window.log('init BarV1.1'); module.exports = function Bar() {};`);\n  expect(session.logs).toStrictEqual(['init BarV1.1']);\n\n  // Now let's change the child to *not* accept itself.\n  // We'll expect that now the parent will handle the evaluation.\n  session.resetState();\n  await session.patch('bar.js', `window.log('init BarV2');`);\n  // We re-run Bar and expect to stop there.\n  // However, it didn't export a component, so we go higher.\n  // We stop at Foo which currently _does_ export a component.\n  expect(session.logs).toStrictEqual(\n    // Bar is evaluated twice:\n    // 1. To invalidate itself once it realizes it's no longer acceptable.\n    // 2. As a child of Foo re-evaluating.\n    ['init BarV2', 'init FooV1', 'init BarV2']\n  );\n\n  // Change it back so that the child accepts itself.\n  session.resetState();\n  await session.patch('bar.js', `window.log('init BarV2'); module.exports = function Bar() {};`);\n  // Since the export list changed, we have to re-run both the parent and the child.\n  expect(session.logs).toStrictEqual(['init FooV1', 'init BarV2']);\n\n  // TODO:\n  // expect(Refresh.performReactRefresh).toHaveBeenCalled();\n  // expect(Refresh.performFullRefresh).not.toHaveBeenCalled();\n  expect(session.didFullRefresh).toBe(false);\n\n  // Editing the child alone now doesn't reevaluate the parent.\n  session.resetState();\n  await session.patch('bar.js', `window.log('init BarV3'); module.exports = function Bar() {};`);\n  expect(session.logs).toStrictEqual(['init BarV3']);\n\n  // Finally, edit the parent in a way that changes the export.\n  // It would still be accepted on its own -\n  // but it's incompatible with the past version which didn't have two exports.\n  await session.evaluate(() => window.localStorage.setItem('init', ''));\n  await session.patch(\n    'foo.js',\n    `\n    if (typeof window !== 'undefined' && window.localStorage) {\n      window.localStorage.setItem('init', 'init FooV2');\n    }\n    exports.Foo = function Foo() {};\n    exports.FooFoo = function FooFoo() {};`\n  );\n\n  // Check that we attempted to evaluate, but had to fall back to full refresh.\n  await expect(session.evaluate(() => window.localStorage.getItem('init'))).resolves.toEqual(\n    'init FooV2'\n  );\n\n  // TODO:\n  // expect(Refresh.performFullRefresh).toHaveBeenCalled();\n  // expect(Refresh.performReactRefresh).not.toHaveBeenCalled();\n  expect(session.didFullRefresh).toBe(true);\n});\n\n// https://github.com/facebook/metro/blob/c083da2a9465ef53f10ded04bb7c0b748c8b90cb/packages/metro/src/lib/polyfills/__tests__/require-test.js#L2513-L2562\nit('can replace a module before it is loaded', async () => {\n  const [session] = await getSandbox();\n\n  await session.write('index.js', `module.exports = function Noop() { return null; };`);\n  await session.reload();\n\n  await session.write(\n    'foo.js',\n    `window.log('init FooV1'); exports.loadBar = function () { require('./bar'); };`\n  );\n  await session.write('bar.js', `window.log('init BarV1');`);\n\n  await session.patch(\n    'index.js',\n    `require('./foo'); module.exports = function Noop() { return null; };`\n  );\n  expect(session.logs).toStrictEqual(['init FooV1']);\n\n  // Replace Bar before it is loaded.\n  session.resetState();\n  await session.patch('bar.js', `window.log('init BarV2');`);\n  expect(session.logs).toStrictEqual([]);\n\n  // Now force Bar to load. It should use the latest version.\n  await session.patch(\n    'index.js',\n    `const { loadBar } = require('./foo'); loadBar(); module.exports = function Noop() { return null; };`\n  );\n  expect(session.logs).toStrictEqual(['init BarV2']);\n\n  // TODO:\n  // expect(Refresh.performReactRefresh).toHaveBeenCalled()\n  // expect(Refresh.performFullRefresh).not.toHaveBeenCalled()\n  expect(session.didFullRefresh).toBe(false);\n});\n"
  },
  {
    "path": "test/conformance/environment.js",
    "content": "const puppeteer = require('puppeteer');\nconst TestEnvironment = require('../jest-environment');\n\nclass SandboxEnvironment extends TestEnvironment {\n  async setup() {\n    await super.setup();\n\n    const wsEndpoint = process.env.PUPPETEER_WS_ENDPOINT;\n    if (!wsEndpoint) {\n      throw new Error('Puppeteer wsEndpoint not found!');\n    }\n\n    this.global.browser = await puppeteer.connect({\n      browserWSEndpoint: wsEndpoint,\n    });\n  }\n\n  async teardown() {\n    await super.teardown();\n\n    if (this.global.browser) {\n      await this.global.browser.disconnect();\n    }\n  }\n}\n\nmodule.exports = SandboxEnvironment;\n"
  },
  {
    "path": "test/helpers/compilation/fixtures/source-map-loader.js",
    "content": "module.exports = function sourceMapLoader(source) {\n  const callback = this.async();\n  callback(null, source, this.query.sourceMap);\n};\n"
  },
  {
    "path": "test/helpers/compilation/index.js",
    "content": "const path = require('path');\nconst { createFsFromVolume, Volume } = require('memfs');\nconst webpack = require('webpack');\nconst normalizeErrors = require('./normalizeErrors');\n\nconst BUNDLE_FILENAME = 'main';\nconst CONTEXT_PATH = path.join(__dirname, '../..', 'loader/fixtures');\nconst OUTPUT_PATH = path.join(__dirname, 'dist');\n\n/**\n * @typedef {Object} CompilationModule\n * @property {string} execution\n * @property {string} parsed\n * @property {string} [sourceMap]\n */\n\n/**\n * @typedef {Object} CompilationSession\n * @property {*[]} errors\n * @property {*[]} warnings\n * @property {CompilationModule} module\n */\n\n/**\n * Gets a Webpack compiler instance to test loader operations.\n * @param {string} subContext\n * @param {Object} [options]\n * @param {boolean | string} [options.devtool]\n * @param {import('../../../loader/types').ReactRefreshLoaderOptions} [options.loaderOptions]\n * @param {*} [options.prevSourceMap]\n * @returns {Promise<CompilationSession>}\n */\nasync function getCompilation(subContext, options = {}) {\n  const compiler = webpack({\n    mode: 'development',\n    cache: false,\n    context: path.join(CONTEXT_PATH, subContext),\n    devtool: options.devtool || false,\n    entry: {\n      [BUNDLE_FILENAME]: './index.js',\n    },\n    output: {\n      filename: '[name].js',\n      hashFunction: 'xxhash64',\n      path: OUTPUT_PATH,\n    },\n    module: {\n      rules: [\n        {\n          exclude: /node_modules/,\n          test: /\\.js$/,\n          use: [\n            {\n              loader: require.resolve('@pmmmwh/react-refresh-webpack-plugin/loader'),\n              options: options.loaderOptions,\n            },\n            !!options.devtool &&\n              Object.prototype.hasOwnProperty.call(options, 'prevSourceMap') && {\n                loader: path.join(__dirname, 'fixtures/source-map-loader.js'),\n                options: {\n                  sourceMap: options.prevSourceMap,\n                },\n              },\n          ].filter(Boolean),\n        },\n      ],\n    },\n    plugins: [new webpack.HotModuleReplacementPlugin()],\n    // Options below forces Webpack to:\n    // 1. Move Webpack runtime into the runtime chunk;\n    // 2. Move node_modules into the vendor chunk with a stable name.\n    optimization: {\n      runtimeChunk: 'single',\n      splitChunks: {\n        chunks: 'all',\n        name: (module, chunks, cacheGroupKey) => cacheGroupKey,\n      },\n    },\n  });\n\n  // Use an in-memory file system to prevent emitting files\n  compiler.outputFileSystem = createFsFromVolume(new Volume());\n\n  /** @type {import('memfs').IFs} */\n  const compilerOutputFs = compiler.outputFileSystem;\n  /** @type {import('webpack').Stats | undefined} */\n  let compilationStats;\n\n  await new Promise((resolve, reject) => {\n    compiler.run((error, stats) => {\n      if (error) {\n        reject(error);\n        return;\n      }\n\n      compilationStats = stats;\n\n      // The compiler have to be explicitly closed\n      compiler.close(() => {\n        resolve();\n      });\n    });\n  });\n\n  return {\n    /** @type {*[]} */\n    get errors() {\n      return normalizeErrors(compilationStats.compilation.errors);\n    },\n    /** @type {*[]} */\n    get warnings() {\n      return normalizeErrors(compilationStats.compilation.errors);\n    },\n    /** @type {CompilationModule} */\n    get module() {\n      const compilationModules = compilationStats.toJson({ source: true }).modules;\n      if (!compilationModules) {\n        throw new Error('Module compilation stats not found!');\n      }\n\n      const parsed = compilationModules.find(({ name }) => name === './index.js');\n      if (!parsed) {\n        throw new Error('Fixture module is not found in compilation stats!');\n      }\n\n      let execution;\n      try {\n        execution = compilerOutputFs\n          .readFileSync(path.join(OUTPUT_PATH, `${BUNDLE_FILENAME}.js`))\n          .toString();\n      } catch (error) {\n        execution = error.toString();\n      }\n\n      /** @type {string | undefined} */\n      let sourceMap;\n      const [, sourceMapUrl] = execution.match(/\\/\\/# sourceMappingURL=(.*)$/) || [];\n      const isInlineSourceMap = !!sourceMapUrl && /^data:application\\/json;/.test(sourceMapUrl);\n      if (!isInlineSourceMap) {\n        try {\n          sourceMap = JSON.stringify(\n            JSON.parse(\n              compilerOutputFs.readFileSync(path.join(OUTPUT_PATH, sourceMapUrl)).toString()\n            ),\n            null,\n            2\n          );\n        } catch (error) {\n          sourceMap = error.toString();\n        }\n      }\n\n      return {\n        parsed: parsed.source,\n        execution,\n        sourceMap,\n      };\n    },\n  };\n}\n\nmodule.exports = getCompilation;\n"
  },
  {
    "path": "test/helpers/compilation/normalizeErrors.js",
    "content": "/**\n * @param {string} str\n * @return {string}\n */\nfunction removeCwd(str) {\n  let cwd = process.cwd();\n  let result = str;\n\n  const isWin = process.platform === 'win32';\n  if (isWin) {\n    cwd = cwd.replace(/\\\\/g, '/');\n    result = result.replace(/\\\\/g, '/');\n  }\n\n  return result.replace(new RegExp(cwd, 'g'), '');\n}\n\n/**\n * @param {Error[]} errors\n * @return {string[]}\n */\nfunction normalizeErrors(errors) {\n  return errors.map((error) => {\n    // Output nested error messages in full -\n    // this is useful for checking loader validation errors, for example.\n    if ('error' in error) {\n      return removeCwd(error.error.message);\n    }\n    return removeCwd(error.message.split('\\n').slice(0, 2).join('\\n'));\n  });\n}\n\nmodule.exports = normalizeErrors;\n"
  },
  {
    "path": "test/helpers/sandbox/aliasWDSv4.js",
    "content": "const moduleAlias = require('module-alias');\n\nmoduleAlias.addAliases({ 'webpack-dev-server': 'webpack-dev-server-v4' });\n"
  },
  {
    "path": "test/helpers/sandbox/configs.js",
    "content": "const path = require('path');\n\nconst BUNDLE_FILENAME = 'main';\n\n/**\n * @param {number} port\n * @returns {string}\n */\nfunction getIndexHTML(port) {\n  return `\n<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"UTF-8\" />\n    <title>Sandbox React App</title>\n  </head>\n  <body>\n    <div id=\"app\"></div>\n    <script src=\"http://localhost:${port}/${BUNDLE_FILENAME}.js\"></script>\n  </body>\n</html>\n`;\n}\n\n/**\n * @param {boolean} esModule\n * @returns {string}\n */\nfunction getPackageJson(esModule = false) {\n  return `\n{\n  \"type\": \"${esModule ? 'module' : 'commonjs'}\"\n}\n`;\n}\n\n/**\n * @param {string} srcDir\n * @returns {string}\n */\nfunction getWDSConfig(srcDir) {\n  return `\nconst { DefinePlugin, ProgressPlugin } = require('webpack');\nconst ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');\n\nmodule.exports = {\n  mode: 'development',\n  context: '${srcDir}',\n  devtool: false,\n  entry: {\n    '${BUNDLE_FILENAME}': [\n      '${path.join(__dirname, 'fixtures/hmr-notifier.js')}',\n      './index.js',\n    ],\n  },\n  module: {\n    rules: [\n      {\n        test: /\\\\.jsx?$/,\n        include: '${srcDir}',\n        use: [\n          {\n            loader: '${require.resolve('babel-loader')}',\n            options: {\n              babelrc: false,\n              plugins: ['${require.resolve('react-refresh/babel')}'],\n            }\n          }\n        ],\n      },\n    ],\n  },\n  output: {\n    hashFunction: 'xxhash64',\n  },\n  plugins: [\n    new DefinePlugin({ __react_refresh_test__: true }),\n    new ProgressPlugin((percentage) => {\n      if (percentage === 1) {\n        console.log(\"Webpack compilation complete.\");\n      }\n    }),\n    new ReactRefreshPlugin(),\n  ],\n  resolve: {\n    alias: ${JSON.stringify(\n      {\n        ...(WDS_VERSION === 4 && { 'webpack-dev-server': 'webpack-dev-server-v4' }),\n      },\n      null,\n      2\n    )},\n    extensions: ['.js', '.jsx'],\n  },\n};\n`;\n}\n\nmodule.exports = { getIndexHTML, getPackageJson, getWDSConfig };\n"
  },
  {
    "path": "test/helpers/sandbox/fixtures/hmr-notifier.js",
    "content": "if (module.hot) {\n  module.hot.addStatusHandler(function (status) {\n    if (status === 'idle') {\n      if (window.onHotSuccess) {\n        window.onHotSuccess();\n      }\n    }\n  });\n}\n"
  },
  {
    "path": "test/helpers/sandbox/index.js",
    "content": "const path = require('path');\nconst fse = require('fs-extra');\nconst { nanoid } = require('nanoid');\nconst { getIndexHTML, getPackageJson, getWDSConfig } = require('./configs');\nconst { killTestProcess, spawnWebpackServe } = require('./spawn');\n\n// Extends the timeout for tests using the sandbox\njest.setTimeout(1000 * 60);\n\n// Setup a global \"queue\" of cleanup handlers to allow auto-teardown of tests,\n// even when they did not run the cleanup function.\n/** @type {Map<string, function(): Promise<void>>} */\nconst cleanupHandlers = new Map();\nafterEach(async () => {\n  for (const [, callback] of cleanupHandlers) {\n    await callback();\n  }\n});\n\n/**\n * Logs output to the console (only in debug mode).\n * @param {...*} args\n * @returns {void}\n */\nconst log = (...args) => {\n  if (__DEBUG__) {\n    console.log(...args);\n  }\n};\n\n/**\n * Pause current asynchronous execution for provided milliseconds.\n * @param {number} ms\n * @returns {Promise<void>}\n */\nconst sleep = (ms) => {\n  return new Promise((resolve) => {\n    setTimeout(resolve, ms);\n  });\n};\n\n/**\n * @typedef {Object} SandboxSession\n * @property {boolean} didFullRefresh\n * @property {*[]} errors\n * @property {*[]} logs\n * @property {function(): void} resetState\n * @property {function(string, string): Promise<void>} write\n * @property {function(string, string): Promise<void>} patch\n * @property {function(string): Promise<void>} remove\n * @property {function(*, ...*=): Promise<*>} evaluate\n * @property {function(): Promise<void>} reload\n */\n\nconst rootSandboxDir = path.join(__dirname, '../..', '__tmp__');\n\n/**\n * Creates a Webpack and Puppeteer backed sandbox to execute HMR operations on.\n * @param {Object} [options]\n * @param {boolean} [options.esModule]\n * @param {string} [options.id]\n * @param {Map<string, string>} [options.initialFiles]\n * @returns {Promise<[SandboxSession, function(): Promise<void>]>}\n */\nasync function getSandbox({ esModule = false, id = nanoid(), initialFiles = new Map() } = {}) {\n  const { default: getPort } = await import('get-port');\n  const port = await getPort();\n\n  // Get sandbox directory paths\n  const sandboxDir = path.join(rootSandboxDir, id);\n  const srcDir = path.join(sandboxDir, 'src');\n  const publicDir = path.join(sandboxDir, 'public');\n  // In case of an ID clash, remove the existing sandbox directory\n  await fse.remove(sandboxDir);\n  // Create the sandbox source directory\n  await fse.mkdirp(srcDir);\n  // Create the sandbox public directory\n  await fse.mkdirp(publicDir);\n\n  // Write necessary files to sandbox\n  await fse.writeFile(path.join(sandboxDir, 'webpack.config.js'), getWDSConfig(srcDir));\n  await fse.writeFile(path.join(publicDir, 'index.html'), getIndexHTML(port));\n  await fse.writeFile(path.join(srcDir, 'package.json'), getPackageJson(esModule));\n  await fse.writeFile(\n    path.join(srcDir, 'index.js'),\n    esModule\n      ? `export default function Sandbox() { return 'new sandbox'; }`\n      : \"module.exports = function Sandbox() { return 'new sandbox'; };\"\n  );\n\n  // Write initial files to sandbox\n  for (const [filePath, fileContent] of initialFiles.entries()) {\n    await fse.writeFile(path.join(srcDir, filePath), fileContent);\n  }\n\n  // TODO: Add handling for webpack-hot-middleware and webpack-plugin-serve\n  const app = await spawnWebpackServe(port, { public: publicDir, root: sandboxDir, src: srcDir });\n  /** @type {import('puppeteer').Page} */\n  const page = await browser.newPage();\n\n  await page.goto(`http://localhost:${port}/`);\n\n  let didFullRefresh = false;\n  /** @type {string[]} */\n  let errors = [];\n  /** @type {string[]} */\n  let logs = [];\n\n  // Expose logging and hot callbacks to the page\n  await Promise.all([\n    page.exposeFunction('log', (...args) => {\n      logs.push(args.join(' '));\n    }),\n    page.exposeFunction('onHotAcceptError', (errorMessage) => {\n      errors.push(errorMessage);\n    }),\n    page.exposeFunction('onHotSuccess', () => {\n      page.emit('hotSuccess');\n    }),\n  ]);\n\n  // Reset testing logs and errors on any navigation.\n  // This is done for the main frame only,\n  // because child frames (e.g. iframes) might attach to the document,\n  // which will cause this event to fire.\n  page.on('framenavigated', (frame) => {\n    if (frame === page.mainFrame()) {\n      resetState();\n    }\n  });\n\n  /** @returns {void} */\n  function resetState() {\n    errors = [];\n    logs = [];\n  }\n\n  async function cleanupSandbox() {\n    try {\n      await page.close();\n      await killTestProcess(app);\n\n      if (!__DEBUG__) {\n        await fse.remove(sandboxDir);\n      }\n\n      // Remove current cleanup handler from the global queue since it has been called\n      cleanupHandlers.delete(id);\n    } catch (e) {\n      // Do nothing\n    }\n  }\n\n  // Cache the cleanup handler for global cleanup\n  // This is done in case tests fail and async handlers are kept alive\n  cleanupHandlers.set(id, cleanupSandbox);\n\n  return [\n    {\n      /** @type {boolean} */\n      get didFullRefresh() {\n        return didFullRefresh;\n      },\n      /** @type {*[]} */\n      get errors() {\n        return errors;\n      },\n      /** @type {*[]} */\n      get logs() {\n        return logs;\n      },\n      /** @returns {void} */\n      resetState,\n      /**\n       * @param {string} fileName\n       * @param {string} content\n       * @returns {Promise<void>}\n       */\n      async write(fileName, content) {\n        // Update the file on filesystem\n        const fullFileName = path.join(srcDir, fileName);\n        const directory = path.dirname(fullFileName);\n        await fse.mkdirp(directory);\n        await fse.writeFile(fullFileName, content);\n      },\n      /**\n       * @param {string} fileName\n       * @param {string} content\n       * @returns {Promise<void>}\n       */\n      async patch(fileName, content) {\n        // Register an event for HMR completion\n        let hmrStatus = 'pending';\n        // Parallelize file writing and event listening to prevent race conditions\n        await Promise.all([\n          this.write(fileName, content),\n          new Promise((resolve) => {\n            const hmrTimeout = setTimeout(() => {\n              hmrStatus = 'timeout';\n              resolve();\n            }, 30 * 1000);\n\n            // Frame Navigate and Hot Success events have to be exclusive,\n            // so we remove the other listener when one of them is triggered.\n\n            /**\n             * @param {import('puppeteer').Frame} frame\n             * @returns {void}\n             */\n            const onFrameNavigate = (frame) => {\n              if (frame === page.mainFrame()) {\n                page.off('hotSuccess', onHotSuccess);\n                clearTimeout(hmrTimeout);\n                hmrStatus = 'reloaded';\n                resolve();\n              }\n            };\n\n            /**\n             * @returns {void}\n             */\n            const onHotSuccess = () => {\n              page.off('framenavigated', onFrameNavigate);\n              clearTimeout(hmrTimeout);\n              hmrStatus = 'success';\n              resolve();\n            };\n\n            // Make sure that the event listener is bound to trigger only once\n            page.once('framenavigated', onFrameNavigate);\n            page.once('hotSuccess', onHotSuccess);\n          }),\n        ]);\n\n        if (hmrStatus === 'reloaded') {\n          log('Application reloaded.');\n          didFullRefresh = didFullRefresh || true;\n        } else if (hmrStatus === 'success') {\n          log('Hot update complete.');\n        } else {\n          throw new Error(`Application is in an inconsistent state: ${hmrStatus}.`);\n        }\n\n        // Slow down tests to wait for re-rendering\n        await sleep(1000);\n      },\n      /**\n       * @param {string} fileName\n       * @returns {Promise<void>}\n       */\n      async remove(fileName) {\n        const fullFileName = path.join(srcDir, fileName);\n        await fse.remove(fullFileName);\n      },\n      /**\n       * @param {*} fn\n       * @param {...*} restArgs\n       * @returns {Promise<*>}\n       */\n      async evaluate(fn, ...restArgs) {\n        if (typeof fn === 'function') {\n          return await page.evaluate(fn, ...restArgs);\n        } else {\n          throw new Error('You must pass a function to be evaluated in the browser!');\n        }\n      },\n      /** @returns {Promise<void>} */\n      async reload() {\n        await page.reload({ waitUntil: 'networkidle2' });\n        didFullRefresh = false;\n      },\n    },\n    cleanupSandbox,\n  ];\n}\n\nmodule.exports = getSandbox;\n"
  },
  {
    "path": "test/helpers/sandbox/spawn.js",
    "content": "const path = require('path');\nconst spawn = require('cross-spawn');\n\n/**\n * @param {string} packageName\n * @returns {string}\n */\nfunction getPackageExecutable(packageName, binName) {\n  let { bin: binPath } = require(`${packageName}/package.json`);\n  // \"bin\": { \"package\": \"bin.js\" }\n  if (typeof binPath === 'object') {\n    binPath = binPath[binName || packageName];\n  }\n  if (!binPath) {\n    throw new Error(`Package ${packageName} does not have an executable!`);\n  }\n\n  return require.resolve(path.join(packageName, binPath));\n}\n\n/**\n * @param {import('child_process').ChildProcess | void} instance\n * @returns {void}\n */\nfunction killTestProcess(instance) {\n  if (!instance) {\n    return;\n  }\n\n  try {\n    process.kill(instance.pid);\n  } catch (error) {\n    if (\n      process.platform === 'win32' &&\n      typeof error.message === 'string' &&\n      (error.message.includes(`no running instance of the task`) ||\n        error.message.includes(`not found`))\n    ) {\n      // Windows throws an error if the process is already dead\n      return;\n    }\n\n    throw error;\n  }\n}\n\n/**\n * @typedef {Object} SpawnOptions\n * @property {string} [cwd]\n * @property {*} [env]\n * @property {string | RegExp} [successMessage]\n */\n\n/**\n * @param {string} processPath\n * @param {*[]} argv\n * @param {SpawnOptions} [options]\n * @returns {Promise<import('child_process').ChildProcess | void>}\n */\nfunction spawnTestProcess(processPath, argv, options = {}) {\n  const cwd = options.cwd || path.resolve(__dirname, '../../..');\n  const env = {\n    ...process.env,\n    NODE_ENV: 'development',\n    ...options.env,\n  };\n  const successRegex = new RegExp(options.successMessage || 'webpack compilation complete.', 'i');\n\n  return new Promise((resolve, reject) => {\n    const instance = spawn(processPath, argv, { cwd, env });\n    let didResolve = false;\n\n    /**\n     * @param {Buffer} data\n     * @returns {void}\n     */\n    function handleStdout(data) {\n      const message = data.toString();\n      if (successRegex.test(message)) {\n        if (!didResolve) {\n          didResolve = true;\n          resolve(instance);\n        }\n      }\n\n      if (__DEBUG__) {\n        process.stdout.write(message);\n      }\n    }\n\n    /**\n     * @param {Buffer} data\n     * @returns {void}\n     */\n    function handleStderr(data) {\n      const message = data.toString();\n\n      if (__DEBUG__) {\n        process.stderr.write(message);\n      }\n    }\n\n    instance.stdout.on('data', handleStdout);\n    instance.stderr.on('data', handleStderr);\n\n    instance.on('close', () => {\n      instance.stdout.removeListener('data', handleStdout);\n      instance.stderr.removeListener('data', handleStderr);\n\n      if (!didResolve) {\n        didResolve = true;\n        resolve();\n      }\n    });\n\n    instance.on('error', (error) => {\n      reject(error);\n    });\n  });\n}\n\n/**\n * @param {number} port\n * @param {Object} dirs\n * @param {string} dirs.public\n * @param {string} dirs.root\n * @param {string} dirs.src\n * @param {SpawnOptions} [options]\n * @returns {Promise<import('child_process').ChildProcess | void>}\n */\nfunction spawnWebpackServe(port, dirs, options = {}) {\n  const webpackBin = getPackageExecutable('webpack-cli', 'webpack-cli');\n\n  const NODE_OPTIONS = [\n    // This requires a script to alias `webpack-dev-server` -\n    // both v4 and v5 are installed,\n    // so we have to ensure that they resolve to the correct variant.\n    WDS_VERSION === 4 && `--require \"${require.resolve('./aliasWDSv4')}\"`,\n  ]\n    .filter(Boolean)\n    .join(' ');\n\n  return spawnTestProcess(\n    webpackBin,\n    [\n      'serve',\n      '--no-color',\n      '--no-client-overlay',\n      '--config',\n      path.join(dirs.root, 'webpack.config.js'),\n      '--static-directory',\n      dirs.public,\n      '--hot',\n      '--port',\n      port,\n    ],\n    {\n      ...options,\n      env: { ...options.env, ...(NODE_OPTIONS && { NODE_OPTIONS }) },\n    }\n  );\n}\n\nmodule.exports = {\n  killTestProcess,\n  spawnWebpackServe,\n};\n"
  },
  {
    "path": "test/jest-environment.js",
    "content": "const { TestEnvironment: NodeEnvironment } = require('jest-environment-node');\nconst yn = require('yn');\n\nclass TestEnvironment extends NodeEnvironment {\n  async setup() {\n    await super.setup();\n\n    this.global.__DEBUG__ = yn(process.env.DEBUG);\n    this.global.WDS_VERSION = parseInt(process.env.WDS_VERSION || 5);\n  }\n}\n\nmodule.exports = TestEnvironment;\n"
  },
  {
    "path": "test/jest-global-setup.js",
    "content": "const puppeteer = require('puppeteer');\nconst yn = require('yn');\n\nasync function setup() {\n  if (yn(process.env.BROWSER, { default: true })) {\n    const browser = await puppeteer.launch({\n      devtools: yn(process.env.DEBUG, { default: false }),\n      headless: yn(process.env.HEADLESS, {\n        // Force headless mode in CI environments\n        default: yn(process.env.CI, { default: false }),\n      }),\n    });\n\n    global.__BROWSER_INSTANCE__ = browser;\n\n    process.env.PUPPETEER_WS_ENDPOINT = browser.wsEndpoint();\n  }\n}\n\nmodule.exports = setup;\n"
  },
  {
    "path": "test/jest-global-teardown.js",
    "content": "async function teardown() {\n  if (global.__BROWSER_INSTANCE__) {\n    await global.__BROWSER_INSTANCE__.close();\n  }\n}\n\nmodule.exports = teardown;\n"
  },
  {
    "path": "test/jest-resolver.js",
    "content": "/**\n * @param {string} request\n * @param {*} options\n * @return {string}\n */\nfunction resolver(request, options) {\n  // This acts as a mock for `require.resolve('react-refresh')`,\n  // since the current mocking behaviour of Jest is not symmetrical,\n  // i.e. only `require` is mocked but not `require.resolve`.\n  if (request === 'react-refresh') {\n    return 'react-refresh';\n  }\n\n  return options.defaultResolver(request, options);\n}\n\nmodule.exports = resolver;\n"
  },
  {
    "path": "test/jest-test-setup.js",
    "content": "require('jest-location-mock');\n\n/**\n * Skips a test block conditionally.\n * @param {boolean} condition The condition to skip the test block.\n * @param {string} blockName The name of the test block.\n * @param {import('@jest/types').Global.BlockFn} blockFn The test block function.\n * @returns {void}\n */\ndescribe.skipIf = (condition, blockName, blockFn) => {\n  if (condition) {\n    return describe.skip(blockName, blockFn);\n  }\n  return describe(blockName, blockFn);\n};\n\n/**\n * Skips a test conditionally.\n * @param {boolean} condition The condition to skip the test.\n * @param {string} testName The name of the test.\n * @param {import('@jest/types').Global.TestFn} fn The test function.\n * @param {number} [timeout] The time to wait before aborting.\n * @returns {void}\n */\ntest.skipIf = (condition, testName, fn, timeout) => {\n  if (condition) {\n    return test.skip(testName, fn);\n  }\n  return test(testName, fn, timeout);\n};\n\nit.skipIf = test.skipIf;\n"
  },
  {
    "path": "test/loader/fixtures/auto/package.json",
    "content": "{\n  \"name\": \"auto\"\n}\n"
  },
  {
    "path": "test/loader/fixtures/cjs/esm/index.js",
    "content": "export default 'esm';\n"
  },
  {
    "path": "test/loader/fixtures/cjs/esm/package.json",
    "content": "{\n  \"type\": \"module\"\n}\n"
  },
  {
    "path": "test/loader/fixtures/cjs/index.js",
    "content": "module.exports = 'Test';\n"
  },
  {
    "path": "test/loader/fixtures/cjs/package.json",
    "content": "{\n  \"name\": \"cjs\",\n  \"type\": \"commonjs\"\n}\n"
  },
  {
    "path": "test/loader/fixtures/esm/cjs/index.js",
    "content": "module.exports = 'cjs';\n"
  },
  {
    "path": "test/loader/fixtures/esm/cjs/package.json",
    "content": "{\n  \"type\": \"commonjs\"\n}\n"
  },
  {
    "path": "test/loader/fixtures/esm/index.js",
    "content": "export default 'Test';\n"
  },
  {
    "path": "test/loader/fixtures/esm/package.json",
    "content": "{\n  \"name\": \"esm\",\n  \"type\": \"module\"\n}\n"
  },
  {
    "path": "test/loader/loader.test.js",
    "content": "const validate = require('sourcemap-validator');\nconst mockFetch = require('../mocks/fetch');\n\ndescribe('loader', () => {\n  let getCompilation;\n\n  beforeEach(() => {\n    jest.isolateModules(() => {\n      getCompilation = require('../helpers/compilation');\n    });\n  });\n\n  describe('on Webpack 5', () => {\n    it('should work for CommonJS', async () => {\n      const compilation = await getCompilation('cjs');\n      const { execution, parsed } = compilation.module;\n\n      expect(parsed).toMatchInlineSnapshot(`\n        \"(typeof __webpack_global__ !== 'undefined' ? __webpack_global__ : __webpack_require__).$Refresh$.runtime = require('react-refresh');\n\n        module.exports = 'Test';\n\n\n        var $ReactRefreshModuleId$ = (typeof __webpack_global__ !== 'undefined' ? __webpack_global__ : __webpack_require__).$Refresh$.moduleId;\n        var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports(\n        \t$ReactRefreshModuleId$\n        );\n\n        function $ReactRefreshModuleRuntime$(exports) {\n        \tif (module.hot) {\n        \t\tvar errorOverlay;\n        \t\tif (typeof __react_refresh_error_overlay__ !== 'undefined') {\n        \t\t\terrorOverlay = __react_refresh_error_overlay__;\n        \t\t}\n        \t\tvar testMode;\n        \t\tif (typeof __react_refresh_test__ !== 'undefined') {\n        \t\t\ttestMode = __react_refresh_test__;\n        \t\t}\n        \t\treturn __react_refresh_utils__.executeRuntime(\n        \t\t\texports,\n        \t\t\t$ReactRefreshModuleId$,\n        \t\t\tmodule.hot,\n        \t\t\terrorOverlay,\n        \t\t\ttestMode\n        \t\t);\n        \t}\n        }\n\n        if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) {\n        \t$ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$);\n        } else {\n        \t$ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$);\n        }\"\n      `);\n      expect(execution).toMatchInlineSnapshot(`\n       \"(self[\"webpackChunkcjs\"] = self[\"webpackChunkcjs\"] || []).push([[\"main\"],{\n\n       /***/ \"./index.js\":\n       /*!******************!*\\\\\n         !*** ./index.js ***!\n         \\\\******************/\n       /***/ ((module, __unused_webpack_exports, __webpack_require__) => {\n\n       (typeof __webpack_global__ !== 'undefined' ? __webpack_global__ : __webpack_require__).$Refresh$.runtime = __webpack_require__(/*! react-refresh */ \"../../../../node_modules/react-refresh/runtime.js\");\n\n       module.exports = 'Test';\n\n\n       var $ReactRefreshModuleId$ = (typeof __webpack_global__ !== 'undefined' ? __webpack_global__ : __webpack_require__).$Refresh$.moduleId;\n       var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports(\n       \t$ReactRefreshModuleId$\n       );\n\n       function $ReactRefreshModuleRuntime$(exports) {\n       \tif (true) {\n       \t\tvar errorOverlay;\n       \t\tif (typeof __react_refresh_error_overlay__ !== 'undefined') {\n       \t\t\terrorOverlay = __react_refresh_error_overlay__;\n       \t\t}\n       \t\tvar testMode;\n       \t\tif (typeof __react_refresh_test__ !== 'undefined') {\n       \t\t\ttestMode = __react_refresh_test__;\n       \t\t}\n       \t\treturn __react_refresh_utils__.executeRuntime(\n       \t\t\texports,\n       \t\t\t$ReactRefreshModuleId$,\n       \t\t\tmodule.hot,\n       \t\t\terrorOverlay,\n       \t\t\ttestMode\n       \t\t);\n       \t}\n       }\n\n       if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) {\n       \t$ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$);\n       } else {\n       \t$ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$);\n       }\n\n       /***/ })\n\n       },\n       /******/ __webpack_require__ => { // webpackRuntimeModules\n       /******/ var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))\n       /******/ __webpack_require__.O(0, [\"defaultVendors\"], () => (__webpack_exec__(\"./index.js\")));\n       /******/ var __webpack_exports__ = __webpack_require__.O();\n       /******/ }\n       ]);\"\n      `);\n\n      expect(compilation.errors).toStrictEqual([]);\n      expect(compilation.warnings).toStrictEqual([]);\n    });\n\n    it('should work for ES Modules', async () => {\n      const compilation = await getCompilation('esm');\n      const { execution, parsed } = compilation.module;\n\n      expect(parsed).toMatchInlineSnapshot(`\n        \"import * as __react_refresh_runtime__ from 'react-refresh';\n        (typeof __webpack_global__ !== 'undefined' ? __webpack_global__ : __webpack_require__).$Refresh$.runtime = __react_refresh_runtime__;\n\n        export default 'Test';\n\n\n        var $ReactRefreshModuleId$ = (typeof __webpack_global__ !== 'undefined' ? __webpack_global__ : __webpack_require__).$Refresh$.moduleId;\n        var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports(\n        \t$ReactRefreshModuleId$\n        );\n\n        function $ReactRefreshModuleRuntime$(exports) {\n        \tif (import.meta.webpackHot) {\n        \t\tvar errorOverlay;\n        \t\tif (typeof __react_refresh_error_overlay__ !== 'undefined') {\n        \t\t\terrorOverlay = __react_refresh_error_overlay__;\n        \t\t}\n        \t\tvar testMode;\n        \t\tif (typeof __react_refresh_test__ !== 'undefined') {\n        \t\t\ttestMode = __react_refresh_test__;\n        \t\t}\n        \t\treturn __react_refresh_utils__.executeRuntime(\n        \t\t\texports,\n        \t\t\t$ReactRefreshModuleId$,\n        \t\t\timport.meta.webpackHot,\n        \t\t\terrorOverlay,\n        \t\t\ttestMode\n        \t\t);\n        \t}\n        }\n\n        if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) {\n        \t$ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$);\n        } else {\n        \t$ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$);\n        }\"\n      `);\n      expect(execution).toMatchInlineSnapshot(`\n       \"\"use strict\";\n       (self[\"webpackChunkesm\"] = self[\"webpackChunkesm\"] || []).push([[\"main\"],{\n\n       /***/ \"./index.js\":\n       /*!******************!*\\\\\n         !*** ./index.js ***!\n         \\\\******************/\n       /***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {\n\n       var react_refresh__WEBPACK_IMPORTED_MODULE_0___namespace_cache;\n       __webpack_require__.r(__webpack_exports__);\n       /* harmony export */ __webpack_require__.d(__webpack_exports__, {\n       /* harmony export */   \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n       /* harmony export */ });\n       /* harmony import */ var react_refresh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react-refresh */ \"../../../../node_modules/react-refresh/runtime.js\");\n\n       (typeof __webpack_global__ !== 'undefined' ? __webpack_global__ : __webpack_require__).$Refresh$.runtime = /*#__PURE__*/ (react_refresh__WEBPACK_IMPORTED_MODULE_0___namespace_cache || (react_refresh__WEBPACK_IMPORTED_MODULE_0___namespace_cache = __webpack_require__.t(react_refresh__WEBPACK_IMPORTED_MODULE_0__, 2)));\n\n       /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ('Test');\n\n\n       var $ReactRefreshModuleId$ = (typeof __webpack_global__ !== 'undefined' ? __webpack_global__ : __webpack_require__).$Refresh$.moduleId;\n       var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports(\n       \t$ReactRefreshModuleId$\n       );\n\n       function $ReactRefreshModuleRuntime$(exports) {\n       \tif (true) {\n       \t\tvar errorOverlay;\n       \t\tif (typeof __react_refresh_error_overlay__ !== 'undefined') {\n       \t\t\terrorOverlay = __react_refresh_error_overlay__;\n       \t\t}\n       \t\tvar testMode;\n       \t\tif (typeof __react_refresh_test__ !== 'undefined') {\n       \t\t\ttestMode = __react_refresh_test__;\n       \t\t}\n       \t\treturn __react_refresh_utils__.executeRuntime(\n       \t\t\texports,\n       \t\t\t$ReactRefreshModuleId$,\n       \t\t\t__webpack_module__.hot,\n       \t\t\terrorOverlay,\n       \t\t\ttestMode\n       \t\t);\n       \t}\n       }\n\n       if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) {\n       \t$ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$);\n       } else {\n       \t$ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$);\n       }\n\n       /***/ })\n\n       },\n       /******/ __webpack_require__ => { // webpackRuntimeModules\n       /******/ var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))\n       /******/ __webpack_require__.O(0, [\"defaultVendors\"], () => (__webpack_exec__(\"./index.js\")));\n       /******/ var __webpack_exports__ = __webpack_require__.O();\n       /******/ }\n       ]);\"\n      `);\n\n      expect(compilation.errors).toStrictEqual([]);\n      expect(compilation.warnings).toStrictEqual([]);\n    });\n\n    it('should generate valid source map when the \"devtool\" option is specified', async () => {\n      const compilation = await getCompilation('cjs', { devtool: 'source-map' });\n      const { execution, sourceMap } = compilation.module;\n\n      expect(sourceMap).toMatchInlineSnapshot(`\n\"{\n  \"version\": 3,\n  \"file\": \"main.js\",\n  \"mappings\": \";;;;;;;;;;AAAA\",\n  \"sources\": [\n    \"webpack://cjs/./index.js\"\n  ],\n  \"sourcesContent\": [\n    \"module.exports = 'Test';\\\\n\"\n  ],\n  \"names\": [],\n  \"ignoreList\": [],\n  \"sourceRoot\": \"\"\n}\"\n`);\n      expect(() => {\n        validate(execution, sourceMap);\n      }).not.toThrow();\n    });\n  });\n\n  it('should generate valid source map when undefined source map is provided', async () => {\n    const compilation = await getCompilation('cjs', {\n      devtool: 'source-map',\n      prevSourceMap: undefined,\n    });\n    const { execution, sourceMap } = compilation.module;\n\n    expect(() => {\n      validate(execution, sourceMap);\n    }).not.toThrow();\n  });\n\n  it('should generate valid source map when null source map is provided', async () => {\n    const compilation = await getCompilation('cjs', {\n      devtool: 'source-map',\n      prevSourceMap: null,\n    });\n    const { execution, sourceMap } = compilation.module;\n\n    expect(() => {\n      validate(execution, sourceMap);\n    }).not.toThrow();\n  });\n\n  it('should generate valid source map when source map string is provided', async () => {\n    const compilation = await getCompilation('cjs', {\n      devtool: 'source-map',\n      prevSourceMap: JSON.stringify({\n        version: 3,\n        sources: ['cjs'],\n        names: [],\n        mappings: 'AAAA;AACA',\n        sourcesContent: [\"module.exports = 'Test';\\n\"],\n      }),\n    });\n    const { execution, sourceMap } = compilation.module;\n\n    expect(() => {\n      validate(execution, sourceMap);\n    }).not.toThrow();\n  });\n\n  it('should generate valid source map when source map object is provided', async () => {\n    const compilation = await getCompilation('cjs', {\n      devtool: 'source-map',\n      prevSourceMap: {\n        version: 3,\n        sources: ['cjs'],\n        names: [],\n        mappings: 'AAAA;AACA',\n        sourcesContent: [\"module.exports = 'Test';\\n\"],\n      },\n    });\n    const { execution, sourceMap } = compilation.module;\n\n    expect(() => {\n      validate(execution, sourceMap);\n    }).not.toThrow();\n  });\n\n  it('should work with global fetch polyfill', async () => {\n    const [fetch] = mockFetch();\n\n    await expect(getCompilation('cjs')).resolves.not.toThrow();\n    expect(global.fetch).toStrictEqual(fetch);\n  });\n});\n"
  },
  {
    "path": "test/loader/unit/getIdentitySourceMap.test.js",
    "content": "const { SourceMapConsumer } = require('source-map');\nconst validate = require('sourcemap-validator');\nconst getIdentitySourceMap = require('../../../loader/utils/getIdentitySourceMap');\n\ndescribe('getIdentitySourceMap', () => {\n  it('should generate valid source map with source equality', async () => {\n    const source = \"module.exports = 'Test'\";\n    const path = 'index.js';\n\n    const identityMap = getIdentitySourceMap(source, path);\n    expect(() => {\n      validate(source, JSON.stringify(identityMap));\n    }).not.toThrow();\n\n    const sourceMapConsumer = await new SourceMapConsumer(identityMap);\n    expect(sourceMapConsumer.sourceContentFor(path)).toBe(source);\n  });\n});\n"
  },
  {
    "path": "test/loader/unit/getModuleSystem.test.js",
    "content": "const path = require('path');\nconst { ModuleFilenameHelpers } = require('webpack');\n\ndescribe('getModuleSystem', () => {\n  let getModuleSystem;\n\n  beforeEach(() => {\n    jest.isolateModules(() => {\n      getModuleSystem = require('../../../loader/utils/getModuleSystem');\n    });\n  });\n\n  it('should return `esm` when `options.esModule` is true', async () => {\n    await expect(getModuleSystem.call({}, ModuleFilenameHelpers, { esModule: true })).resolves.toBe(\n      'esm'\n    );\n  });\n\n  it('should return `cjs` when `options.esModule` is false', async () => {\n    await expect(\n      getModuleSystem.call({}, ModuleFilenameHelpers, { esModule: false })\n    ).resolves.toBe('cjs');\n  });\n\n  it('should return `esm` when `resourcePath` matches `options.esModule.include`', async () => {\n    await expect(\n      getModuleSystem.call(\n        {\n          resourcePath: 'include',\n        },\n        ModuleFilenameHelpers,\n        { esModule: { include: /include/ } }\n      )\n    ).resolves.toBe('esm');\n  });\n\n  it('should return `cjs` when `resourcePath` matches `options.esModule.exclude`', async () => {\n    await expect(\n      getModuleSystem.call(\n        {\n          resourcePath: 'exclude',\n        },\n        ModuleFilenameHelpers,\n        { esModule: { exclude: /exclude/ } }\n      )\n    ).resolves.toBe('cjs');\n  });\n\n  it('should return `esm` when `resourcePath` ends with `.mjs` extension', async () => {\n    await expect(\n      getModuleSystem.call({ resourcePath: 'index.mjs' }, ModuleFilenameHelpers, {})\n    ).resolves.toBe('esm');\n  });\n\n  it('should return `cjs` when `resourcePath` ends with `.cjs` extension', async () => {\n    await expect(\n      getModuleSystem.call({ resourcePath: 'index.cjs' }, ModuleFilenameHelpers, {})\n    ).resolves.toBe('cjs');\n  });\n\n  it('should return `esm` when `package.json` uses the `module` type', async () => {\n    await expect(\n      getModuleSystem.call(\n        {\n          resourcePath: path.resolve(__dirname, '..', 'fixtures/esm', 'index.js'),\n          rootContext: path.resolve(__dirname, '..', 'fixtures/esm'),\n          addDependency: () => {},\n          addMissingDependency: () => {},\n        },\n        ModuleFilenameHelpers,\n        {}\n      )\n    ).resolves.toBe('esm');\n  });\n\n  it('should return `esm` when `package.json` uses the `module` type nested inside a cjs package', async () => {\n    await expect(\n      getModuleSystem.call(\n        {\n          resourcePath: path.resolve(__dirname, '..', 'fixtures/cjs/esm', 'index.js'),\n          rootContext: path.resolve(__dirname, '..', 'fixtures/cjs'),\n          addDependency: () => {},\n          addMissingDependency: () => {},\n        },\n        ModuleFilenameHelpers,\n        {}\n      )\n    ).resolves.toBe('esm');\n  });\n\n  it('should return `cjs` when `package.json` uses the `commonjs` type', async () => {\n    await expect(\n      getModuleSystem.call(\n        {\n          resourcePath: path.resolve(__dirname, '..', 'fixtures/cjs', 'index.js'),\n          rootContext: path.resolve(__dirname, '..', 'fixtures/cjs'),\n          addDependency: () => {},\n          addMissingDependency: () => {},\n        },\n        ModuleFilenameHelpers,\n        {}\n      )\n    ).resolves.toBe('cjs');\n  });\n\n  it('should return `cjs` when `package.json` uses the `commonjs` type nexted insdie an esm package', async () => {\n    await expect(\n      getModuleSystem.call(\n        {\n          resourcePath: path.resolve(__dirname, '..', 'fixtures/esm/cjs', 'index.js'),\n          rootContext: path.resolve(__dirname, '..', 'fixtures/esm'),\n          addDependency: () => {},\n          addMissingDependency: () => {},\n        },\n        ModuleFilenameHelpers,\n        {}\n      )\n    ).resolves.toBe('cjs');\n  });\n\n  it('should return `cjs` when nothing matches', async () => {\n    await expect(\n      getModuleSystem.call(\n        {\n          resourcePath: path.resolve(__dirname, '..', 'fixtures/auto', 'index.js'),\n          rootContext: path.resolve(__dirname, '..', 'fixtures/auto'),\n          addDependency: () => {},\n          addMissingDependency: () => {},\n        },\n        ModuleFilenameHelpers,\n        { esModule: {} }\n      )\n    ).resolves.toBe('cjs');\n  });\n});\n"
  },
  {
    "path": "test/loader/unit/getRefreshModuleRuntime.test.js",
    "content": "const { Template } = require('webpack');\nconst getRefreshModuleRuntime = require('../../../loader/utils/getRefreshModuleRuntime');\n\ndescribe('getRefreshModuleRuntime', () => {\n  it('should return working refresh module runtime without const using CommonJS', () => {\n    const refreshModuleRuntime = getRefreshModuleRuntime(Template, {\n      const: false,\n      moduleSystem: 'cjs',\n    });\n\n    expect(refreshModuleRuntime.indexOf('var')).not.toBe(-1);\n    expect(refreshModuleRuntime.indexOf('const')).toBe(-1);\n    expect(refreshModuleRuntime.indexOf('let')).toBe(-1);\n    expect(refreshModuleRuntime.indexOf('module.hot')).not.toBe(-1);\n    expect(refreshModuleRuntime.indexOf('import.meta.webpackHot')).toBe(-1);\n    expect(refreshModuleRuntime).toMatchInlineSnapshot(`\n      \"var $ReactRefreshModuleId$ = (typeof __webpack_global__ !== 'undefined' ? __webpack_global__ : __webpack_require__).$Refresh$.moduleId;\n      var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports(\n      \t$ReactRefreshModuleId$\n      );\n\n      function $ReactRefreshModuleRuntime$(exports) {\n      \tif (module.hot) {\n      \t\tvar errorOverlay;\n      \t\tif (typeof __react_refresh_error_overlay__ !== 'undefined') {\n      \t\t\terrorOverlay = __react_refresh_error_overlay__;\n      \t\t}\n      \t\tvar testMode;\n      \t\tif (typeof __react_refresh_test__ !== 'undefined') {\n      \t\t\ttestMode = __react_refresh_test__;\n      \t\t}\n      \t\treturn __react_refresh_utils__.executeRuntime(\n      \t\t\texports,\n      \t\t\t$ReactRefreshModuleId$,\n      \t\t\tmodule.hot,\n      \t\t\terrorOverlay,\n      \t\t\ttestMode\n      \t\t);\n      \t}\n      }\n\n      if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) {\n      \t$ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$);\n      } else {\n      \t$ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$);\n      }\"\n    `);\n  });\n\n  it('should return working refresh module runtime with const using CommonJS', () => {\n    const refreshModuleRuntime = getRefreshModuleRuntime(Template, {\n      const: true,\n      moduleSystem: 'cjs',\n    });\n\n    expect(refreshModuleRuntime.indexOf('var')).toBe(-1);\n    expect(refreshModuleRuntime.indexOf('const')).not.toBe(-1);\n    expect(refreshModuleRuntime.indexOf('let')).not.toBe(-1);\n    expect(refreshModuleRuntime.indexOf('module.hot')).not.toBe(-1);\n    expect(refreshModuleRuntime.indexOf('import.meta.webpackHot')).toBe(-1);\n    expect(refreshModuleRuntime).toMatchInlineSnapshot(`\n      \"const $ReactRefreshModuleId$ = (typeof __webpack_global__ !== 'undefined' ? __webpack_global__ : __webpack_require__).$Refresh$.moduleId;\n      const $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports(\n      \t$ReactRefreshModuleId$\n      );\n\n      function $ReactRefreshModuleRuntime$(exports) {\n      \tif (module.hot) {\n      \t\tlet errorOverlay;\n      \t\tif (typeof __react_refresh_error_overlay__ !== 'undefined') {\n      \t\t\terrorOverlay = __react_refresh_error_overlay__;\n      \t\t}\n      \t\tlet testMode;\n      \t\tif (typeof __react_refresh_test__ !== 'undefined') {\n      \t\t\ttestMode = __react_refresh_test__;\n      \t\t}\n      \t\treturn __react_refresh_utils__.executeRuntime(\n      \t\t\texports,\n      \t\t\t$ReactRefreshModuleId$,\n      \t\t\tmodule.hot,\n      \t\t\terrorOverlay,\n      \t\t\ttestMode\n      \t\t);\n      \t}\n      }\n\n      if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) {\n      \t$ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$);\n      } else {\n      \t$ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$);\n      }\"\n    `);\n  });\n\n  it('should return working refresh module runtime without const using ES Modules', () => {\n    const refreshModuleRuntime = getRefreshModuleRuntime(Template, {\n      const: false,\n      moduleSystem: 'esm',\n    });\n\n    expect(refreshModuleRuntime.indexOf('var')).not.toBe(-1);\n    expect(refreshModuleRuntime.indexOf('const')).toBe(-1);\n    expect(refreshModuleRuntime.indexOf('let')).toBe(-1);\n    expect(refreshModuleRuntime.indexOf('module.hot')).toBe(-1);\n    expect(refreshModuleRuntime.indexOf('import.meta.webpackHot')).not.toBe(-1);\n    expect(refreshModuleRuntime).toMatchInlineSnapshot(`\n      \"var $ReactRefreshModuleId$ = (typeof __webpack_global__ !== 'undefined' ? __webpack_global__ : __webpack_require__).$Refresh$.moduleId;\n      var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports(\n      \t$ReactRefreshModuleId$\n      );\n\n      function $ReactRefreshModuleRuntime$(exports) {\n      \tif (import.meta.webpackHot) {\n      \t\tvar errorOverlay;\n      \t\tif (typeof __react_refresh_error_overlay__ !== 'undefined') {\n      \t\t\terrorOverlay = __react_refresh_error_overlay__;\n      \t\t}\n      \t\tvar testMode;\n      \t\tif (typeof __react_refresh_test__ !== 'undefined') {\n      \t\t\ttestMode = __react_refresh_test__;\n      \t\t}\n      \t\treturn __react_refresh_utils__.executeRuntime(\n      \t\t\texports,\n      \t\t\t$ReactRefreshModuleId$,\n      \t\t\timport.meta.webpackHot,\n      \t\t\terrorOverlay,\n      \t\t\ttestMode\n      \t\t);\n      \t}\n      }\n\n      if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) {\n      \t$ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$);\n      } else {\n      \t$ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$);\n      }\"\n    `);\n  });\n\n  it('should return working refresh module runtime with const using ES Modules', () => {\n    const refreshModuleRuntime = getRefreshModuleRuntime(Template, {\n      const: true,\n      moduleSystem: 'esm',\n    });\n\n    expect(refreshModuleRuntime.indexOf('var')).toBe(-1);\n    expect(refreshModuleRuntime.indexOf('const')).not.toBe(-1);\n    expect(refreshModuleRuntime.indexOf('let')).not.toBe(-1);\n    expect(refreshModuleRuntime.indexOf('module.hot')).toBe(-1);\n    expect(refreshModuleRuntime.indexOf('import.meta.webpackHot')).not.toBe(-1);\n    expect(refreshModuleRuntime).toMatchInlineSnapshot(`\n      \"const $ReactRefreshModuleId$ = (typeof __webpack_global__ !== 'undefined' ? __webpack_global__ : __webpack_require__).$Refresh$.moduleId;\n      const $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports(\n      \t$ReactRefreshModuleId$\n      );\n\n      function $ReactRefreshModuleRuntime$(exports) {\n      \tif (import.meta.webpackHot) {\n      \t\tlet errorOverlay;\n      \t\tif (typeof __react_refresh_error_overlay__ !== 'undefined') {\n      \t\t\terrorOverlay = __react_refresh_error_overlay__;\n      \t\t}\n      \t\tlet testMode;\n      \t\tif (typeof __react_refresh_test__ !== 'undefined') {\n      \t\t\ttestMode = __react_refresh_test__;\n      \t\t}\n      \t\treturn __react_refresh_utils__.executeRuntime(\n      \t\t\texports,\n      \t\t\t$ReactRefreshModuleId$,\n      \t\t\timport.meta.webpackHot,\n      \t\t\terrorOverlay,\n      \t\t\ttestMode\n      \t\t);\n      \t}\n      }\n\n      if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) {\n      \t$ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$);\n      } else {\n      \t$ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$);\n      }\"\n    `);\n  });\n});\n"
  },
  {
    "path": "test/loader/unit/normalizeOptions.test.js",
    "content": "const normalizeOptions = require('../../../loader/utils/normalizeOptions');\n\n/** @type {Partial<import('../../../types/loader').ReactRefreshLoaderOptions>} */\nconst DEFAULT_OPTIONS = {\n  const: false,\n  esModule: undefined,\n};\n\ndescribe('normalizeOptions', () => {\n  it('should return default options when an empty object is received', () => {\n    expect(normalizeOptions({})).toStrictEqual(DEFAULT_OPTIONS);\n  });\n\n  it('should return user options', () => {\n    expect(\n      normalizeOptions({\n        const: true,\n        esModule: {\n          exclude: 'exclude',\n          include: 'include',\n        },\n      })\n    ).toStrictEqual({\n      const: true,\n      esModule: {\n        exclude: 'exclude',\n        include: 'include',\n      },\n    });\n  });\n\n  it('should return true for overlay options when it is true', () => {\n    expect(normalizeOptions({ esModule: true })).toStrictEqual({\n      ...DEFAULT_OPTIONS,\n      esModule: true,\n    });\n  });\n\n  it('should return false for esModule when it is false', () => {\n    expect(normalizeOptions({ esModule: false })).toStrictEqual({\n      ...DEFAULT_OPTIONS,\n      esModule: false,\n    });\n  });\n\n  it('should return undefined for esModule when it is undefined', () => {\n    expect(normalizeOptions({ esModule: undefined })).toStrictEqual({\n      ...DEFAULT_OPTIONS,\n      esModule: undefined,\n    });\n  });\n\n  it('should return undefined for esModule when it is undefined', () => {\n    expect(normalizeOptions({ esModule: undefined })).toStrictEqual({\n      ...DEFAULT_OPTIONS,\n      esModule: undefined,\n    });\n  });\n});\n"
  },
  {
    "path": "test/loader/validateOptions.test.js",
    "content": "describe('validateOptions', () => {\n  let getCompilation;\n\n  beforeEach(() => {\n    jest.isolateModules(() => {\n      getCompilation = require('../helpers/compilation');\n    });\n  });\n\n  it('should accept \"const\" when it is true', async () => {\n    const compilation = await getCompilation('cjs', { loaderOptions: { const: true } });\n    expect(compilation.errors).toStrictEqual([]);\n  });\n\n  it('should accept \"const\" when it is false', async () => {\n    const compilation = await getCompilation('cjs', { loaderOptions: { const: false } });\n    expect(compilation.errors).toStrictEqual([]);\n  });\n\n  it('should reject \"const\" when it is not a boolean', async () => {\n    const compilation = await getCompilation('cjs', { loaderOptions: { const: 1 } });\n    expect(compilation.errors).toHaveLength(1);\n    expect(compilation.errors[0]).toMatchInlineSnapshot(`\n      \"Invalid options object. React Refresh Loader has been initialized using an options object that does not match the API schema.\n       - options.const should be a boolean.\"\n    `);\n  });\n\n  it('should accept \"esModule\" when it is true', async () => {\n    const compilation = await getCompilation('esm', {\n      loaderOptions: { esModule: true },\n    });\n    expect(compilation.errors).toStrictEqual([]);\n  });\n\n  it('should accept \"esModule\" when it is false', async () => {\n    const compilation = await getCompilation('cjs', {\n      loaderOptions: { esModule: false },\n    });\n    expect(compilation.errors).toStrictEqual([]);\n  });\n\n  it('should accept \"esModule\" when it is undefined', async () => {\n    const compilation = await getCompilation('cjs', { loaderOptions: {} });\n    expect(compilation.errors).toStrictEqual([]);\n  });\n\n  it('should accept \"esModule\" when it is an empty object', async () => {\n    const compilation = await getCompilation('cjs', { loaderOptions: { esModule: {} } });\n    expect(compilation.errors).toStrictEqual([]);\n  });\n\n  it('should reject \"esModule\" when it is not a boolean nor an object', async () => {\n    const compilation = await getCompilation('cjs', {\n      loaderOptions: { esModule: 'esModule' },\n    });\n    expect(compilation.errors).toHaveLength(1);\n    expect(compilation.errors[0]).toMatchInlineSnapshot(`\n      \"Invalid options object. React Refresh Loader has been initialized using an options object that does not match the API schema.\n       - options.esModule should be one of these:\n         boolean | object { exclude?, include? }\n         Details:\n          * options.esModule should be a boolean.\n          * options.esModule should be an object:\n            object { exclude?, include? }\"\n    `);\n  });\n\n  it('should accept \"esModule.exclude\" when it is a RegExp', async () => {\n    const compilation = await getCompilation('cjs', {\n      loaderOptions: { esModule: { exclude: /index\\.js/ } },\n    });\n    expect(compilation.errors).toStrictEqual([]);\n  });\n\n  it('should accept \"esModule.exclude\" when it is an absolute path string', async () => {\n    const compilation = await getCompilation('cjs', {\n      loaderOptions: { esModule: { exclude: '/index.js' } },\n    });\n    expect(compilation.errors).toStrictEqual([]);\n  });\n\n  it('should accept \"esModule.exclude\" when it is a string', async () => {\n    const compilation = await getCompilation('cjs', {\n      loaderOptions: { esModule: { exclude: 'index.js' } },\n    });\n    expect(compilation.errors).toStrictEqual([]);\n  });\n\n  it('should accept \"esModule.exclude\" when it is an array of RegExp or strings', async () => {\n    const compilation = await getCompilation('cjs', {\n      loaderOptions: { esModule: { exclude: [/index\\.js/, 'index.js'] } },\n    });\n    expect(compilation.errors).toStrictEqual([]);\n  });\n\n  it('should reject \"esModule.exclude\" when it is an object', async () => {\n    const compilation = await getCompilation('cjs', {\n      loaderOptions: { esModule: { exclude: {} } },\n    });\n    expect(compilation.errors).toHaveLength(1);\n    expect(compilation.errors[0]).toMatchInlineSnapshot(`\n      \"Invalid options object. React Refresh Loader has been initialized using an options object that does not match the API schema.\n       - options.esModule should be one of these:\n         boolean | object { exclude?, include? }\n         Details:\n          * options.esModule.exclude should be one of these:\n            RegExp | string\n            Details:\n             * options.esModule.exclude should be an instance of RegExp.\n             * options.esModule.exclude should be a string.\n          * options.esModule.exclude should be an array:\n            [RegExp | string, ...] (should not have fewer than 1 item)\n          * options.esModule.exclude should be one of these:\n            RegExp | string | [RegExp | string, ...] (should not have fewer than 1 item)\"\n    `);\n  });\n\n  it('should accept \"esModule.include\" when it is a RegExp', async () => {\n    const compilation = await getCompilation('esm', {\n      loaderOptions: { esModule: { include: /index\\.js/ } },\n    });\n    expect(compilation.errors).toStrictEqual([]);\n  });\n\n  it('should accept \"esModule.include\" when it is an absolute path string', async () => {\n    const compilation = await getCompilation('esm', {\n      loaderOptions: { esModule: { include: '/index.js' } },\n    });\n    expect(compilation.errors).toStrictEqual([]);\n  });\n\n  it('should accept \"esModule.include\" when it is a string', async () => {\n    const compilation = await getCompilation('esm', {\n      loaderOptions: { esModule: { include: 'index.js' } },\n    });\n    expect(compilation.errors).toStrictEqual([]);\n  });\n\n  it('should accept \"esModule.include\" when it is an array of RegExp or strings', async () => {\n    const compilation = await getCompilation('esm', {\n      loaderOptions: { esModule: { include: [/index\\.js/, 'index.js'] } },\n    });\n    expect(compilation.errors).toStrictEqual([]);\n  });\n\n  it('should reject \"esModule.include\" when it is an object', async () => {\n    const compilation = await getCompilation('esm', {\n      loaderOptions: { esModule: { include: {} } },\n    });\n    expect(compilation.errors).toHaveLength(1);\n    expect(compilation.errors[0]).toMatchInlineSnapshot(`\n      \"Invalid options object. React Refresh Loader has been initialized using an options object that does not match the API schema.\n       - options.esModule should be one of these:\n         boolean | object { exclude?, include? }\n         Details:\n          * options.esModule.include should be one of these:\n            RegExp | string\n            Details:\n             * options.esModule.include should be an instance of RegExp.\n             * options.esModule.include should be a string.\n          * options.esModule.include should be an array:\n            [RegExp | string, ...] (should not have fewer than 1 item)\n          * options.esModule.include should be one of these:\n            RegExp | string | [RegExp | string, ...] (should not have fewer than 1 item)\"\n    `);\n  });\n\n  it('should reject any unknown options', async () => {\n    const compilation = await getCompilation('cjs', {\n      loaderOptions: { unknown: 'unknown' },\n    });\n    expect(compilation.errors).toHaveLength(1);\n    expect(compilation.errors[0]).toMatchInlineSnapshot(`\n      \"Invalid options object. React Refresh Loader has been initialized using an options object that does not match the API schema.\n       - options has an unknown property 'unknown'. These properties are valid:\n         object { const?, esModule? }\"\n    `);\n  });\n});\n"
  },
  {
    "path": "test/mocks/fetch.js",
    "content": "/** @type {Set<function(): void>} */\nconst cleanupHandlers = new Set();\nafterEach(() => {\n  [...cleanupHandlers].map((callback) => callback());\n});\n\nconst mockFetch = () => {\n  const originalFetch = global.fetch;\n\n  const fetchMock = new Function();\n  global.fetch = fetchMock;\n\n  function mockRestore() {\n    global.fetch = originalFetch;\n  }\n\n  cleanupHandlers.add(mockRestore);\n\n  return [fetchMock, mockRestore];\n};\n\nmodule.exports = mockFetch;\n"
  },
  {
    "path": "test/unit/fixtures/socketIntegration.js",
    "content": "module.exports = {};\n"
  },
  {
    "path": "test/unit/getAdditionalEntries.test.js",
    "content": "const getAdditionalEntries = require('../../lib/utils/getAdditionalEntries');\n\nconst ErrorOverlayEntry = require.resolve('../../client/ErrorOverlayEntry');\nconst ReactRefreshEntry = require.resolve('../../client/ReactRefreshEntry');\n\ndescribe('getAdditionalEntries', () => {\n  it('should work with default settings', () => {\n    expect(getAdditionalEntries({ overlay: { entry: ErrorOverlayEntry } })).toStrictEqual({\n      overlayEntries: [ErrorOverlayEntry],\n      prependEntries: [ReactRefreshEntry],\n    });\n  });\n\n  it('should skip overlay entries when overlay is false in options', () => {\n    expect(getAdditionalEntries({ overlay: false })).toStrictEqual({\n      overlayEntries: [],\n      prependEntries: [ReactRefreshEntry],\n    });\n  });\n});\n"
  },
  {
    "path": "test/unit/getIntegrationEntry.test.js",
    "content": "const getIntegrationEntry = require('../../lib/utils/getIntegrationEntry');\n\ndescribe('getIntegrationEntry', () => {\n  it('should work with webpack-hot-middleware', () => {\n    expect(getIntegrationEntry('whm')).toStrictEqual('webpack-hot-middleware/client');\n  });\n\n  it('should work with webpack-plugin-serve', () => {\n    expect(getIntegrationEntry('wps')).toStrictEqual('webpack-plugin-serve/client');\n  });\n\n  it('should return undefined for webpack-dev-server', () => {\n    expect(getIntegrationEntry('wds')).toStrictEqual(undefined);\n  });\n\n  it('should return undefined for unknown integrations', () => {\n    expect(getIntegrationEntry('unknown')).toStrictEqual(undefined);\n  });\n});\n"
  },
  {
    "path": "test/unit/getSocketIntegration.test.js",
    "content": "const getSocketIntegration = require('../../lib/utils/getSocketIntegration');\n\ndescribe('getSocketIntegration', () => {\n  it('should work with webpack-dev-server', () => {\n    const WDSSocket = require.resolve('../../sockets/WDSSocket');\n    expect(getSocketIntegration('wds')).toStrictEqual(WDSSocket);\n  });\n\n  it('should work with webpack-hot-middleware', () => {\n    const WHMEventSource = require.resolve('../../sockets/WHMEventSource');\n    expect(getSocketIntegration('whm')).toStrictEqual(WHMEventSource);\n  });\n\n  it('should work with webpack-plugin-serve', () => {\n    const WPSSocket = require.resolve('../../sockets/WPSSocket');\n    expect(getSocketIntegration('wps')).toStrictEqual(WPSSocket);\n  });\n\n  it('should resolve when module path is provided', () => {\n    const FixtureSocket = require.resolve('./fixtures/socketIntegration');\n    expect(getSocketIntegration(FixtureSocket)).toStrictEqual(FixtureSocket);\n  });\n\n  it('should throw when non-path string is provided', () => {\n    expect(() => getSocketIntegration('unknown')).toThrowErrorMatchingInlineSnapshot(\n      `\"Cannot find module 'unknown' from '../lib/utils/getSocketIntegration.js'\"`\n    );\n  });\n});\n"
  },
  {
    "path": "test/unit/globals.test.js",
    "content": "const { getRefreshGlobalScope } = require('../../lib/globals');\n\ndescribe('getRefreshGlobalScope', () => {\n  it('should work for Webpack 5', () => {\n    const { RuntimeGlobals } = require('webpack');\n    expect(getRefreshGlobalScope(RuntimeGlobals)).toStrictEqual('__webpack_require__.$Refresh$');\n  });\n});\n"
  },
  {
    "path": "test/unit/makeRefreshRuntimeModule.test.js",
    "content": "const makeRefreshRuntimeModule = require('../../lib/utils/makeRefreshRuntimeModule');\n\ndescribe('makeRefreshRuntimeModule', () => {\n  beforeEach(() => {\n    global.__webpack_require__ = { i: [] };\n  });\n\n  afterAll(() => {\n    delete global.__webpack_require__;\n  });\n\n  it('should make runtime module', () => {\n    const webpack = require('webpack');\n\n    let RefreshRuntimeModule;\n    expect(() => {\n      RefreshRuntimeModule = makeRefreshRuntimeModule(webpack);\n    }).not.toThrow();\n\n    expect(() => {\n      new RefreshRuntimeModule();\n    }).not.toThrow();\n  });\n\n  it('should generate with ES5 settings', () => {\n    const webpack = require('webpack');\n    const RuntimeTemplate = require('webpack/lib/RuntimeTemplate');\n\n    const RefreshRuntimeModule = makeRefreshRuntimeModule(webpack);\n    const instance = new RefreshRuntimeModule();\n    instance.compilation = {\n      runtimeTemplate: new RuntimeTemplate(\n        {},\n        { environment: { arrowFunction: false, const: false } },\n        (i) => i\n      ),\n    };\n\n    const runtime = instance.generate();\n    expect(runtime).toMatchInlineSnapshot(`\n\"var setup = function(moduleId) {\n\tvar refresh = {\n\t\tmoduleId: moduleId,\n\t\tregister: function(type, id) {\n\t\t\tvar typeId = moduleId + ' ' + id;\n\t\t\trefresh.runtime.register(type, typeId);\n\t\t},\n\t\tsignature: function() { return refresh.runtime.createSignatureFunctionForTransform(); },\n\t\truntime: {\n\t\t\tcreateSignatureFunctionForTransform: function() { return function(type) { return type; }; },\n\t\t\tregister: function() {}\n\t\t},\n\t};\n\treturn refresh;\n};\n\n__webpack_require__.i.push(function(options) {\n\tvar originalFactory = options.factory;\n\toptions.factory = function(moduleObject, moduleExports, webpackRequire) {\n\t\tvar hotRequire = function(request) { return webpackRequire(request); };\n\t\tvar createPropertyDescriptor = function(name) {\n\t\t\treturn {\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tget: function() { return webpackRequire[name]; },\n\t\t\t\tset: function(value) {\n\t\t\t\t\twebpackRequire[name] = value;\n\t\t\t\t},\n\t\t\t};\n\t\t};\n\t\tfor (var name in webpackRequire) {\n\t\t\tif (name === \"$Refresh$\") continue;\n\t\t\tif (Object.prototype.hasOwnProperty.call(webpackRequire, name)) {\n\t\t\t\tObject.defineProperty(hotRequire, name, createPropertyDescriptor(name));\n\t\t\t}\n\t\t}\n\t\thotRequire.$Refresh$ = setup(options.id);\n\t\toriginalFactory.call(this, moduleObject, moduleExports, hotRequire);\n\t};\n});\"\n`);\n    expect(() => {\n      eval(runtime);\n    }).not.toThrow();\n  });\n\n  it('should make working runtime module with ES6 settings', () => {\n    const webpack = require('webpack');\n    const RuntimeTemplate = require('webpack/lib/RuntimeTemplate');\n\n    const RefreshRuntimeModule = makeRefreshRuntimeModule(webpack);\n    const instance = new RefreshRuntimeModule();\n    instance.compilation = {\n      runtimeTemplate: new RuntimeTemplate(\n        {},\n        { environment: { arrowFunction: true, const: true } },\n        (i) => i\n      ),\n    };\n\n    const runtime = instance.generate();\n    expect(runtime).toMatchInlineSnapshot(`\n\"const setup = (moduleId) => {\n\tconst refresh = {\n\t\tmoduleId: moduleId,\n\t\tregister: (type, id) => {\n\t\t\tconst typeId = moduleId + ' ' + id;\n\t\t\trefresh.runtime.register(type, typeId);\n\t\t},\n\t\tsignature: () => (refresh.runtime.createSignatureFunctionForTransform()),\n\t\truntime: {\n\t\t\tcreateSignatureFunctionForTransform: () => ((type) => (type)),\n\t\t\tregister: x => {}\n\t\t},\n\t};\n\treturn refresh;\n};\n\n__webpack_require__.i.push((options) => {\n\tconst originalFactory = options.factory;\n\toptions.factory = function(moduleObject, moduleExports, webpackRequire) {\n\t\tconst hotRequire = (request) => (webpackRequire(request));\n\t\tconst createPropertyDescriptor = (name) => {\n\t\t\treturn {\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tget: () => (webpackRequire[name]),\n\t\t\t\tset: (value) => {\n\t\t\t\t\twebpackRequire[name] = value;\n\t\t\t\t},\n\t\t\t};\n\t\t};\n\t\tfor (const name in webpackRequire) {\n\t\t\tif (name === \"$Refresh$\") continue;\n\t\t\tif (Object.prototype.hasOwnProperty.call(webpackRequire, name)) {\n\t\t\t\tObject.defineProperty(hotRequire, name, createPropertyDescriptor(name));\n\t\t\t}\n\t\t}\n\t\thotRequire.$Refresh$ = setup(options.id);\n\t\toriginalFactory.call(this, moduleObject, moduleExports, hotRequire);\n\t};\n});\"\n`);\n    expect(() => {\n      eval(runtime);\n    }).not.toThrow();\n  });\n});\n"
  },
  {
    "path": "test/unit/normalizeOptions.test.js",
    "content": "const normalizeOptions = require('../../lib/utils/normalizeOptions');\n\n/** @type {Partial<import('../../types/types').ReactRefreshPluginOptions>} */\nconst DEFAULT_OPTIONS = {\n  exclude: /node_modules/i,\n  include: /\\.([cm]js|[jt]sx?|flow)$/i,\n  overlay: {\n    entry: require.resolve('../../client/ErrorOverlayEntry'),\n    module: require.resolve('../../overlay'),\n    sockIntegration: 'wds',\n  },\n};\n\ndescribe('normalizeOptions', () => {\n  it('should return default options when an empty object is received', () => {\n    expect(normalizeOptions({})).toStrictEqual(DEFAULT_OPTIONS);\n  });\n\n  it('should return user options', () => {\n    expect(\n      normalizeOptions({\n        exclude: 'exclude',\n        forceEnable: true,\n        include: 'include',\n        library: 'library',\n        overlay: {\n          entry: 'entry',\n          module: 'overlay',\n          sockIntegration: 'whm',\n        },\n      })\n    ).toStrictEqual({\n      exclude: 'exclude',\n      forceEnable: true,\n      include: 'include',\n      library: 'library',\n      overlay: {\n        entry: 'entry',\n        module: 'overlay',\n        sockIntegration: 'whm',\n      },\n    });\n  });\n\n  it('should return default for overlay options when it is true', () => {\n    expect(normalizeOptions({ overlay: true })).toStrictEqual(DEFAULT_OPTIONS);\n  });\n\n  it('should return false for overlay options when it is false', () => {\n    expect(normalizeOptions({ overlay: false })).toStrictEqual({\n      ...DEFAULT_OPTIONS,\n      overlay: false,\n    });\n  });\n\n  it('should keep \"overlay.entry\" when it is false', () => {\n    const options = { ...DEFAULT_OPTIONS };\n    options.overlay.entry = false;\n\n    expect(normalizeOptions(options)).toStrictEqual(options);\n  });\n\n  it('should keep \"overlay.module\" when it is false', () => {\n    const options = { ...DEFAULT_OPTIONS };\n    options.overlay.module = false;\n\n    expect(normalizeOptions(options)).toStrictEqual(options);\n  });\n\n  it('should keep \"overlay.sockIntegration\" when it is false', () => {\n    const options = { ...DEFAULT_OPTIONS };\n    options.overlay.sockIntegration = false;\n\n    expect(normalizeOptions(options)).toStrictEqual(options);\n  });\n});\n"
  },
  {
    "path": "test/unit/validateOptions.test.js",
    "content": "const ReactRefreshPlugin = require('../../lib');\n\ndescribe('validateOptions', () => {\n  it('should accept \"exclude\" when it is a RegExp', () => {\n    expect(() => {\n      new ReactRefreshPlugin({ exclude: /test/ });\n    }).not.toThrow();\n  });\n\n  it('should accept \"exclude\" when it is an absolute path string', () => {\n    expect(() => {\n      new ReactRefreshPlugin({ exclude: '/test' });\n    }).not.toThrow();\n  });\n\n  it('should accept \"exclude\" when it is a string', () => {\n    expect(() => {\n      new ReactRefreshPlugin({ exclude: 'test' });\n    }).not.toThrow();\n  });\n\n  it('should accept \"exclude\" when it is an array of RegExp or strings', () => {\n    expect(() => {\n      new ReactRefreshPlugin({ exclude: [/test/, 'test'] });\n    }).not.toThrow();\n  });\n\n  it('should reject \"exclude\" when it is an object', () => {\n    expect(() => {\n      new ReactRefreshPlugin({ exclude: {} });\n    }).toThrowErrorMatchingInlineSnapshot(`\n      \"Invalid options object. React Refresh Plugin has been initialized using an options object that does not match the API schema.\n       - options.exclude should be one of these:\n         RegExp | string | [RegExp | string, ...] (should not have fewer than 1 item)\n         Details:\n          * options.exclude should be one of these:\n            RegExp | string\n            Details:\n             * options.exclude should be an instance of RegExp.\n             * options.exclude should be a string.\n          * options.exclude should be an array:\n            [RegExp | string, ...] (should not have fewer than 1 item)\"\n    `);\n  });\n\n  it('should accept \"forceEnable\" when it is true', () => {\n    expect(() => {\n      new ReactRefreshPlugin({ forceEnable: true });\n    }).not.toThrow();\n  });\n\n  it('should accept \"forceEnable\" when it is false', () => {\n    expect(() => {\n      new ReactRefreshPlugin({ forceEnable: false });\n    }).not.toThrow();\n  });\n\n  it('should reject \"forceEnable\" when it is not a boolean', () => {\n    expect(() => {\n      new ReactRefreshPlugin({ forceEnable: 1 });\n    }).toThrowErrorMatchingInlineSnapshot(`\n      \"Invalid options object. React Refresh Plugin has been initialized using an options object that does not match the API schema.\n       - options.forceEnable should be a boolean.\"\n    `);\n  });\n\n  it('should accept \"include\" when it is a RegExp', () => {\n    expect(() => {\n      new ReactRefreshPlugin({ include: /test/ });\n    }).not.toThrow();\n  });\n\n  it('should accept \"include\" when it is an absolute path string', () => {\n    expect(() => {\n      new ReactRefreshPlugin({ include: '/test' });\n    }).not.toThrow();\n  });\n\n  it('should accept \"include\" when it is a string', () => {\n    expect(() => {\n      new ReactRefreshPlugin({ include: 'test' });\n    }).not.toThrow();\n  });\n\n  it('should accept \"include\" when it is an array of RegExp or strings', () => {\n    expect(() => {\n      new ReactRefreshPlugin({ include: [/test/, 'test'] });\n    }).not.toThrow();\n  });\n\n  it('should reject \"include\" when it is an object', () => {\n    expect(() => {\n      new ReactRefreshPlugin({ include: {} });\n    }).toThrowErrorMatchingInlineSnapshot(`\n      \"Invalid options object. React Refresh Plugin has been initialized using an options object that does not match the API schema.\n       - options.include should be one of these:\n         RegExp | string | [RegExp | string, ...] (should not have fewer than 1 item)\n         Details:\n          * options.include should be one of these:\n            RegExp | string\n            Details:\n             * options.include should be an instance of RegExp.\n             * options.include should be a string.\n          * options.include should be an array:\n            [RegExp | string, ...] (should not have fewer than 1 item)\"\n    `);\n  });\n\n  it('should accept \"library\" when it is a string', () => {\n    expect(() => {\n      new ReactRefreshPlugin({ library: 'library' });\n    }).not.toThrow();\n  });\n\n  it('should reject \"library\" when it is not a string', () => {\n    expect(() => {\n      new ReactRefreshPlugin({ library: [] });\n    }).toThrowErrorMatchingInlineSnapshot(`\n      \"Invalid options object. React Refresh Plugin has been initialized using an options object that does not match the API schema.\n       - options.library should be a string.\"\n    `);\n  });\n\n  it('should accept \"overlay\" when it is true', () => {\n    expect(() => {\n      new ReactRefreshPlugin({ overlay: true });\n    }).not.toThrow();\n  });\n\n  it('should accept \"overlay\" when it is false', () => {\n    expect(() => {\n      new ReactRefreshPlugin({ overlay: false });\n    }).not.toThrow();\n  });\n\n  it('should accept \"overlay\" when it is an empty object', () => {\n    expect(() => {\n      new ReactRefreshPlugin({ overlay: {} });\n    }).not.toThrow();\n  });\n\n  it('should reject \"overlay\" when it is not a boolean nor an object', () => {\n    expect(() => {\n      new ReactRefreshPlugin({ overlay: 'overlay' });\n    }).toThrowErrorMatchingInlineSnapshot(`\n\"Invalid options object. React Refresh Plugin has been initialized using an options object that does not match the API schema.\n - options.overlay should be one of these:\n   boolean | object { entry?, module?, sockIntegration? }\n   Details:\n    * options.overlay should be a boolean.\n    * options.overlay should be an object:\n      object { entry?, module?, sockIntegration? }\"\n`);\n  });\n\n  it('should accept \"overlay.entry\" when it is an absolute path string', () => {\n    expect(() => {\n      new ReactRefreshPlugin({\n        overlay: { entry: '/test' },\n      });\n    }).not.toThrow();\n  });\n\n  it('should accept \"overlay.entry\" when it is a string', () => {\n    expect(() => {\n      new ReactRefreshPlugin({\n        overlay: { entry: 'test' },\n      });\n    }).not.toThrow();\n  });\n\n  it('should accept \"overlay.entry\" when it is false', () => {\n    expect(() => {\n      new ReactRefreshPlugin({\n        overlay: { entry: false },\n      });\n    }).not.toThrow();\n  });\n\n  it('should reject \"overlay.entry\" when it is not a string nor false', () => {\n    expect(() => {\n      new ReactRefreshPlugin({\n        overlay: { entry: true },\n      });\n    }).toThrowErrorMatchingInlineSnapshot(`\n\"Invalid options object. React Refresh Plugin has been initialized using an options object that does not match the API schema.\n - options.overlay should be one of these:\n   boolean | object { entry?, module?, sockIntegration? }\n   Details:\n    * options.overlay.entry should be one of these:\n      false | string\n      Details:\n       * options.overlay.entry should be equal to constant false.\n       * options.overlay.entry should be a string.\"\n`);\n  });\n\n  it('should accept \"overlay.module\" when it is an absolute path string', () => {\n    expect(() => {\n      new ReactRefreshPlugin({\n        overlay: { module: '/test' },\n      });\n    }).not.toThrow();\n  });\n\n  it('should accept \"overlay.module\" when it is a string', () => {\n    expect(() => {\n      new ReactRefreshPlugin({\n        overlay: { module: 'test' },\n      });\n    }).not.toThrow();\n  });\n\n  it('should accept \"overlay.module\" when it is false', () => {\n    expect(() => {\n      new ReactRefreshPlugin({\n        overlay: { module: false },\n      });\n    }).not.toThrow();\n  });\n\n  it('should reject \"overlay.module\" when it is not a string nor false', () => {\n    expect(() => {\n      new ReactRefreshPlugin({\n        overlay: { module: true },\n      });\n    }).toThrowErrorMatchingInlineSnapshot(`\n\"Invalid options object. React Refresh Plugin has been initialized using an options object that does not match the API schema.\n - options.overlay should be one of these:\n   boolean | object { entry?, module?, sockIntegration? }\n   Details:\n    * options.overlay.module should be one of these:\n      false | string\n      Details:\n       * options.overlay.module should be equal to constant false.\n       * options.overlay.module should be a string.\"\n`);\n  });\n\n  it('should accept \"overlay.sockIntegration\" when it is \"wds\"', () => {\n    expect(() => {\n      new ReactRefreshPlugin({\n        overlay: { sockIntegration: 'wds' },\n      });\n    }).not.toThrow();\n  });\n\n  it('should accept \"overlay.sockIntegration\" when it is \"whm\"', () => {\n    expect(() => {\n      new ReactRefreshPlugin({\n        overlay: { sockIntegration: 'whm' },\n      });\n    }).not.toThrow();\n  });\n\n  it('should accept \"overlay.sockIntegration\" when it is \"wps\"', () => {\n    expect(() => {\n      new ReactRefreshPlugin({\n        overlay: { sockIntegration: 'wps' },\n      });\n    }).not.toThrow();\n  });\n\n  it('should accept \"overlay.sockIntegration\" when it is an absolute path string', () => {\n    expect(() => {\n      new ReactRefreshPlugin({\n        overlay: { sockIntegration: '/test' },\n      });\n    }).not.toThrow();\n  });\n\n  it('should accept \"overlay.sockIntegration\" when it is a string', () => {\n    expect(() => {\n      new ReactRefreshPlugin({\n        overlay: { sockIntegration: 'test' },\n      });\n    }).not.toThrow();\n  });\n\n  it('should accept \"overlay.sockIntegration\" when it is false', () => {\n    expect(() => {\n      new ReactRefreshPlugin({\n        overlay: { sockIntegration: false },\n      });\n    }).not.toThrow();\n  });\n\n  it('should reject \"overlay.sockIntegration\" when it is not a string nor false', () => {\n    expect(() => {\n      new ReactRefreshPlugin({\n        overlay: { sockIntegration: true },\n      });\n    }).toThrowErrorMatchingInlineSnapshot(`\n\"Invalid options object. React Refresh Plugin has been initialized using an options object that does not match the API schema.\n - options.overlay should be one of these:\n   boolean | object { entry?, module?, sockIntegration? }\n   Details:\n    * options.overlay.sockIntegration should be one of these:\n      false | \"wds\" | \"whm\" | \"wps\" | string\n      Details:\n       * options.overlay.sockIntegration should be equal to constant false.\n       * options.overlay.sockIntegration should be one of these:\n         \"wds\" | \"whm\" | \"wps\"\n       * options.overlay.sockIntegration should be a string.\"\n`);\n  });\n\n  it('should reject any unknown options', () => {\n    expect(() => {\n      new ReactRefreshPlugin({ unknown: true });\n    }).toThrowErrorMatchingInlineSnapshot(`\n      \"Invalid options object. React Refresh Plugin has been initialized using an options object that does not match the API schema.\n       - options has an unknown property 'unknown'. These properties are valid:\n         object { esModule?, exclude?, forceEnable?, include?, library?, overlay? }\"\n    `);\n  });\n});\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"allowJs\": true,\n    \"declaration\": true,\n    \"emitDeclarationOnly\": true,\n    \"esModuleInterop\": true,\n    \"module\": \"commonjs\",\n    \"noUnusedLocals\": true,\n    \"outDir\": \"types\",\n    \"resolveJsonModule\": true,\n    \"skipLibCheck\": true,\n    \"strict\": true,\n    \"target\": \"es2018\"\n  },\n  \"include\": [\"./lib/*\", \"./loader/*\", \"./options/*\"],\n  \"exclude\": [\"node_modules\"]\n}\n"
  },
  {
    "path": "types/lib/index.d.ts",
    "content": "export = ReactRefreshPlugin;\ndeclare class ReactRefreshPlugin {\n  /**\n   * @param {import('./types').ReactRefreshPluginOptions} [options] Options for react-refresh-plugin.\n   */\n  constructor(options?: import('./types').ReactRefreshPluginOptions | undefined);\n  /**\n   * @readonly\n   * @type {import('./types').NormalizedPluginOptions}\n   */\n  readonly options: import('./types').NormalizedPluginOptions;\n  /**\n   * Applies the plugin.\n   * @param {import('webpack').Compiler} compiler A webpack compiler object.\n   * @returns {void}\n   */\n  apply(compiler: import('webpack').Compiler): void;\n}\ndeclare namespace ReactRefreshPlugin {\n  export { ReactRefreshPlugin };\n}\n"
  },
  {
    "path": "types/lib/types.d.ts",
    "content": "export type ErrorOverlayOptions = {\n  /**\n   * Path to a JS file that sets up the error overlay integration.\n   */\n  entry?: string | false | undefined;\n  /**\n   * The error overlay module to use.\n   */\n  module?: string | false | undefined;\n  /**\n   * Path to a JS file that sets up the Webpack socket integration.\n   */\n  sockIntegration?:\n    | import('type-fest').LiteralUnion<false | 'wds' | 'whm' | 'wps', string>\n    | undefined;\n};\nexport type NormalizedErrorOverlayOptions = import('type-fest').SetRequired<\n  ErrorOverlayOptions,\n  'entry' | 'module' | 'sockIntegration'\n>;\nexport type ReactRefreshPluginOptions = {\n  /**\n   * Enables strict ES Modules compatible runtime.\n   */\n  esModule?: boolean | import('../loader/types').ESModuleOptions | undefined;\n  /**\n   * Files to explicitly exclude from processing.\n   */\n  exclude?: string | RegExp | (string | RegExp)[] | undefined;\n  /**\n   * Enables the plugin forcefully.\n   */\n  forceEnable?: boolean | undefined;\n  /**\n   * Files to explicitly include for processing.\n   */\n  include?: string | RegExp | (string | RegExp)[] | undefined;\n  /**\n   * Name of the library bundle.\n   */\n  library?: string | undefined;\n  /**\n   * Modifies how the error overlay integration works in the plugin.\n   */\n  overlay?: boolean | ErrorOverlayOptions | undefined;\n};\nexport type OverlayOverrides = {\n  /**\n   * Modifies how the error overlay integration works in the plugin.\n   */\n  overlay: false | NormalizedErrorOverlayOptions;\n};\nexport type NormalizedPluginOptions = import('type-fest').SetRequired<\n  import('type-fest').Except<ReactRefreshPluginOptions, 'overlay'>,\n  'exclude' | 'include'\n> &\n  OverlayOverrides;\n"
  },
  {
    "path": "types/loader/index.d.ts",
    "content": "export = ReactRefreshLoader;\n/**\n * A simple Webpack loader to inject react-refresh HMR code into modules.\n *\n * [Reference for Loader API](https://webpack.js.org/api/loaders/)\n * @this {import('webpack').LoaderContext<import('./types').ReactRefreshLoaderOptions>}\n * @param {string} source The original module source code.\n * @param {import('source-map').RawSourceMap} [inputSourceMap] The source map of the module.\n * @param {*} [meta] The loader metadata passed in.\n * @returns {void}\n */\ndeclare function ReactRefreshLoader(\n  this: import('webpack').LoaderContext<import('./types').ReactRefreshLoaderOptions>,\n  source: string,\n  inputSourceMap?: import('source-map').RawSourceMap | undefined,\n  meta?: any\n): void;\n"
  },
  {
    "path": "types/loader/types.d.ts",
    "content": "export type ESModuleOptions = {\n  /**\n   * Files to explicitly exclude from flagged as ES Modules.\n   */\n  exclude?: string | RegExp | (string | RegExp)[] | undefined;\n  /**\n   * Files to explicitly include for flagged as ES Modules.\n   */\n  include?: string | RegExp | (string | RegExp)[] | undefined;\n};\nexport type ReactRefreshLoaderOptions = {\n  /**\n   * Enables usage of ES6 `const` and `let` in generated runtime code.\n   */\n  const?: boolean | undefined;\n  /**\n   * Enables strict ES Modules compatible runtime.\n   */\n  esModule?: boolean | ESModuleOptions | undefined;\n};\nexport type NormalizedLoaderOptions = import('type-fest').SetRequired<\n  ReactRefreshLoaderOptions,\n  'const'\n>;\n"
  },
  {
    "path": "types/options/index.d.ts",
    "content": "/**\n * Sets a constant default value for the property when it is undefined.\n * @template T\n * @template {keyof T} Property\n * @param {T} object An object.\n * @param {Property} property A property of the provided object.\n * @param {T[Property]} [defaultValue] The default value to set for the property.\n * @returns {T[Property]} The defaulted property value.\n */\nexport function d<T, Property extends keyof T>(\n  object: T,\n  property: Property,\n  defaultValue?: T[Property] | undefined\n): T[Property];\n/**\n * Resolves the value for a nested object option.\n * @template T\n * @template {keyof T} Property\n * @template Result\n * @param {T} object An object.\n * @param {Property} property A property of the provided object.\n * @param {function(T | undefined): Result} fn The handler to resolve the property's value.\n * @returns {Result} The resolved option value.\n */\nexport function n<T, Property extends keyof T, Result>(\n  object: T,\n  property: Property,\n  fn: (arg0: T | undefined) => Result\n): Result;\n"
  },
  {
    "path": "webpack.config.js",
    "content": "const path = require('node:path');\nconst TerserPlugin = require('terser-webpack-plugin');\n\nmodule.exports = {\n  mode: 'production',\n  entry: {\n    client: './client/ReactRefreshEntry.js',\n  },\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new TerserPlugin({\n        extractComments: false,\n        terserOptions: {\n          format: { comments: false },\n        },\n      }),\n    ],\n    nodeEnv: 'development',\n  },\n  output: {\n    filename: '[name].min.js',\n    path: path.resolve(__dirname, 'umd'),\n  },\n};\n"
  }
]