diff --git a/.changeset/fix-react-router-webpack-use-analysis.md b/.changeset/fix-react-router-webpack-use-analysis.md new file mode 100644 index 0000000000..fd9f53572b --- /dev/null +++ b/.changeset/fix-react-router-webpack-use-analysis.md @@ -0,0 +1,5 @@ +--- +'@tanstack/react-router': patch +--- + +fix(react-router): prevent webpack static analysis of `React.use` with let binding diff --git a/packages/react-router/src/utils.ts b/packages/react-router/src/utils.ts index beed649bb9..f3cbf54613 100644 --- a/packages/react-router/src/utils.ts +++ b/packages/react-router/src/utils.ts @@ -5,7 +5,8 @@ import * as React from 'react' // React 18 with Webpack, which statically analyzes imports and fails when it // sees React.use referenced (since 'use' is not exported from React 18). // This uses a dynamic string lookup to avoid the static analysis. -const REACT_USE = 'use' +// eslint-disable-next-line prefer-const -- Must be `let` to prevent bundler constant-folding +let REACT_USE = 'use' /** * React.use if available (React 19+), undefined otherwise.