Download next.js/packages/react-refresh-utils/loader.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/react-refresh-utils/loader.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/packages/react-refresh-utils/loader.ts
-
curl -L -o loader.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/react-refresh-utils/loader.ts
1 kB
| import type { LoaderDefinition } from 'webpack' | |
| import RefreshModuleRuntime from './internal/ReactRefreshModule.runtime' | |
| let refreshModuleRuntime = RefreshModuleRuntime.toString() | |
| refreshModuleRuntime = refreshModuleRuntime | |
| .slice( | |
| refreshModuleRuntime.indexOf('{') + 1, | |
| refreshModuleRuntime.lastIndexOf('}') | |
| ) | |
| // Given that the import above executes the module we need to make sure it does not crash on `import.meta` not being allowed. | |
| .replace('global.importMeta', 'import.meta') | |
| let commonJsrefreshModuleRuntime = refreshModuleRuntime.replace( | |
| 'import.meta.webpackHot', | |
| 'module.hot' | |
| ) | |
| const ReactRefreshLoader: LoaderDefinition = function ReactRefreshLoader( | |
| source, | |
| inputSourceMap | |
| ) { | |
| this.callback( | |
| null, | |
| `${source}\n\n;${ | |
| // Account for commonjs not supporting `import.meta | |
| this.resourcePath.endsWith('.cjs') | |
| ? commonJsrefreshModuleRuntime | |
| : refreshModuleRuntime | |
| }`, | |
| inputSourceMap | |
| ) | |
| } | |
| export default ReactRefreshLoader | |