-
Notifications
You must be signed in to change notification settings - Fork 42
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
Globals don't propagate to required modules #11
Comments
I gave it a shot, but it's pretty tricky. You basically need to inject some kind of sandboxed module You can work around it like so: var domify = sandboxedModule.require("domify", {
globals: { document: myFakeDocument }
requires: {
"./lib/domify": sandboxedModule.require("domify/lib/domify", {
globals: { document: myFakeDocument }
})
}
}); (it might be |
Ah, the exact same workaround I'm currently hacking on. It'll do for now. Thanks mate |
We recently added this feature to proxyquire. I'm not sure if that helps you at all since it works with require extensions (so may not apply here), but I thought it might help you to have a look. If you prefer to not read diffs, it all happens in here. |
Add failing test for felixge#11
I was trying very hard to do
But
domify
resolves to/node_modules/domify/index.js
, which is justBut if I insert a
console.log(document)
at the top of/node_modules/domify/lib/domify.js
, it fails, indicating thedocument
global didn't make it through the dependency chain.The text was updated successfully, but these errors were encountered: