Giter Club home page Giter Club logo

Comments (7)

mattdesl avatar mattdesl commented on July 21, 2024

Yeah, it's a bit tricky. That sort of existence check is very fragile, as there are lots of solutions nowadays that blend browser/Node features like process and require.

Do you have any modules in particular that are breaking or acting strangely? It would be good to test against real-world use cases rather than hypotheticals.

from devtool.

cannoneyed avatar cannoneyed commented on July 21, 2024

The module that borked things up for me was https://github.com/mio/mio.

Perhaps https://github.com/facebook/react might be useful to check out?

from devtool.

cannoneyed avatar cannoneyed commented on July 21, 2024

Here's a bit of a wacky idea... could you wrap all of the app's code in an IIFE to override the window variable like so?

(function (window) {
  // app code goes here...
  console.log(window) // undefined!
})()

from devtool.

mattdesl avatar mattdesl commented on July 21, 2024

Yes I was thinking the same. We are already wrapping the code in closures anyways for Node requires. It will break the odd app that does something like this, but it's fairly non standard:

// module A
global.window = 'foo';

// module B
console.log(window);

It would probably come in through a flag like --no-browser-globals (or maybe something more concise than that!) which also removes document and other things.

from devtool.

mattdesl avatar mattdesl commented on July 21, 2024

Also it will mean window.close() is not possible.

from devtool.

mattdesl avatar mattdesl commented on July 21, 2024

Pushed no-browser-globals branch.

You can try it like so:

npm i Jam3/devtool#no-browser-globals -g
devtool my-file.js --no-bg

This doesn't work in the REPL/Console, though. Going to sit on it for a while and think if there is any other way to fix this.

from devtool.

mattdesl avatar mattdesl commented on July 21, 2024

Pushed to 1.6.0

from devtool.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.