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

feat(nuxt): app.config improvements #6905

Merged
merged 9 commits into from
Aug 24, 2022
Merged

feat(nuxt): app.config improvements #6905

merged 9 commits into from
Aug 24, 2022

Conversation

Tahul
Copy link
Contributor

@Tahul Tahul commented Aug 24, 2022

πŸ”— Linked issue

nuxt/nuxt#14670

❓ 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

Resolves:

  • Use defu.arrayFn to allow overrriding arrays in multi-layer format
    • In c54292b I implemented it how it was made in @nuxt-themes/kit
    • In 1b07424 I implemented it using arrayFn as suggested in app.config improvementsΒ nuxt#14670
      • Leads to strange behaviors with HMR (array keys going null when going from a play array to function format)
    • I would say that overwriting is expected behavior in this kind of config, and that function format seem to introduce a bit of overhead for the user to understand when reading config files.
  • Fixed an issue in which deep keys were not properly deleted on HMR, as seen here.
    • This portion of codes properly deepAssign on changes, but does not delete existing keys
    • Reproduction
  • Implement updateAppConfig composable

Few notes about this:

I've seen appConfig merging occurs in built template here, considering that, what is the proper way to implement features that needs to have access to the fully merged app config file inside Nuxt?

In nuxt/nuxt#14670, there is mentions to:

  • Use untyped to (auto)generate types from appConfig instead of defu
  • Support _schema (global config) [needs new issue to track]

I would love to help on these issues but need guidance on how to resolve the whole appConfig object from Nuxt side, in order to generate typings from it.

πŸ“ Checklist

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

@netlify
Copy link

netlify bot commented Aug 24, 2022

βœ… Deploy Preview for nuxt3-docs ready!

Name Link
πŸ”¨ Latest commit c2bf3a7
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/6306514ddc27470008c90bd4
😎 Deploy Preview https://deploy-preview-6905--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.

@pi0
Copy link
Member

pi0 commented Aug 24, 2022

Thanks for PR @Tahul! I think after resolving comments it is good to go πŸ‘πŸΌ

Please for next ones keep them small to one change.

@pi0
Copy link
Member

pi0 commented Aug 24, 2022

I've seen appConfig merging occurs in built template here, considering that, what is the proper way to implement features that needs to have access to the fully merged app config file inside Nuxt?

If by "inside Nuxt" you mean within modules, it is not possible. App config is a runtime template and merged and available only on runtime. Modules can access or extend it via a runtime plugin.

@pi0 pi0 changed the title feat(app.config): suggested improvements feat(nuxt): app.config improvements Aug 24, 2022
@Tahul
Copy link
Contributor Author

Tahul commented Aug 24, 2022

#6905 (comment)

I mean from inside Nuxt, this seem needed to generate typings and support _schema key as mentioned in the PR description.

@pi0
Copy link
Member

pi0 commented Aug 24, 2022

I mean from inside Nuxt, this seem needed to generate typings and support _schema key as mentioned in the PR description.

We have access to nuxt.options.appConfig... But more thinking, a generic schema support for Nuxt makes more sense (it is not limited to app config feature) but can type appConfig too.

@Tahul
Copy link
Contributor Author

Tahul commented Aug 24, 2022

I mean from inside Nuxt, this seem needed to generate typings and support _schema key as mentioned in the PR description.

We have access to nuxt.options.appConfig... But more thinking, a generic schema support for Nuxt makes more sense (it is not limited to app config feature) but can type appConfig too.

CleanShot 2022-08-24 at 18 20 12@2x

I understand we have access to nuxt.options.appConfig, but does that mean people can only write their schema from nuxt.config.ts file then?

@pi0
Copy link
Member

pi0 commented Aug 24, 2022

I understand we have access to nuxt.options.appConfig, but does that mean people can only write their schema from nuxt.config.ts file then?

I don't expect ordinary people to use (advanced) _schema feature we are planning to add. But yes it is a built-time thing for schema not runtime. Defined either using nuxt.config or hooks.

Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@pi0 pi0 merged commit 1700bf8 into nuxt:main Aug 24, 2022
This was referenced Aug 24, 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.

None yet

3 participants