Regression: React.use build error with React 18 and Webpack/Rspack
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15.1k
- Forks
- 1.9k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 143
Description
Which project does this relate to?
Router
Describe the bug
Build error on using Webpack/Rspack bundlers.
rspack build
ERROR in ./node_modules/@tanstack/react-router/dist/esm/utils.js 6:19-33
× ESModulesLinkingError: export 'use' (imported as 'React$1') was not found in 'react' (possible exports: Children, Component, Fragment, Profiler, PureComponent, StrictMode, Suspense, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, act, cloneElement, createContext, createElement, createFactory, createRef, forwardRef, isValidElement, lazy, memo, startTransition, unstable_act, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore, useTransition, version)
╭─[6:18]
4 │ * React.use if available (React 19+), undefined otherwise.
5 │ * Use dynamic lookup to avoid Webpack compilation errors with React 18.
6 │ */ var reactUse = React$1["use"];
· ──────────────
7 │ var useLayoutEffect = typeof window !== "undefined" ? React$1.useLayoutEffect : React$1.useEffect;
8 │ /**
╰────
Rspack compiled with 1 error in 465 ms
error: script "build" exited with code 1
Similar to #6332 #7176
Complete minimal reproducer
https://github.com/agneym/tanstack-router-rspack-use
Steps to Reproduce the Bug
bun install
bun run build
Expected behavior
No errors
Screenshots or Videos
No response
Platform
- Router / Start Version: 1.170.10
- OS: macOS
- Browser: [e.g. Chrome, Safari, Firefox]
- Browser Version: [e.g. 91.1]
- Bundler: rspack
- Bundler Version: 2.0.6
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked minimal reproducer by running bun install and bun run build, then inspect the generated node_modules/@tanstack/react-router/dist/esm/utils.js around the React.use access. Review related issues #6332 and #7176, and consider the React 18 and React 19 behavior; done means the Rspack/Webpack build completes without errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript, webpack
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100