Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

feat(app): pass inject/provide helpers as second argument to plugins #226

Merged
merged 1 commit into from
Jun 17, 2021

Conversation

danielroe
Copy link
Member

this may be a deliberate choice but if so, it will make it harder for module authors to create plugins for both 2/3

@atinux
Copy link
Member

atinux commented Jun 15, 2021

Well the context is also different (nuxt vs ctx). I agree we need to find an easy way to make a plugin for both N2 and N3 compatible.

@danielroe danielroe self-assigned this Jun 16, 2021
@atinux
Copy link
Member

atinux commented Jun 16, 2021

Let's discuss in nuxt/bridge#119 :)

@pi0
Copy link
Member

pi0 commented Jun 16, 2021

We can take the same approach of module compatibility to by default provide a semi-compatible interface (reducing breaking change surface) and defineNuxtPlugin (from @nuxt/app) for typing and better control (plugins using define, probably don't need a compat proxy)

@danielroe danielroe closed this Jun 16, 2021
@danielroe danielroe deleted the fix/nuxt3-plugin-signature branch June 16, 2021 12:13
@pi0 pi0 mentioned this pull request Jun 16, 2021
2 tasks
@pi0
Copy link
Member

pi0 commented Jun 16, 2021

~> nuxt/bridge#118

@danielroe danielroe restored the fix/nuxt3-plugin-signature branch June 16, 2021 15:41
@danielroe danielroe reopened this Jun 16, 2021
@danielroe
Copy link
Member Author

danielroe commented Jun 16, 2021

Just (re)rediscovered this, which makes me think that we should go ahead with this PR (or update the signature):

export interface Plugin {
(nuxt: Nuxt, provide?: Nuxt['provide']): Promise<void> | void
}

@danielroe danielroe changed the title fix(app): add 'inject' param for nuxt3 plugins fix(app): add 'provide' param for nuxt3 plugins Jun 16, 2021
@pi0 pi0 changed the title fix(app): add 'provide' param for nuxt3 plugins feat(app): pass inject/provide helpers as second argument to plugins Jun 16, 2021
@pi0
Copy link
Member

pi0 commented Jun 16, 2021

We can probably start showing a deprecated message on inject usage to use nuxt.provide when had defineNuxtPlugin (#230)

@pi0 pi0 merged commit 62b19c6 into main Jun 17, 2021
@pi0 pi0 deleted the fix/nuxt3-plugin-signature branch June 17, 2021 10:02
pi0 added a commit to nitrojs/nitro that referenced this pull request Apr 11, 2022
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants