From 509387f468d4787e4a0f023bf2e88163443d3c08 Mon Sep 17 00:00:00 2001 From: Maks Pikov Date: Mon, 13 Apr 2026 22:08:14 +0000 Subject: [PATCH 1/3] fix(react-router): prevent webpack static analysis of React.use with let binding --- packages/react-router/src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-router/src/utils.ts b/packages/react-router/src/utils.ts index beed649bb9..8052d007e2 100644 --- a/packages/react-router/src/utils.ts +++ b/packages/react-router/src/utils.ts @@ -5,7 +5,7 @@ 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' +let REACT_USE = 'use' /** * React.use if available (React 19+), undefined otherwise. From 4be1f89b119406a0e88640baf25aa354e1f60134 Mon Sep 17 00:00:00 2001 From: Manuel Schiller Date: Wed, 15 Apr 2026 04:22:15 +0200 Subject: [PATCH 2/3] disable eslint --- packages/react-router/src/utils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-router/src/utils.ts b/packages/react-router/src/utils.ts index 8052d007e2..f3cbf54613 100644 --- a/packages/react-router/src/utils.ts +++ b/packages/react-router/src/utils.ts @@ -5,6 +5,7 @@ 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. +// eslint-disable-next-line prefer-const -- Must be `let` to prevent bundler constant-folding let REACT_USE = 'use' /** From 09a008272f77350afa0917999d6730a30641a8a1 Mon Sep 17 00:00:00 2001 From: Manuel Schiller Date: Sat, 18 Apr 2026 21:38:58 +0200 Subject: [PATCH 3/3] add changeset --- .changeset/fix-react-router-webpack-use-analysis.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fix-react-router-webpack-use-analysis.md 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