-
Notifications
You must be signed in to change notification settings - Fork 59
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
fix: allow bundle to be used in web workers #408
Conversation
`globalObject` is `"window"` by default which is not available in web workers. Using `"self"` allows the bundle to work in both environments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alanshaw mind adding a test for this? I remember this problem existing in the past and there being a great endeavour to remove window
references from everywhere in the code
I don't have the bandwidth to add this test atm - @hugomrdias any chance you can pull this over the line? |
@alanshaw Can I work on the test for this pull request? |
@ay2306 🙏 yes please that would be amazing! |
@alanshaw To test this PR/commit, can I add a job in Travis to clone js-ipfs, build it using aegir and then run a headless browser to test if is there is no error in web worker? |
@@ -21,9 +21,6 @@ const env = { | |||
// Webpack overrides for karma | |||
const karmaWebpackConfig = merge.strategy({ plugins: 'replace' })(webpackConfig(), { | |||
entry: '', | |||
output: { | |||
libraryTarget: 'var' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why this is/was necessary, but the added test passes with globalObject
as 'self'
or 'window'
unless this is removed, in which case it passes with globalObject
as 'self'
and fails with it as 'window'
as reported in ipfs/js-ipfs#2349.
The js-IPFS tests pass without this block when run in the browser/webworkers so I'm not sure if it's necessary - ipfs/js-ipfs#3343
globalObject
is"window"
by default which is not available in web workers. Using"self"
allows the bundle to work in both environments.resolves ipfs/js-ipfs#2349
cc @Gozala