@tanstack/router-plugin
Version:
Modern and scalable routing for React applications
21 lines (20 loc) • 991 B
text/typescript
import { Config } from '../config.cjs';
import type * as t from '@babel/types';
/**
* Emits HMR accept code for bundlers with webpack-compatible `module.hot`
* semantics (classic webpack via `import.meta.webpackHot`, and Rspack).
*
* Unlike Vite's `hot.accept((newModule) => {...})` — where the callback receives
* the freshly re-imported module — webpack re-executes the module factory on
* accept, so our HMR logic must live at module top level and read the previous
* `routeId` out of `hot.data`. `hot.dispose` stashes it for the next run, and
* `hot.accept()` (no callback) enrolls us as a self-accepting boundary.
*
* Returns an array of statements so that for React we can prepend an
* `import { performReactRefresh } from 'react-refresh/runtime'` hoisted to the
* top of the module.
*/
export declare function createWebpackHmrStatement(stableRouteOptionKeys: Array<string>, opts: {
targetFramework: Config['target'];
routeId?: string;
}): Array<t.Statement>;