Skip to content

@sentry/browser's require types are missing #12295

Closed
@davidmurdoch

Description

@davidmurdoch

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/browser

SDK Version

8.7.0

Framework Version

No response

Link to Sentry event

No response

SDK Setup

No response

Steps to Reproduce

Init a new node project (I used node 20 with yarn 1)

run:

yarn init -y

run:

yarn add typescript@5.4.5 @sentry/browser@8.7.0

create tsconfig.json:

{
    "compilerOptions": {
        "strict": true, // changes type warning to error
        "moduleResolution": "node16" // causes typescript to use `require` resolution instead of `import`
    }
}

create index.ts:

import * as Sentry from "@sentry/browser";

You'll find that the project can't compile because import * as Sentry from "@sentry/browser"; errors because Could not find a declaration file for module '@sentry/browser'.

This is because the package.json for '@sentry/browser' (the published version, not the version in this repo) has this exports section:


"exports": {
    "./package.json": "./package.json",
    ".": {
      "import": {
        "types": "./types/index.d.ts",
        "default": "./esm/index.js"
      },
      "require": {
        "types": "./build/npm.types/index.d.ts",
        "default": "./cjs/index.js"
      }
    }
  },
  

which specifies that require types live at ./build/npm.types/index.d.ts, but this file doesn't exist.

Maybe related, but the published package.json doesn't match what's in this repo at time of release. Yikes.

Expected Result

types should work

Actual Result

types don't work

Metadata

Metadata

Assignees

Labels

Package: browserIssues related to the Sentry Browser SDK

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions