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

Handle node.js module scope #2

Open
msridhar opened this issue Jan 15, 2014 · 3 comments
Open

Handle node.js module scope #2

msridhar opened this issue Jan 15, 2014 · 3 comments

Comments

@msridhar
Copy link
Member

Consider normalizing the following node.js code:

var fs = require("fs");

The normalized code tries to read require from the global object, but in node, require is declared in the so-called "module" scope. Hence, the normalized code fails with a ReferenceError. I wonder if we can handle this?

@msridhar
Copy link
Member Author

@xiemaisi any thoughts?

@msridhar
Copy link
Member Author

One thought: it looks like module, which refers to the current module object, is a property of the global object in node. So maybe we could special-case accesses to certain "global" variables known to be properties of module, like require, and rewrite those as accessing properties of __global['module']?

@xiemaisi
Copy link

I haven't looked into normalising node.js code yet. As you suggest, the rewriting of global variable references would have to be changed to take module into account, but I'm unclear about the details.

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

No branches or pull requests

2 participants