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

How to change default storage of multiCache.serverOptions.ts? #50

Closed
junkym0nk3y opened this issue May 2, 2024 · 1 comment
Closed
Labels
enhancement New feature or request

Comments

@junkym0nk3y
Copy link

It's a pretty strange decision to make 'app' folder and use it for module configuration storage.
I found that this path is hardcoded in
~/node_modules/nuxt-multi-cache/dist/module.mjs line:147

    const resolvedPath = "~/app/multiCache.serverOptions".replace(/^(~~|@@)/, nuxt.options.rootDir).replace(/^(~|@)/, nuxt.options.srcDir);

Can I ask for a new feature where I could set the path of multiCache.serverOptions storage?
Because I wish to move whole module, with config to npm local package and use it as nuxt layer in multiply projects

@dulnan
Copy link
Owner

dulnan commented Jun 16, 2024

The decision was made based on how other such things are implemented, for example the app/router.options.ts file from Nuxt itself. The problem is that it's not really module configuration, but module "behaviour". For module authors there is no easy way to allow module consumers to define non-stringable module configuration: Everything in nuxt.config.ts is only available at build time. The only way this can be done is using a separate file, which is then "magically" included/inlined at build time.

In your case, what you could do is define the runtime options as usual using defineMultiCacheOptions in your layer folder. Then in your project where you use said layer, you create a app/multiCache.serverOptions.ts where you import the config from your layer and export it again.

In Nuxt 4 the directory structure will change anyway (see nuxt/nuxt#26444) and the app folder will become the "main" folder. I suspect this will require adjustments to this module. I will keep your use case in mind and see if it's possible to provide a solution that would allow such a layer based "inheritance".

@dulnan dulnan added the enhancement New feature or request label Jun 16, 2024
@dulnan dulnan closed this as completed Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants