Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

key merge strategy #145

Closed
pi0 opened this issue Mar 6, 2024 · 4 comments
Closed

key merge strategy #145

pi0 opened this issue Mar 6, 2024 · 4 comments
Assignees
Labels
discussion enhancement New feature or request

Comments

@pi0
Copy link
Member

pi0 commented Mar 6, 2024

(this is a primary draft to explain the idea)

Related: #138, #87

Sometime default defu merging strategy is not ideal. We could allow a custom defu merger but it is not initiative.

I was thinking to try with an object syntax like this:

{
  mergeStrategy: {
    modules: (a, b) => a.concat(b)
  }
}

(it could be backported to defu)

@cpreston321
Copy link
Member

cpreston321 commented Mar 6, 2024

So you are thinking if mergeStrategy is defined in the user config vs the c12 config? Then we could eventually put this back in defu to then use defuFn & defuArray to then automatically handle this.

@pi0
Copy link
Member Author

pi0 commented Mar 6, 2024

c12 config (controlled by nuxt for example). Yes we need a defuFn wrapper to use consistently every place in c12, that extends defuArray-like behavior and allows overriding behavior per-key with simple object. So for example nuxt can do reverse merge on modules array.

@cpreston321 cpreston321 self-assigned this Mar 6, 2024
@cpreston321
Copy link
Member

cpreston321 commented Mar 6, 2024

I'll try to implement this and give it a shot for a POC 💯 Thanks for the feedback

@pi0
Copy link
Member Author

pi0 commented Jun 11, 2024

Implemented as simpler merger function so that end-users have full control #160

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants