Open huang-julien opened 1 year ago
Have you tried importing from #app
or #imports
instead? I'm assuming you're talking about using these composables in runtime code (e.g. plugins) rather than directly in the module.
this is linked to https://github.com/huang-julien/nuxt-runtime-compiler/pull/37, https://github.com/nuxt/nuxt/issues/15553 and https://github.com/nuxt/nuxt/discussions/18413.
What i'm trying to do is to use app.config.ts
to define the compilerOptions
for vue in runtime through a plugin. However since this is only applied to vue in runtime, I would like to pass theses options, more specifically the isCustomElementTag
function from the app.config to the nuxt config at build time. this would avoid to define the compileroptions
twice.
Importing from #app
or #imports
within the module fails and I think most of the users won't import it since it is auto-imported.
This is tricky - app.config
is specifically meant to allow runtime code that relies on the entire Nuxt app context and importing or relying on it in the build-time part of modules is I think not something we can easily support.
This would be fine for anything that's serialisable - you could just set it in module options. But I recognise that (for example) functions are not so easy.
I think we would find it difficult to support this, but maybe we it would be worth gradually adopting a single location for shared config between build/runtime that module authors can use. e.g. module author can read in a ~/config/my-module.mjs
file which will be accessible at build time within module as well as imported by module in build.
A docs PR might be worth it to the module authors guide.
Describe the feature
Hi :wave: , It would be nice to be able to use
useAppConfig
within modules since this can be used by modules to get non-stringifyable data in plugins.Currently there's like a dependency loop when we import an
app.config.ts
(in a module file) withif we don't specify the import, the import will fail since
app.config.ts
has not been transformed.using
useAppConfig()
in modules triggers the same issue since it need to be imported fromnuxt/app
Additional information
Final checks