hapijs / good

hapi process monitoring
Other
525 stars 161 forks source link

exports pattern in v8.1.2 breaking downstream tests #608

Closed jeromecovington closed 5 years ago

jeromecovington commented 5 years ago

I was attempting to take the update from v8.1.1 to v.8.1.2 and found that the exports pattern in the new version was breaking the tests in my downstream wrapper around hapi.

The problem seems to be that register is no longer exported directly on the exports object but is now a property of exports.plugin.

I was surprised to see this change in a semver minor publish so wanted to check in on the reason for this before I refactor my code.

devinivy commented 5 years ago

Those are both valid formats for a hapi plugin ({ plugin: { pkg, register } } and { pkg, register }), and the fact that good is a hapi plugin is the extent of its public-facing API (aside from it's registration options, of course!). I'm curious in what way you're using good that would cause a breakage. If your hapi wrapper duplicates any of hapi's code for normalizing plugins, perhaps your code doesn't support hapi plugins in this format.

jeromecovington commented 5 years ago

Yep, that makes sense. It'd been a while since I read the details of the normalized plugin pattern in https://github.com/hapijs/hapi/issues/3658

Replace the exports.register() and the matching exports.register.attributes with exports.plugin = { register, name, version, multiple, dependencies, once, pkg }

So it looks like this is a previously anticipated spec that Good finally made "good" on. On my side I am requiring and then re-exporting Good along with some options as a custom or wrapped logging plugin. It should be a simple matter of just re-exporting (in my code) as exports.plugin = Good.plugin rather than exports.plugin = Good. Either way appreciate the quick response @devinivy.

devinivy commented 5 years ago

You got it! 👍

lock[bot] commented 4 years ago

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.