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

Config inheritance seems to be in reverse order from docs #1458

Closed
tlancina opened this issue Jan 25, 2024 · 4 comments
Closed

Config inheritance seems to be in reverse order from docs #1458

tlancina opened this issue Jan 25, 2024 · 4 comments
Labels

Comments

@tlancina
Copy link

Description

Hello! https://vike.dev/config#overridable-defaults says "The +config.h.js file of pages (/pages/some-page/+config.h.js) can override default values defined by /pages/+config.h.js.", but it didn't seem to be working that way (playing around with defining Page meta to manually control render modes). Debugging the issue it seems like the sort order in the implementation is to have longer path lengths first, so when they are iterated over, shorter paths clobber config set by more specific ones.

Object.entries(interfaceFilesRelevant).forEach(([_locationId, interfaceFiles]) => {

image

I'm on version 0.4.156. Can you confirm you are seeing this as well? A simple repro is to define meta: { Page: { env: { server: true, client: false } } in pages/ or render/ config and then override with meta: { Page: { env: { server: true, client: true } } in a specific path and check for the client side bundle on load.

If I change the above line to the following then it works as expected:

Object.entries(interfaceFilesRelevant).reverse().forEach(([_locationId, interfaceFiles]) => {

Happy to PR this as well 😄

@brillout
Copy link
Member

Let me try to reproduce.

Happy to PR this as well 😄

Sure, we can always close it anyways if there is a better solution :)

brillout added a commit that referenced this issue Jan 25, 2024
@brillout
Copy link
Member

Indeed, I could reproduce and your fix was correct.

Fix pre-released as 0.4.160-commit-a1101c1.

Also, in case your company is up for it: Support Vike #1350.

@tlancina
Copy link
Author

Hey thanks for the quick response. I wasn't sure what sort of sort guarantees interfaceFilesRelevant had potentially from other places so was hesitant to suggest it as a permanent fix.

I don't have an employer at the moment, but I respect the hustle! Just sent you some beer money. Thanks for Vike!

@brillout
Copy link
Member

Thank you 🍻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants