Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

feat(nuxt): app.config with hmr and reactivity support #6333

Merged
merged 38 commits into from
Aug 17, 2022
Merged

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Aug 3, 2022

πŸ”— Linked issue

Closes nuxt/nuxt#14330

❓ 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)
  • ✨ 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:

  • Working Vite HMR (*)
  • Test Webpack HMR
  • Test deep assign (seems not required)
  • appConfig in nuxt.config for type support and easy module integration
  • Programmatic way to add additional app.config files (possible by modifying appConfig or app:resolve hook)
  • Add tests
  • Inject $appConfig (A plugin can easily inject reactive shortcut. Delegating addition to next steps)
  • Infer types from app.config for useAppConfig()
  • Add docs (API, Guide and File)
  • Add module author guide (adding after trying on edge

(*) 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.

@netlify
Copy link

netlify bot commented Aug 3, 2022

βœ… Deploy Preview for nuxt3-docs canceled.

Name Link
πŸ”¨ Latest commit 15f5e3f
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/62fd05d478de67000842429f

@pi0 pi0 changed the title feat(nuxt): app.config with hmr support feat(nuxt): app.config with hmr and reactivity support Aug 3, 2022
@pi0 pi0 requested review from danielroe, atinux and antfu August 3, 2022 13:34
playground/app.config.ts Outdated Show resolved Hide resolved
@pi0 pi0 marked this pull request as ready for review August 4, 2022 15:31
@atinux
Copy link
Member

atinux commented Aug 17, 2022

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.

@pi0
Copy link
Member Author

pi0 commented Aug 17, 2022

@atinux It is supported by default (main layer is part of other layers :))

@pi0
Copy link
Member Author

pi0 commented Aug 17, 2022

HMR seems unstable with vite-node but is probably not directly related to this PR. We can test better on edge.

@pi0 pi0 merged commit 94f76ea into main Aug 17, 2022
@pi0 pi0 deleted the feat/app-config branch August 17, 2022 15:23
@Tahul Tahul mentioned this pull request Aug 19, 2022
@pi0 pi0 mentioned this pull request Aug 26, 2022
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Editable runtime config with HMR
3 participants