javascript - How can I dynamically require an npm dependency file loaded with webpack? -


i want like:

var dynamicrequire = require.context('./', true); console.log(dynamicrequire.keys()); dynamicrequire('react/foo/bar'); 

but console.log shows files local directory, not npm packages. when webpack builds can see included number 234 mapping path number lost. how can accomplish this? thanks!

i'm not sure, problem here, suspect, purpose have forgotten provide require.context second argument, flag, decides, whether webpack should subfolders , pick files there also. use require.context('./', true, [some regexp maybe ?]).

let me know if that's not addressing problem.


Comments