feat(nuxt): add hook debug mode
🔗 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

📝 Checklist
- [x] I have linked an issue or discussion.
- [ ] I have updated the documentation accordingly.
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...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site settings.
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.
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.
Makes sense to inspect only for browser. Moved to #https://github.com/unjs/hookable/issues/50.
Are we waiting for anything in https://github.com/unjs/hookable/pull/51?
[email protected] released
I had some other changes I was going to make when hookable was released. Will check later.
edit - all good