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

Problems using core-js inside Devtool #230

Closed
galadriel2143 opened this issue Aug 22, 2016 · 6 comments
Closed

Problems using core-js inside Devtool #230

galadriel2143 opened this issue Aug 22, 2016 · 6 comments

Comments

@galadriel2143
Copy link

I'm trying to use a node.js app inside an Electron-based debugger, devtool. Devtool has a command line switch, --no-browser-globals, which hides the window, document, and navigator variables from running scripts. The issue I'm running into is that the modules/_html script does this:

module.exports = require('./_global').document && document.documentElement;

The left hand side of the script succeeds, because core-js uses this black magic to grab the window object:

Function('return this')();

But the right hand side fails because it references the document variable. If I change the code to:

module.exports = require('./_global').document && require('./_global').document.documentElement;

It works properly.

@Jessidhia
Copy link

w.r.t. that black magic: it's actually the only reliable way of getting access to the global object, unless you forbid eval. As was demonstrated by this example 😆

But yes, it would probably be better if no globals are ever assumed to be available outside of require('./_global').

@galadriel2143
Copy link
Author

Is there any way to expedite this getting fixed? I've already tracked down the issue and have a solution, it just needs to be implemented. Should I create a PR?

@zloirock
Copy link
Owner

zloirock commented Sep 1, 2016

If

var global = require('./_global').document;
module.exports = document && document.documentElement;

will fix this issue completely - feel free add a PR.

@Jessidhia
Copy link

It will fix it so the document is found in the "real" global environment, but it still defeats the point of --no-browser-globals. I guess it's good enough to at least prevent a crash...

@galadriel2143
Copy link
Author

galadriel2143 commented Sep 2, 2016

Yeah. It probably would be better if Devtool would correctly hide the browser globals, so that even the weird eval trick that core-js uses would return undefined, but fixing that sounds more complicated... maybe I should post a bug there...

@zloirock
Copy link
Owner

zloirock commented Aug 6, 2017

Should be fixed in 2.5.0.

@zloirock zloirock closed this as completed Aug 6, 2017
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

3 participants