-
-
Notifications
You must be signed in to change notification settings - Fork 67
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
[q]Autoload with dependencies #31
Comments
Can you make an example where this behavior is failing you? How would you change this? |
@mcollina const fastify = require('fastify')();
const externalPlugin = require('fastify-external-plugin');
const autoloadPlugin = require('fastify-autoload');
fastify.register(externalPlugin);
fastify.register(autoloadPlugin, {dir: './plugins'});
... // await for fastify.ready and listen As an fastify-external-plugin we could have Obviously we can set dependency to decorators and wait until |
Fastify does not resolve the dependency graph, because plugins are loaded in-order by fastify. This plugin needs that, because it would load them from the order that they are being returned from the file system. Essentially, the dependency order thing is needed to solve a problem added by autoload, and only on plugins registered by autoload. If you need |
I realise what @SkeLLLa means is if we have a plugin as const fp = require('fastify-plugin')
function plugin (f, opts, next) {
// plugin body
next()
}
module.exports = fp(plugin, {
name: 'plugin-g',
dependencies: ['fastify-sensible']
}) The new feature of automatically resolving dependencies won't find The problem sounds legit. Do you have any suggestion on how to tackle this? @mcollina |
I think the best suggestion if a plugin is missing is to assume that is loaded by fastify and rely on https://github.com/fastify/fastify/blob/e2062efcc7adbb82101e3afd7734835f81d71bbe/lib/pluginUtils.js#L29 this check. It will throw if it's missing, and that's ok. |
Yea that sounds good. Something like this? #32.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Fastify plugin module support dependencies section. If some plugins wrapped with fastify-plugin registered through autoload, then it checks only plugins, that are loaded through autoload. However it ignores plugins that are previously loaded with fastify.register.
Is that correct behaviour? Or it should check
Symbol(registered-plugin)
in fastify instance as well?The text was updated successfully, but these errors were encountered: