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.config.ts - debugging] unable to debug vite config and custom plugins code (VSCode/typescript) #19254

Open
7 tasks done
igrdi opened this issue Jan 21, 2025 · 0 comments

Comments

@igrdi
Copy link

igrdi commented Jan 21, 2025

Describe the bug

I am doing: developing a custom vite plugin and need to debug it in VSCode. For that I've created a project via create vite@latest and vanilla-ts template. Added a vite.config.ts file with a minimal plugin code.

What I expect is: The breakpoints in vite.config.ts are being hit

What actually happening is: The breakpoints are not being hit

I believe the problem is here: (isESM code block)

async function loadConfigFromBundledFile(

because when I removed "type": "module" from package.json, the breakpoints are being hit. But then the CJS deprecated warning appears in the console.

Reproduction

https://github.com/igrdi/vitejs-vite-vite_config_ts-debug

https://stackblitz.com/~/github.com/igrdi/vitejs-vite-vite_config_ts-debug

Steps to reproduce

  1. Create a project vanilla-ts template (for simplicity. Or any other TS template):
npm create vite@latest my-app -- --template vanilla-ts
  1. Add vite.config.ts file with the content:
import { defineConfig } from "vite";
export default defineConfig({
  plugins: [
    {
      name: "vite:custom-plugin",
      transformIndexHtml: {
        order: "pre",
        async handler(code) {
          console.log(code);                  // <- set a breakpoint here
        },
      },
    },
  ],
});
  1. Open JavaScript Debug Terminal in VSCode and run build command:
npm run build

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 18.09 GB / 31.88 GB
  Binaries:
    Node: 22.11.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.9.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.19041.4355
  npmPackages:
    vite: ^6.0.5 => 6.0.10

Used Package Manager

npm

Logs

No response

Validations

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

1 participant