Skip to content

fix(vite): resolve ESM types correctly under NodeNext and Deno#626

Merged
JoviDeCroock merged 1 commit into
mainfrom
JoviDeCroock/prefresh-issue-625
Jun 12, 2026
Merged

fix(vite): resolve ESM types correctly under NodeNext and Deno#626
JoviDeCroock merged 1 commit into
mainfrom
JoviDeCroock/prefresh-issue-625

Conversation

@JoviDeCroock

@JoviDeCroock JoviDeCroock commented Jun 12, 2026

Copy link
Copy Markdown
Member

Problem

TypeScript 6.0 (shipped in Deno v2.8.3) rejects export = declarations resolved through an exports.import condition as a hard error, breaking deno check for every Fresh user depending on @prefresh/vite.

Fixes #625

Changes

  • Split the exports map per condition: import now resolves to a real ESM entry (src/index.mjs, a thin wrapper re-exporting the plugin as default) typed by a new index.d.mts using export default, while require keeps src/index.js typed by index.d.ts using export =.
  • Inlined the FilterPattern type in both declaration files. @rollup/pluginutils@4's types don't resolve under moduleResolution: NodeNext (TS7016), which broke any consumer type-checking without skipLibCheck.
  • Cleaned the stale files array (dist/runtime/utils don't exist in this package) to src, index.d.ts, index.d.mts. The published tarball previously only worked because npm auto-includes the main file.

The import condition now points at a real ESM entry (src/index.mjs)
typed by index.d.mts (export default), while require keeps index.d.ts
(export =). Previously both conditions served the CJS file typed with
export =, which TypeScript 6 / Deno 2.8.3+ reject when resolved
through the import condition.

Also inline FilterPattern instead of importing it from
@rollup/pluginutils, whose types do not resolve under NodeNext.

Fixes #625
@changeset-bot

changeset-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4bbe51f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@prefresh/vite Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@JoviDeCroock JoviDeCroock merged commit 5353098 into main Jun 12, 2026
1 check passed
@JoviDeCroock JoviDeCroock deleted the JoviDeCroock/prefresh-issue-625 branch June 12, 2026 16:54
@github-actions github-actions Bot mentioned this pull request Jun 12, 2026
@SisyphusZheng

Copy link
Copy Markdown

thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

types: export = in index.d.ts contradicts exports.import in package.json

2 participants