framework
framework copied to clipboard
feat(nuxt): `app.config` with hmr and reactivity support
🔗 Linked issue
Closes #5918
❓ Type of change
- [ ] 📖 Documentation (updates to the documentation or readme)
- [ ] 🐞 Bug fix (a non-breaking change that fixes an issue)
- [x] 👌 Enhancement (improving an existing functionality like performance)
- [ ] ✨ 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 (multi layer) app.config file with true HMR support and reactivity/editable on both client and server side.
A diversion from the original proposal is that I've decided to keep it separated from runtimeConfig at least for now since runtime config is globally frozen on server side and injection method of appConfig is foundomantelay different (bundler vs nitro-provided). This means appConfig and runtimeConfig.app are not the same.
Playground is edited to try new feature.
TODO:
- [x] Working Vite HMR (*)
- [x] Test Webpack HMR
- [x] ~~Test deep assign~~ (seems not required)
- [x]
appConfiginnuxt.configfor type support and easy module integration - [x] Programmatic way to add additional
app.configfiles (possible by modifyingappConfigorapp:resolvehook) - [x] Add tests
- [ ] ~~Inject
$appConfig~~ (A plugin can easily inject reactive shortcut. Delagating addition to next steps) - [ ] Infer types from
app.configforuseAppConfig()
(*) When testing, I've found that virtual files do not support HMR
📝 Checklist
- [ ] I have linked an issue or discussion.
- [ ] I have updated the documentation accordingly.
Deploy Preview for nuxt3-docs canceled.
| Name | Link |
|---|---|
| Latest commit | 15f5e3f4d7ce8ac362639296ccee31bc1ed91db7 |
| Latest deploy log | https://app.netlify.com/sites/nuxt3-docs/deploys/62fd05d478de67000842429f |
It would be nice to also test it in https://github.com/nuxt/framework/tree/main/examples/advanced/config-extends to check the multi layer support.
@Atinux It is supported by default (main layer is part of other layers :))
HMR seems unstable with vite-node but is probably not directly related to this PR. We can test better on edge.