Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
/frameworkPublic archive

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

Merged
pi0 merged 38 commits into
mainfrom
feat/app-config
Aug 17, 2022
Merged

feat(nuxt): app.config with hmr and reactivity support#6333
pi0 merged 38 commits into
mainfrom
feat/app-config

Conversation

@pi0

@pi0pi0 commented Aug 3, 2022

Copy link
Copy Markdown
Member

🔗 Linked issue

Closesnuxt/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

netlifyBot commented Aug 3, 2022

Copy link
Copy Markdown

Deploy Preview for nuxt3-docs canceled.

NameLink
🔨 Latest commit15f5e3f
🔍 Latest deploy loghttps://app.netlify.com/sites/nuxt3-docs/deploys/62fd05d478de67000842429f

@pi0pi0 changed the title feat(nuxt): app.config with hmr supportfeat(nuxt): app.config with hmr and reactivity supportAug 3, 2022
@pi0
pi0 requested review from antfu, atinux and danielroeAugust 3, 2022 13:34
Comment threadpackages/nuxt/src/core/templates.ts Outdated
Comment threadpackages/nuxt/src/app/config.ts Outdated
Comment threadpackages/schema/src/types/config.ts Outdated
Comment threadplayground/app.config.ts Outdated
@pi0
pi0 marked this pull request as ready for review August 4, 2022 15:31
Comment threadtest/fixtures/basic/app.config.ts Outdated
@atinux

Copy link
Copy Markdown
Member

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

pi0 commented Aug 17, 2022

Copy link
Copy Markdown
MemberAuthor

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

Comment threadpackages/nuxt/src/app/config.ts Outdated
@pi0

pi0 commented Aug 17, 2022

Copy link
Copy Markdown
MemberAuthor

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 mainAug 17, 2022
@pi0
pi0 deleted the feat/app-config branch August 17, 2022 15:23
@TahulTahul mentioned this pull request Aug 19, 2022
@pi0pi0 mentioned this pull request Aug 26, 2022
Sign up for freeto 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

@pi0@atinux@danielroe