Skip to content

Importing resource with URL no longer bundles the asset (>=7.1.0 regression) #20631

@nocive

Description

@nocive

Describe the bug

A standard integration of react-pdf with pdfjs-dist as described in their documentation works correctly with vite 7.0.6 and older but not with 7.1.0 or newer.

Given the following minimal example of react-pdf:

import { pdfjs } from 'react-pdf'

pdfjs.GlobalWorkerOptions.workerSrc = new URL(
  'pdfjs-dist/build/pdf.worker.min.mjs',
  import.meta.url,
).toString()

With vite 7.0.6 or older the pdf.worker.min.mjs asset is correctly bundled and present in the dist directory:

dist/assets/pdf.worker.min--PgD6g2g.mjs              1,035.02 kB

However, with vite 7.1.0 or newer it is not.

Reproduction

https://stackblitz.com/edit/vitejs-vite-ybwgh9rm?file=src%2Fmain.js

Steps to reproduce

  • Open the reproduction
  • Build it with yarn build and observe the pdf.worker.min.mjs file being bundled by vite
  • Upgrade vite to 7.1.0 or newer with yarn add [email protected]
  • Run yarn build again and observe the absence of the pdf.worker.min.mjs asset.

System Info

System:
    OS: Linux 6.12 Manjaro Linux
    CPU: (12) x64 13th Gen Intel(R) Core(TM) i7-1365U
    Memory: 21.57 GB / 31.01 GB
    Container: Yes
    Shell: 5.3.0 - /bin/bash
  Binaries:
    Node: 24.4.1 - /usr/bin/node
    Yarn: 4.9.1 - /usr/bin/yarn
    npm: 11.4.2 - /usr/bin/npm
  npmPackages:
    @vitejs/plugin-react: ^5.0.0 => 5.0.0 
    vite: 7.0.6 => 7.0.6

Used Package Manager

yarn

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions