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

Use "self" instead of "window" #5

Open
jorrete opened this issue Feb 20, 2021 · 7 comments
Open

Use "self" instead of "window" #5

jorrete opened this issue Feb 20, 2021 · 7 comments

Comments

@jorrete
Copy link

jorrete commented Feb 20, 2021

Could be possible to use self instead of window?

module.exports = self.FormData

I'm trying to instantiate Swagger in a webworker, and it is complaining because window doesn't exist.

@alexindigo
Copy link
Member

There is been quite a motion around it, please check commit history :)

Maybe it’s time to create number of wrappers for different use cases. 🤔

cc @DylanPiercey

@alexindigo
Copy link
Member

Sorry, I had in mind different file – https://github.com/form-data/form-data/commits/master/lib/browser.js

@DylanPiercey I think we can copy what we have there.

@DylanPiercey
Copy link
Member

@alexindigo yeah that should work

@DylanPiercey
Copy link
Member

@alexindigo given the goal of this module is to expose FormData globally, should we make a breaking change / major release and no longer export FormData? It seems like really the browser file for this module should just be empty, since presumably FormData is already global in the browser, even in a worker.

Alternatively, again since we are assuming there is already the global, could we not just change this to module.exports = FormData?

@tmkasun
Copy link

tmkasun commented Apr 1, 2021

I'm also having the exact same issue, Can't use swagger-js in web worker because of this.

image

I'm also +1 to @DylanPiercey idea exporting directly module.exports = FormData rather than adding to the global window object.

@char0n
Copy link

char0n commented Apr 1, 2021

What about using already standardized globalThis? I'll issue a PR if agreed that this is path forward.

@char0n
Copy link

char0n commented Jul 7, 2021

I've issued a PR: #6 for using globalThis object. It's a breaking change but will work in all major browsers and latest node.js versions (and that's what we currently need).

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

5 participants