Skip to content

Object.defineProperty called on non-object error with pdfjs-dist in webpack mode (possibly related to webpack/webpack#20095) #89177

@makotot

Description

@makotot

Link to the code that reproduces this issue

https://github.com/makotot/next-react-pdf-webpack-issue

To Reproduce

  1. Clone the reproduction repository
  2. pnpm install
  3. pnpm dev (runs next dev --webpack)
  4. Open http://localhost:3000 in browser
  5. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    WebpackRelated to Webpack with Next.js.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions