Link to the code that reproduces this issue
https://github.com/makotot/next-react-pdf-webpack-issue
To Reproduce
- Clone the reproduction repository
pnpm install
pnpm dev (runs next dev --webpack)
- Open http://localhost:3000 in browser
- See error in console:
Uncaught TypeError: Object.defineProperty called on non-object
Current vs. Expected behavior
Current: When using react-pdf (which depends on pdfjs-dist) with Next.js 16 and webpack mode, the app
crashes with TypeError: Object.defineProperty called on non-object.
Expected: The app should work without errors.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin 25.2.0
Binaries:
Node: 22.x
pnpm: 10.x
Relevant Packages:
next: 16.1.6
react: 19.0.0
react-pdf: 10.3.0
Which area(s) are affected? (Select all that apply)
Webpack
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
This issue appears to be the same as webpack/webpack#20095, which was fixed in webpack 5.103.0.
Next.js 16.1.6 lists webpack 5.98.0 in devDependencies, which is likely bundled in dist/compiled/webpack/bundle5.js.
May be related: #52542