You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The require() functions were an attempt to make life easier by being able to load plugins just like loading modules in node. This didn't work out so great. Instead, it was never clear how package paths were being resolved, lots of nasty magic used (including throwing an Error to get a call stack and figure out the file path of where require was called in user code).
Instead of trying to have hapi resolve paths through guesswork and the active registration of the local require() using plugin.loader(), this moves the require work out. The change mostly means instead of doing pack.require('some-package'), doing pack.register(require('some-package')).
Because now hapi cannot know the path of the plugin, other magic will no longer happen, like figuring out relative paths of static files and templates declared in the plugin. For that, plugin.path has been changed to plugin.path() which is used to set the base directory for any static resources, same way as files.relativeTo works in the server config.
The
require()
functions were an attempt to make life easier by being able to load plugins just like loading modules in node. This didn't work out so great. Instead, it was never clear how package paths were being resolved, lots of nasty magic used (including throwing an Error to get a call stack and figure out the file path of where require was called in user code).Instead of trying to have hapi resolve paths through guesswork and the active registration of the local
require()
usingplugin.loader()
, this moves the require work out. The change mostly means instead of doingpack.require('some-package')
, doingpack.register(require('some-package'))
.Because now hapi cannot know the path of the plugin, other magic will no longer happen, like figuring out relative paths of static files and templates declared in the plugin. For that,
plugin.path
has been changed toplugin.path()
which is used to set the base directory for any static resources, same way asfiles.relativeTo
works in the server config.Closes #1499
Closes #1471
The text was updated successfully, but these errors were encountered: