Repository navigation
Conversation
Contributor
size-limit report 📦Compared: 6cade8d (PR test merge using develop at 73e928a) Against: 73e928a (develop) · base run #65941 ✅ Baseline matches: this diff contains only this PR's changes.
|
Contributor
Optional E2E testsSome optional checks were not successful. They do not block the merge. 4 not successful, 55 successful. See the run.
Successful checks
|
…cript TypeScript reads our `.d.ts` files as CommonJS, also under the `import` condition. So `import Sentry from '@sentry/node'` type-checks in ESM code, although the ESM builds have no default export. At runtime Node then fails with `SyntaxError: ... does not provide an export named 'default'`, and bundlers fail or give `undefined`. The `import` types of every entry with an ESM build now point to a `.d.mts` file that `write-esm-types.mjs` writes after `tsc`. It re-exports the `.d.ts` file next to it, so TypeScript reads the same declarations as ESM and reports TS1192 for the default import. CJS consumers keep the `.d.ts` types, so their default import still works. - Entries with a real default export get a `.d.mts` file that keeps the default under `nodenext`. - `@sentry/nextjs` and `@sentry/remix` keep the `.d.ts` types for the `node` condition, because Node loads their CJS build also for `import`. - ESM-only entries (`@sentry/nitro`, `@sentry/nuxt/module`) get only the `.d.mts` types. - `types` is now the first condition of the `./cloudflare` entries of `@sentry/react-router` and `@sentry/remix`, so TypeScript uses it. The new `package-types` E2E app checks all packages with attw, type-checks a namespace and a default import of every typed entry with TypeScript 5.0, 5.9, 6.0 and 7.0 in `nodenext`, `bundler` and `node10` mode and with the `react-native` condition, and checks that a CJS build sets `__esModule` only for entries with a default export. It fails if a package with types is not one of its dependencies, or if an entry has no types and is not a known JS-only entry (hooks, loaders, injected files). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JPeer264
force-pushed
the
jp/esm-types-default-import
branch
from
November 13, 2026 08:31
e3edd99 to
449bbd8
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #3105
Description
This adds ESM type files (
.d.mts) for theimportcondition of every typed entry. TypeScript now reportsimport Sentry from '@sentry/node'in ESM as an error. Before, this import passed the type check and failed at runtime. CJS keeps the.d.tsfiles, so nothing changes there.The new
package-typesE2E app checks all packages with attw, and type-checks every entry with TypeScript 5.0, 5.9, 6.0 and 7.0 innodenext,bundler,node10and React Native setups. A new entry without.d.mtstypes fails this app. Most of the added lines are this app.Types decisions
Each
.d.mtsis a one-line re-export of its.d.ts(export * from './index.js';), written by a script aftertsc. A second fulltscoutput in ESM format would declare every class twice, and TypeScript would then reject an instance from one copy where the other copy is expected (TS2345).Release decisions
This targets a minor release, because in most setups the code that now fails the type-check also fails at runtime. The alternative is v12 with a
MIGRATION.mdentry, because of the cases in "Known issues".Known issues
import * as Sentry.bundlermode reads the ESM types."type": "module"and a CJS test transform (for example Jest).bundlermode, TypeScript 5.0 to 5.5 still accept a default import.