-
Notifications
You must be signed in to change notification settings - Fork 924
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
feat: add support for clientData #1286
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
@meteorlxy This pr just include clientData api itself now, if you think that the api is ready, we can release this in next version so that I can start to use it and collect some feedbacks from my users. We can just leave it undocument, and if you want, I can add some docs and mark them as W.I.P. |
@Mister-Hope In fact, I don't see too many differences from provide/inject: export default defineClientConfig({
enhance({ app }) {
app.provide(foo, bar)
},
}) Any further ideas? |
This ensures that the clientData can be visited in any enhance function. There will be cases where a plugin is providing some exports which requires client data. I make a draft with the code you wrote in my theme, and I met similar problems. The theme clientConfig seems not be the first one, so I cannot access the data in enhance cycle in some cases. Moving it to core insure every data is injected before any client hook. |
Any update on this?
I think this reason is enough to add this feature in core. |
cc again @meteorlxy |
A |
I think a Let's focus on the problem of this pr:
Adding Adding it to client as a new concept seems more natural to me, as the client is handling the "client config" before any existing hooks to let it be accessable. Another improvement is that we now requires users to add a We could also allow the user client config to do not have any default export, i.e.: // .vuepress/client.ts
// imports
definePluginAConfig({ xxx }) |
I would like to open a pr for this, this is useful for users that only want to add this file for plugin customization purpose, it will be a bit strange for them to understand that without a default export we are throwing an error. Also, A lot of plugins are not expecting usage with the export object, maybe they just want to add some styles or library imports on the client side. |
No description provided.