sveltejs / sapper-legacy.svelte.dev

Old docs site for Sapper
https://sapper-legacy.svelte.dev/
Other
13 stars 22 forks source link

Add section on debugging to docs. #32

Closed nsivertsen closed 6 years ago

nsivertsen commented 6 years ago

I'm not sure whether this really belongs here, but debugging has come up a few times in chat and I've found it quite valuable.

I'm not sure whether this works with Webpack. I'm guessing sourcemaps for Webpack need to be enabled in sapper-template rather than directly in Sapper as is the case for Rollup?

Rich-Harris commented 6 years ago

I'm afraid I can't get this to work at all :( ndb npm run dev opens ndb, but doesn't start Sapper. I'm on the latest version of ndb. Is there a step that I'm missing?

nsivertsen commented 6 years ago

That's strange, the only steps I've taken are npm install -g ndb and ndb npm run dev. I must say though that ndb occasionally shows aberrant behaviour. The first few days of use it had a dark theme, now it has a light theme, without me changing any settings or doing an update. And sometimes it takes a few starts to get it to work.

When you go to http://localhost:3000, does the tab hang or do you get an ERR_CONNECTION_REFUSED error? Did you insert any debugger statements anywhere in your code?

What happens if, after opening ndb, you click npm run dev in the list of npm scripts in the bottom left panel?

Rich-Harris commented 6 years ago

A-ha! I think it's just a lot slower to start up sometimes, which made me think it wasn't working at all. The answer was to just have a bit more patience. It works — sourcemaps and everything. I added a console.log('here') inside a template, and it showed up...

screen shot 2018-09-08 at 1 13 41 pm

...and clicking index.html:7 took me right to the correct place in the template:

screen shot 2018-09-08 at 1 11 50 pm

This is pretty damn cool!

Rich-Harris commented 6 years ago

I added a note about the slow startup time, in case other people are as impatient as me and also assume it's broken. Thank you!

nsivertsen commented 6 years ago

Glad to hear you got it working! And my pleasure!