Skip to content

[bug]: UploadThing packages fail to compile with Next.js 16 Turbopack mode #1242

@hyper-lode

Description

@hyper-lode

Provide environment information

System:
    OS: macOS 15.6.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 2.21 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.5.0 - /Users/hal8/.nvm/versions/node/v24.5.0/bin/node
    npm: 11.6.0 - /Users/hal8/.nvm/versions/node/v24.5.0/bin/npm
    bun: 1.2.18 - /Users/hal8/.bun/bin/bun
  Browsers:
    Chrome: 141.0.7390.108
    Edge: 141.0.3537.92
    Firefox: 144.0
    Safari: 26.0.1
  npmPackages:
    @uploadthing/react: ^7.3.3 => 7.3.3 
    typescript: ^5.9.3 => 5.9.3 
    uploadthing: ^7.7.4 => 7.7.4

Describe the bug

When running Next.js 16 with Turbopack (the default in Next.js 16), UploadThing packages fail to compile with multiple module resolution and parsing errors. The application crashes on startup when trying to compile any page that imports UploadThing components.

Expected Behavior:
UploadThing should work seamlessly with Next.js 16's Turbopack bundler.

Actual Behavior:
The dev server fails to compile pages that use UploadThing, throwing multiple errors related to:

  • Unknown module types for README.md and LICENSE files
  • ECMAScript parsing errors in LICENSE files
  • Module format mismatches (CommonJS vs ESM) in .cts files
  • Missing .cjs file resolution

Link to reproduction

https://stackblitz.com/github/pingdotgg/uploadthing/tree/main/examples/minimal-appdir

To reproduce

  1. Create a Next.js 16 project (or upgrade existing project to Next.js 16)
  2. Install UploadThing: npm install uploadthing @uploadthing/react
  3. Import and use any UploadThing component (e.g., in a page component)
  4. Run npm run dev (Next.js 16 uses Turbopack by default)
  5. Navigate to a page that uses UploadThing
  6. Observe compilation errors

Additional information

Error Output

⨯ ./node_modules/@uploadthing/mime-types/README.md
Unknown module type
This module doesn't have an associated type. Use a known file extension, or register a loader for it.

⨯ ./node_modules/@uploadthing/react/README.md
Unknown module type
This module doesn't have an associated type. Use a known file extension, or register a loader for it.

⨯ ./node_modules/@uploadthing/mime-types/LICENSE:1:6
Parsing ecmascript source code failed
> 1 | (The MIT License)
    |      ^^^
Expected ',', got 'MIT'

⨯ ./node_modules/@uploadthing/react/LICENSE:1:5
Parsing ecmascript source code failed
> 1 | MIT License
    |     ^^^^^^^
Expected ';', '}' or <eof>

⨯ ./node_modules/@uploadthing/mime-types/application/index.d.cts
Specified module format (CommonJs) is not matching the module format of the source code (EcmaScript Modules)

⨯ ./node_modules/@uploadthing/react/dist/index.d.cts
Specified module format (CommonJs) is not matching the module format of the source code (EcmaScript Modules)

⨯ ./node_modules/@uploadthing/react/native/index.d.cts:1:1
Module not found: Can't resolve '../dist/use-uploadthing-BnX8QvFV.cjs'

⨯ ./node_modules/@uploadthing/react/dist/index.d.cts:1:1
Module not found: Can't resolve './use-uploadthing-BnX8QvFV.cjs'

Suggested Fix

The UploadThing package may need to:

  1. Exclude non-code files (README.md, LICENSE) from being processed by bundlers
  2. Ensure CommonJS type definition files (.d.cts) properly align with the actual module format
  3. Verify that all referenced .cjs files exist in the distributed package
  4. Add explicit Turbopack compatibility testing to CI/CD pipeline

👨‍👧‍👦 Contributing

  • 🙋‍♂️ Yes, I'd be down to file a PR fixing this bug!

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:packagesissue regarding one of the uploadthing packagesstatus: in progresswork is currently underway to address this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions