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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce an option to encapsulate the plugin #197

Closed
2 tasks done
dwickern opened this issue Sep 20, 2022 · 2 comments 路 Fixed by #199
Closed
2 tasks done

Introduce an option to encapsulate the plugin #197

dwickern opened this issue Sep 20, 2022 · 2 comments 路 Fixed by #199
Labels
good first issue Good for newcomers semver-minor Issue or PR that should land as semver minor

Comments

@dwickern
Copy link
Contributor

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

馃殌 Feature Proposal

Introduce an option encapsulate?: boolean. Defaults to false. When set to true, keep the plugin encapsulated.

Motivation

fastify-plugin currently makes all plugins accessible by setting skip-override. It would be nice to have an option to keep it encapsulated, so you can set a plugin's name, metadata, etc without affecting the plugin's scope.

Would you consider a PR for this?

Example

module.exports = fp(plugin, {
  fastify: '4.x',
  decorators: {
    fastify: ['plugin1', 'plugin2'],
    reply: ['compress']
  },
  dependencies: ['plugin1-name', 'plugin2-name'],
  encapsulate: true,
})
@Eomm
Copy link
Member

Eomm commented Sep 21, 2022

I think it is a good suggestion, but I suspect that something will not work (such as the name option) - so we will need a good test suite to cover the use cases

@climba03003 climba03003 added semver-minor Issue or PR that should land as semver minor good first issue Good for newcomers labels Sep 21, 2022
@climba03003
Copy link
Member

climba03003 commented Sep 21, 2022

I suspect that something will not work

I do not get what's you mean by name option would not works?
The name doesn't matter if it is encapsulated or not. It will be pushed to the registered list and plugin chain in any case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers semver-minor Issue or PR that should land as semver minor
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants