framework icon indicating copy to clipboard operation
framework copied to clipboard

feat(nuxt): add hook debug mode

Open danielroe opened this issue 3 years ago • 4 comments

🔗 Linked issue

resolves #3718

❓ Type of change

  • [ ] 📖 Documentation (updates to the documentation or readme)
  • [ ] 🐞 Bug fix (a non-breaking change that fixes an issue)
  • [ ] 👌 Enhancement (improving an existing functionality like performance)
  • [x] ✨ New feature (a non-breaking change that adds functionality)
  • [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

This PR adds support for debug: true in your nuxt config (disabled by default). At the moment, it prints out hook names and timings on the server, and logs hook arguments as well in the browser.

Example output

Server

[nuxt] app:created: 2.109ms
[nuxt] vue:setup: 0.035ms
[nuxt] app:rendered: 0.019ms
[nitro] render:html: 0.048ms
[nitro] render:response: 0.01ms

Client

CleanShot 2022-09-20 at 16 33 23

📝 Checklist

  • [x] I have linked an issue or discussion.
  • [ ] I have updated the documentation accordingly.

danielroe avatar Sep 20 '22 15:09 danielroe

Deploy Preview for nuxt3-docs ready!

Name Link
Latest commit 4a1759be24bde7288aea46008f292dd228899d45
Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/634a90a88c8f1d000850b038
Deploy Preview https://deploy-preview-7690--nuxt3-docs.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Sep 20 '22 15:09 netlify[bot]

This is a nice improvement but what do you think if we directly add hookable.setupDebugger(hooks, { tag })? We have at least 4 hookable namespace now (nuxt build, nuxt app, nitro build and nitro app). It can consistently add feature.

pi0 avatar Sep 20 '22 16:09 pi0

I like the idea. What do you think about enabling a custom handler as well (or 'presets')? I think it's nicer to have a browser API with collapsed/grouped logs and also allow logging all args, which would be unfeasibly verbose in the terminal.

danielroe avatar Sep 21 '22 08:09 danielroe

Makes sense to inspect only for browser. Moved to #https://github.com/unjs/hookable/issues/50.

pi0 avatar Sep 21 '22 10:09 pi0

Are we waiting for anything in https://github.com/unjs/hookable/pull/51?

danielroe avatar Sep 27 '22 15:09 danielroe

[email protected] released

pi0 avatar Oct 13 '22 17:10 pi0

I had some other changes I was going to make when hookable was released. Will check later.

edit - all good

danielroe avatar Oct 15 '22 11:10 danielroe