Open pi0 opened 3 years ago
Then it would be also safe to mention using
buildModules
anddevDependency
since rest of logic is bundled with plugin file :)
Yeah at the moment, this information is really missing into each modules. It could be really cool to get it for improve generation of nuxt config file for instance <3
Thanks for the feedback! I'll take a look at these suggestions and make some updates.
@Geminii It is next step indeed for nuxt/config+nuxt/kit making us able to automate docs (and initial config) generation. Stay tuned π
@lindsaykwardell No problems. Feel free pinging for any help βΊοΈ
@pi0 if i can help you on this way don't hesitate π I think it will permit to do much things in background ππ
@pi0 on the note of Nuxt 3, are there any other changes I should watch out for from a module perspective? Might as well be as prepared as I can :)
Actually doing above advices it would be pretty near for nuxt3 compatibility. (except you might also want to expose composition API hooks)
There are two projects planned specially for cross compatibility of modules:
this.
(like this.addPlugin
) with higher portabilityAnyway keep all of info above as future plans. We have few months to even start advice these.
@pi0, is this what you had in mind as far as switching to buildModule and privateRuntimeConfig?
https://github.com/lindsaykwardell/nuxt-github-api/tree/development
I saw you suggested using publicRuntimeConfig, but I think if it's a build module it doesn't need to be public, correct?
Hi @lindsaykwardell β
Actually you have to use $config
inside plugin (it doesn't involves module anymore after build). See this example
I saw you suggested using publicRuntimeConfig, but I think if it's a build module it doesn't need to be public, correct?
It is better to be privateRuntimeConfig
but since this plugin should be also able working in client-side, we have to use publicRuntimeConfig
which is same as current version which token is exposed to all clients. A more secure approach would be registering an http proxy to add tokens in client-side.
Ah, okay. I'll move the $config
logic to the plugin then, that makes sense.
I think I may be missing something on buildModules
, though. I was under the impression that since it's now a buildModule, the plugin can only be triggered during the build, and its data is then injected into the Nuxt instance. Or was this comment just a suggestion that it could be used as both a buildModule
and a regular module
? And if so, should the docs reflect that either the privateRuntimeConfig
or the publicRuntimeConfig
is acceptable depending on use case, since they both compile into the $config
object?
Thank you so much for your input, I really appreciate it! :)
First of all nice module π―
It would be better to use nuxt
runtimeConfig
in configuration so it is also visible to users that when usingpublicRuntimeConfig
it is actually exposed to client (currently we actually add token to client bundle) Also this adds ability to use a new token afternuxt build
using environment variables and.env
file. read more - exampleThen it would be also safe to mention using
buildModules
anddevDependency
since rest of logic is bundled with plugin file :)Also as a side-note, inline config syntax
[module, { /* config * }]
may be deprecated with nuxt3 because of harder typing. So i would suggest recommending top-level. (a types field would be also nice example)