felixge / node-sandboxed-module

A sandboxed node.js module loader that lets you inject dependencies into your modules.
MIT License
342 stars 42 forks source link

Allow injection of modules that do not have corresponding files #64

Open aetherwalker opened 6 years ago

aetherwalker commented 6 years ago

Hey,

In using this module was hoping to inject files that would be required dynamically, however I seem to be getting a file error when doing so.

I wrote an addition to add an option ignoreMissing to essentially allow the failing call to "require-like" to fail silently and fall back to the current key as the filename. Leaving the option with a default that preserves the current functionality.

I took a shot at adding a test for the option, adding "test-ignore-missing.js".

nomiddlename commented 6 years ago

I'm hitting this same problem as well (I load modules dynamically based on a user's config), would love to see a fix.