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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pack.require() and plugin.require() #1656

Closed
hueniverse opened this issue May 25, 2014 · 0 comments
Closed

Remove pack.require() and plugin.require() #1656

hueniverse opened this issue May 25, 2014 · 0 comments
Assignees
Labels
breaking changes Change that can breaking existing code
Milestone

Comments

@hueniverse
Copy link
Contributor

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.

Closes #1499
Closes #1471

@hueniverse hueniverse added this to the 6.0.0 milestone May 25, 2014
@hueniverse hueniverse self-assigned this May 25, 2014
hueniverse pushed a commit that referenced this issue May 25, 2014
@lock lock bot locked as resolved and limited conversation to collaborators Jan 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking changes Change that can breaking existing code
Projects
None yet
Development

No branches or pull requests

1 participant