Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite-node uses undeclared export vite/types/hot #3704

Closed
6 tasks done
just-boris opened this issue Jun 29, 2023 · 2 comments · Fixed by #3993
Closed
6 tasks done

Vite-node uses undeclared export vite/types/hot #3704

just-boris opened this issue Jun 29, 2023 · 2 comments · Fixed by #3993

Comments

@just-boris
Copy link

just-boris commented Jun 29, 2023

Describe the bug

This line uses an undeclared export:

import type { ViteHotContext } from 'vite/types/hot'

When running typescript with "moduleResolution": "bundler", it fails compilation with undeclared exports.

The allowed vite exports can be found here: https://github.com/vitejs/vite/blob/126e93e6693474a038a5053b7cefb99295f21eb5/packages/vite/package.json#L21-L32

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-spzqkv?file=package.json,tsconfig.json&initialPath=__vitest__/

System Info

n/a

Used Package Manager

npm

Validations

@stackblitz
Copy link

stackblitz bot commented Jun 29, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@Maxim-Mazurok
Copy link
Contributor

Maxim-Mazurok commented Aug 18, 2023

My temporary workaround using patch-package:

diff --git a/node_modules/vite-node/dist/server.d.ts b/node_modules/vite-node/dist/server.d.ts
index a21e596..80b6bd2 100644
--- a/node_modules/vite-node/dist/server.d.ts
+++ b/node_modules/vite-node/dist/server.d.ts
@@ -1,3 +1,4 @@
+//@ts-expect-error
 import { TransformResult, ViteDevServer } from 'vite';
 import { E as EncodedSourceMap } from './types.d-7442d07f.js';
 import { g as DebuggerOptions, D as DepsHandlingOptions, f as ViteNodeServerOptions, F as FetchResult, e as ViteNodeResolveId } from './types-e8623e9c.js';
diff --git a/node_modules/vite-node/dist/types-e8623e9c.d.ts b/node_modules/vite-node/dist/types-e8623e9c.d.ts
index dfe926f..ac99fe8 100644
--- a/node_modules/vite-node/dist/types-e8623e9c.d.ts
+++ b/node_modules/vite-node/dist/types-e8623e9c.d.ts
@@ -1,3 +1,4 @@
+//@ts-expect-error
 import { ViteHotContext } from 'vite/types/hot';
 import { E as EncodedSourceMap } from './types.d-7442d07f.js';
 
node_modules/vite-node/dist/server.d.ts:1:48 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("vite")' call instead.

1 import { TransformResult, ViteDevServer } from 'vite';
                                                 ~~~~~~

node_modules/vite-node/dist/types-e8623e9c.d.ts:1:32 - error TS2307: Cannot find module 'vite/types/hot' or its corresponding type declarations.

1 import { ViteHotContext } from 'vite/types/hot';
                                 ~~~~~~~~~~~~~~~~


Found 2 errors in 2 files.

Errors  Files
     1  node_modules/vite-node/dist/server.d.ts:1
     1  node_modules/vite-node/dist/types-e8623e9c.d.ts:1

@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants