Vite/Rollup build fails to resolve regenerator-runtime/runtime imported by exceljs.browser.js
Description
Building a React application with Vite and pnpm fails because exceljs/lib/exceljs.browser.js imports regenerator-runtime/runtime, but that package cannot be resolved from ExcelJS.
Error
[vite]: Rollup failed to resolve import "regenerator-runtime/runtime"
from "node_modules/.pnpm/[email protected]/node_modules/exceljs/lib/exceljs.browser.js".
This is most likely unintended because it can break your application at runtime.Environment
- ExcelJS:
4.4.0 - Vite:
8.0.16 - Package manager: pnpm
- Node.js:
22.19.17 - Application: React
Steps to reproduce
- Install ExcelJS in a pnpm-managed Vite application:
pnpm add [email protected]- Import ExcelJS:
import ExcelJS from 'exceljs';
const workbook = new ExcelJS.Workbook();- Run the production build:
pnpm build- Rollup fails to resolve:
regenerator-runtime/runtimeActual behavior
The consuming application must explicitly install regenerator-runtime even though it is imported from ExcelJS code:
pnpm add regenerator-runtimeAdding it as a direct dependency allows the build to complete.
Expected behavior
Installing and importing ExcelJS should provide all runtime dependencies required by its distributed browser entry. Consumers should not need to discover and explicitly install an undeclared transitive runtime dependency.
Additional context
This appears related to #1903, although that issue concerns Angular and @babel/runtime/regenerator. This case specifically involves:
exceljs/lib/exceljs.browser.js
→ regenerator-runtime/runtime
→ Vite/Rollup resolution failure with pnpmpnpm’s strict dependency isolation may expose the issue where dependency-hoisting package managers do not.
Could regenerator-runtime be declared as a production dependency of ExcelJS, or could the browser entry be built without requiring this external runtime?
Source: exceljs/exceljs