Skip to content

Make it possible to run jsdom in a worker #711

Closed
@lawnsea

Description

@lawnsea

For my research project Treehouse, I forked jsdom and got it to run in a web worker. This was two years ago. I'm interested in doing this again, but in a way that is maintainable, rather than just a proof-of-concept.

At a high level, this is what was necessary to get jsdom 0.2.4 running in a worker:

  • remove node dependencies that cannot be met in the browser (fs, e.g.)*
  • provide pure-JS implementations of node dependencies where possible (url, e.g.)*
  • use util.inherits instead of assigning to __proto__
  • use Object.defineProperty instead of __defineSetter__/Getter__
  • replace uses of variables named window and document with win and doc**

I also refactored the code to use AMD and build with RequireJS. I don't think this is necessary now (and may not have been necessary then): it should be possible to use the cjsTranslate method to build for the browser.

I would like to keep the diff from my fork to the original as minimal as possible. So, I'd like to upstream those changes that support browser compatibility in a non-breaking way. Would y'all be open to that?

* browserify may help with these
** I'm embarrassed to admit I don't remember why this was necessary

EDIT: I'm aware of this thread and #245

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions