Skip to content

Instantly share code, notes, and snippets.

@myndzi
Created April 29, 2016 17:36
Show Gist options
  • Save myndzi/b556a5dacee2514f11e2c43b3fb9adfe to your computer and use it in GitHub Desktop.
Save myndzi/b556a5dacee2514f11e2c43b3fb9adfe to your computer and use it in GitHub Desktop.
project/node_modules/loader - can require('foo') but not require('bar')
project/node_modules/foo
project/node_modules/foo/node_modules/bar
@myndzi
Copy link
Author

myndzi commented Apr 29, 2016

If you for some reason needed to load 'bar' from 'loader', you could potentially do it like this:

foo.js:
module.exports.loadChild = function (str) { return require('str'); }

loader.js:
require('foo').loadChild('bar');

...but the better solution is to make 'bar' a direct dependent of 'project'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment