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

custom plugin dependencies #11

Merged
merged 1 commit into from
May 19, 2011
Merged

custom plugin dependencies #11

merged 1 commit into from
May 19, 2011

Conversation

arlolra
Copy link
Contributor

@arlolra arlolra commented May 18, 2011

i'm writing some custom plugins but they have dependencies on packages i don't want to install globally ( i don't think they should be ). unfortunately, this means node can't find them ( them being the deps i'm requiring ). i'd like to just put a package.json inside the folder i installed haraka's configs / plugins to and npm install them to a node_modules beside plugins and config.

this seems to work and keeps things clean. it was the best i could come up with according to the way modules are resolved:
http://nodejs.org/docs/v0.3.1/api/modules.html#module_Resolving

of course, i could just add this line at the top of each of my plugins, but i thought it might become something canonical. other people will hopefully be writing custom plugins as well one day. what do you think?

@arlolra
Copy link
Contributor Author

arlolra commented May 18, 2011

along the same line ... if you accept this, should the install generate a package.json as well?

@arlolra
Copy link
Contributor Author

arlolra commented May 18, 2011

hmm, maybe this is the wrong thing to do:
http://nodejs.org/docs/v0.4.7/api/modules.html#loading_from_the_require.paths_Folders

@baudehlo
Copy link
Collaborator

Yeah then I guess you could even package up your custom mail server with a dependency on Haraka...

Didn't I read though on the node mailing list that require.paths is going away? If not, I'll just take the patch.

@arlolra
Copy link
Contributor Author

arlolra commented May 19, 2011

It says require.paths may disappear. A lot of libraries still rely on it though.

It might not be the best solution, but so far I haven't figured anything else out. Using vm.runInNewContext kind of complicates things ... do you have any ideas?

@baudehlo
Copy link
Collaborator

To be honest I think worst case scenario, if require.paths goes away then we could always hack plugin loading to provide a custom require() to work around it... I'll apply the patch.

baudehlo added a commit that referenced this pull request May 19, 2011
custom plugin dependencies
@baudehlo baudehlo merged commit 0fe1b6e into haraka:master May 19, 2011
@arlolra
Copy link
Contributor Author

arlolra commented Jul 15, 2011

as suspected nodejs/node-v0.x-archive@7f0047c

but seems like using NODE_PATH is an easy fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants