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

fix(nuxt): support deep assign on empty object for app config #10087

Merged
merged 1 commit into from
Jan 13, 2023

Conversation

atinux
Copy link
Member

@atinux atinux commented Jan 13, 2023

πŸ”— Linked issue

No linked issue, but a reproduction: https://stackblitz.com/edit/github-mgmeto?file=app.config.ts,app.vue

Tested locally in playground with my fix and works.

❓ 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)

@codesandbox
Copy link

codesandbox bot commented Jan 13, 2023

CodeSandbox logoCodeSandbox logoΒ  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@atinux atinux requested a review from pi0 January 13, 2023 16:28
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.

πŸ’―

@Tahul
Copy link
Contributor

Tahul commented Jan 13, 2023

I have a small suggestion about updateAppConfig and the current update strategy.

We currently use deepAssign and deepDelete in sequence so when calling updateAppConfig(content), the content becomes the new appConfig, without mutating the original object reference to preserve reactivity.

The issue with that is that deepDelete will inevitably delete all the missing keys from content, avoiding the possibility to make partial update of the app.config by sending only parts of it.

While this works very good, I think it would be amazing being able to send only partial updates to the app.config, without implying deepDelete.

Also, I don't think deleting keys from the app.config is safe or needed, as if the key is defined it's inevitable that features in the project somehow depend on these keys, and then removing them could lead to runtime throws.

@pi0
Copy link
Member

pi0 commented Jan 13, 2023

@Tahul Can you please open an issue with steps to reproduce? Indeed update shouldn't delete missing sub-keys too. BTW we initially did it because it was making strange behavior when a user removes an optional-option from main app.config and HMR was not reflecting that.

Copy link
Member Author

atinux commented Jan 13, 2023

The deepDelete is only used in development actually for HMR: https://github.com/nuxt/framework/blob/fix/update-app-config/packages/nuxt/src/app/config.ts#L61

What are the steps that brings a bad DX?

@Tahul
Copy link
Contributor

Tahul commented Jan 13, 2023

The deepDelete is only used in development actually for HMR: fix/update-app-config/packages/nuxt/src/app/config.ts#L61

What are the steps that brings a bad DX?

Wow, my bad, sorry for not double-checking that.

I thought the same sequence occurred in HMR and in runtime call.

I was mentioning this lately while working on studio because we allow partial updates for tokens.config and I thought that same partial updates would break with app.config. We are going to switch between holding the complete version of the app.config file in json files to holding only the keys that has been modified from studio for performances purpose.

You can consider this closed, sorry πŸ˜“

@danielroe danielroe merged commit 71a5727 into main Jan 13, 2023
@danielroe danielroe deleted the fix/update-app-config branch January 13, 2023 23:28
@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe mentioned this pull request Jan 20, 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.

4 participants