Skip to content

@sentry/bundler-plugins imports types from rollup, which causes a TS error because it's an optional dependency #22296

Description

@aguo-ntech

@sentry/bundler-plugins declares rollup as an optional peer dependency, but its built type definitions for the ./rollup export import TransformResult directly from rollup.

Because the ./vite export transitively imports from the rollup module, consumers of @sentry/vite-plugin (or @sentry/bundler-plugins/vite) who do not have rollup installed hit a TS2307 error.

Reproduction

import { sentryVitePlugin } from '@sentry/vite-plugin';

TypeScript reports:

node_modules/@sentry/bundler-plugins/build/types/rollup/index.d.ts:5:38 - error TS2307: Cannot find module 'rollup' or its corresponding type declarations.

5 import type { TransformResult } from 'rollup';

Findings

  • packages/bundler-plugins/package.json has rollup in peerDependencies with optional: true.
  • packages/bundler-plugins/src/rollup/index.ts line 23: import type { TransformResult } from 'rollup';.
  • packages/bundler-plugins/src/vite/index.ts imports from ../rollup, so the Vite type path depends on the Rollup type file.

Metadata

Metadata

Assignees

Labels

Fields

No fields configured for issues without a type.

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions