-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
6.x breaks plugin modules exporting functions #1728
Comments
As far as I can tell, it was never intended for a function with a register property to be supported. In fact it looks like the change in 6.x.x tightened up the expected behavior. I understand it is an inconvenience to have to change your modules, but this change was expected to cause breakages. You can do the same thing you do already with slight modifications by exporting the function as a property on the exports and use that for testing or registering routes/methods. With that said, I am unsure why you would need to use the exported function to do the above when you can do that from within the plugin itself, leaving it self contained. |
Exporting the function is extremely helpful for the tests, @chapel. I can test without Hapi involved, with just the server method involved, or also with the route involved. It might never have been intended for Hapi to support |
That's not how that works though. You were using an unintended bug as a I am not speaking for Hapi by the way, but as a user and fellow developer I
|
I don't think this is a big deal either way. I can relax the test since ultimately I don't care what type the module itself is as long as it has a register property. |
I wrote many Hapi plugin modules which export a function with a
register
function property. This lets me:The update broke this plugin structure with one assertion:
At this point, as invoked via
hapi -c
,plugin
is{ plugin: myModuleExport }
. The first clause fails, thentypeof plugin.plugin === 'object
fails.typeof plugin.plugin.register === 'function'
is true, but the expression never gets that far.The next line is:
If the assertion had not tripped,
register
would end up correct.Any chance you can alter your assertion so I don't have to make breaking API changes to a dozen or so modules?
The text was updated successfully, but these errors were encountered: