`addPlugin` from `@nuxt/kit` prepends plugins
See original GitHub issueEnvironment
- Operating System:
Linux
- Node Version:
v16.14.2
- Nuxt Version:
3.0.0-rc.4
- Package Manager:
npm@7.17.0
- Builder:
vite
- User Config:
modules
- Runtime Modules:
@/modules/pinia
,@/modules/my-module
- Build Modules:
-
Reproduction
https://stackblitz.com/edit/github-ba6rwp?file=nuxt.config.ts
Describe the bug
addPlugin
, by default, prepends to the list of plugins. This is great for the purpose described in code comment.
There are two problems though:
a) a module depends on other modules, the natural approach is to order them in a manner that dependencies are first
modules: [
'@pinia/nuxt',
'my-module-depends-on-pinia' // <-- uses pinia
]
b) a module can expose more than one plugin depending on each other
addPlugin(resolver.resolve('./plugins/api.js')
addPlugin(resolver.resolve('./plugins/auth.js') // <-- calls api
In both cases, the module / plugin registered later does not have access to the plugins added prior. Adding { append: true }
is not ideal, as it puts the module plugins after user plugins.
Additional context
No response
Logs
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top Results From Across the Web
r/Nuxt - Why does this.addPlugin prepend the plugin instead ...
Hey Nuxt addicts, I have a quick question regarding Nuxt plugins. I recently found out that Nuxt actually does not push a plugin...
Read more >The ModuleContainer class - Nuxt
Registers a plugin using addTemplate and prepends it it to plugins[] array. this.addPlugin({ src: path.resolve(__dirname, 'templates/foo.js'), ...
Read more >Add plugin's plugin dependency as plugin dependency of user
I am creating an SBT plugin to be used in all Scala projects in my company. It is a collection of commonly used...
Read more >using ___NODE is deprecated - Strapi/Gatsby-Source-Strapi
Issue Title Created Date Comment Count Updated D...
what would a unique component thingy look like 11 2022‑08‑01 2022‑08‑26
API not respond well with 404...
Read more >sbt Reference Manual — Using plugins
Enabling and disabling auto plugins. A plugin can declare that its settings be automatically added to the build definition, in which case you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @Aareksio These two are not related with the built-in
app:created
hook and plugin ordering.Closing this issue because default preprend behavior is intended explained in previous comment.
Linking here as discussions tend to be overlooked and it is heavily related: https://github.com/nuxt/framework/discussions/6436