Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/clean-types-resolve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@prefresh/vite': patch
---

Fix type resolution under `moduleResolution: NodeNext` and Deno

The `import` condition now resolves to a real ESM entry (`src/index.mjs`) with matching ESM type declarations (`index.d.mts` using `export default`), while `require` keeps the CommonJS declarations (`index.d.ts` using `export =`). Previously the ESM entry was typed with a CJS-style `export =` declaration, which TypeScript 6 / Deno 2.8.3+ reject as a hard error.

Also inline the `FilterPattern` type instead of importing it from `@rollup/pluginutils`, whose types do not resolve under NodeNext.
13 changes: 13 additions & 0 deletions packages/vite/index.d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { PluginOption } from 'vite';

type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null;

interface Options {
parserPlugins?: readonly string[];
include?: FilterPattern;
exclude?: FilterPattern;
}

declare const prefreshPlugin: (options?: Options) => Promise<PluginOption>;

export default prefreshPlugin;
3 changes: 2 additions & 1 deletion packages/vite/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FilterPattern } from '@rollup/pluginutils';
import { PluginOption } from 'vite';

type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null;

interface Options {
parserPlugins?: readonly string[];
include?: FilterPattern;
Expand Down
18 changes: 11 additions & 7 deletions packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,24 @@
"types": "index.d.ts",
"exports": {
".": {
"types": "./index.d.ts",
"require": "./src/index.js",
"import": "./src/index.js"
"import": {
"types": "./index.d.mts",
"default": "./src/index.mjs"
},
"require": {
"types": "./index.d.ts",
"default": "./src/index.js"
}
},
"./package.json": "./package.json"
},
"modes": {
"default": "src/index.js"
},
"files": [
"dist",
"runtime",
"utils",
"index.d.ts"
"src",
"index.d.ts",
"index.d.mts"
],
"scripts": {
"lint": "eslint src",
Expand Down
3 changes: 3 additions & 0 deletions packages/vite/src/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import prefreshPlugin from './index.js';

export default prefreshPlugin;
Loading