PepsRyuu / nollup

Rollup compatible development bundler for fast rebuilds and HMR.
MIT License
488 stars 28 forks source link

Debugging in VS Code? #201

Closed zgoda closed 3 years ago

zgoda commented 3 years ago

A question: how do I set up VS Code launch configuration so internal debugger works with nollup based project?

My current config results in unbound breakpoints:

        {
            "type": "pwa-chrome",
            "request": "launch",
            "name": "Launch Chrome against localhost",
            "url": "http://localhost:8080",
            "webRoot": "${workspaceFolder}/src"
        }

For reference, that's my Nollup rc file:

module.exports = {
  contentBase: 'public',
  port: 8080,
  hot: true
};

and Rollup bundling config:

{
  input: './src/main.js',
  output: {
    dir: 'build',
    format: 'esm',
    entryFileNames: '[name].[hash].js',
    assetFileNames: '[name].[hash][extname]',
    sourceMap: true,
  },
},
PepsRyuu commented 3 years ago

I don't use this feature, and in my first time using it, it seems to work fine. What if you remove src from the webRoot?

zgoda commented 3 years ago

Breakpoint is still unbound.

Zrzut ekranu z 2021-05-23 21-43-13

The same VSC launch configuration works for webpack projects with that kind of code layout.

PepsRyuu commented 3 years ago

Can you provide a reproducible example?

zgoda commented 3 years ago

Minimal repro: https://github.com/zgoda/nollup-vsc-debug-cfg

This is basically Preact template with some minimal code to be able to set breakpoints, eg on line 10 in src/App.js. https://github.com/zgoda/nollup-vsc-debug-cfg/blob/master/src/App.js#L10

PepsRyuu commented 3 years ago

image

Works fine for me. I've no idea what could be causing it to not work on your setup.

PepsRyuu commented 3 years ago

Oh wait, hang on, do you mean being able to set a breakpoint in the actual source code and have it bound there rather than in the loaded scripts section?

PepsRyuu commented 3 years ago

Can you try this?

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "pwa-chrome",
            "request": "launch",
            "name": "Launch Chrome against localhost",
            "url": "http://localhost:8080",
            "webRoot": "${workspaceFolder}",
            "sourceMapPathOverrides": {
                "nollup://*": "${workspaceFolder}/*"
            }
        }
    ]
}
zgoda commented 3 years ago

This is it, thank you very much!

A hole in memory, I once used that override with Snowpack or Vite.