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

RunnableDevEnvironment is export from .d.ts as class, but it's not exported from .js #18998

Open
7 tasks done
hi-ogawa opened this issue Dec 18, 2024 · 1 comment
Open
7 tasks done

Comments

@hi-ogawa
Copy link
Collaborator

hi-ogawa commented Dec 18, 2024

Describe the bug

import { RunnableDevEnvironment } from 'vite';
console.log(RunnableDevEnvironment);
failed to load config from /home/projects/vitejs-vite-zmc8qxuk/vite.config.ts
error when starting dev server:
file:///home/projects/vitejs-vite-zmc8qxuk/node_modules/.vite-temp/vite.config.ts.timestamp-1734498569035-d5fc4179877e1.mjs:2
import { RunnableDevEnvironment } from "file:///home/projects/vitejs-vite-zmc8qxuk/node_modules/vite/dist/node/index.js";
         ^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: The requested module 'file:///home/projects/vitejs-vite-zmc8qxuk/node_modules/vite/dist/node/index.js' does not provide an export named 'RunnableDevEnvironment'

This is exported as type in the source, but it looks like this is somehow dropped in packaged dts.

export {
createRunnableDevEnvironment,
isRunnableDevEnvironment,
type RunnableDevEnvironment,
type RunnableDevEnvironmentContext,
} from './server/environments/runnableEnvironment'

export { ..., RunnableDevEnvironment, type RunnableDevEnvironmentContext, ... };

This probably makes IDE to autocomplete RunnableDevEnvironment without type and that got me runtime errors several times.

Reproduction

https://stackblitz.com/edit/vitejs-vite-zmc8qxuk?file=vite.config.ts

Steps to reproduce

  • open stackblitz

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    vite: ^6.0.3 => 6.0.3

Used Package Manager

npm

Logs

No response

Validations

@sapphi-red
Copy link
Member

I think it's caused by Swatinem/rollup-plugin-dts#311.
If I change RunnableDevEnvironment in dist/node/index.d.ts to type RunnableDevEnvironment, then TypeScript correctly shows an error.

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

No branches or pull requests

2 participants