-
Notifications
You must be signed in to change notification settings - Fork 48.8k
The Great Web Worker Refactor of 2014 #1434
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
Conversation
globalObj = global; | ||
} | ||
|
||
invariant(globalObj, 'ExecutionEnvironment: could not find global object'); |
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.
globalObj = this; maybe?
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.
globalObj = this
would be wrong, that's the scope of this module. We used to have globalObj
= Function('return this;')() because that executes in a new global scope. But then we didn't need it and we removed it to be CSP safe. Not sure about self or global either... does one of those work in node?
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 use globalObj = (function () { return this })()
as cross-platform variant, returns global object in Node.js modules and window object in the browser.
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.
If I recall correctly, (function() { return this })()
won't return the global object in strict mode, which is part of the reason we were using Function("return this")()
before.
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.
You're right. In that case, since bundled file is usually already wrapped into kind of wrapper function (UMD or other; you're not setting strict mode globally anyway, right?), you can set this function to strict mode and pass global object from outside for any internal use:
(function (global) {
'use strict';
// ... all the real code goes here ...
})((function () { return this })());
or
(function (factory) {
// your UMD or other wrapper
factory(this);
}(function (global) {
'use strict';
// ... all the real code goes here ...
});
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
working make it more message passing-y make triggerEvent public fix reacttestutils Tests passing fix where files live, remove old toplevel callback fix cloneWithProps tst Use opaque DOM node handles move mountimage stuff to use handles fix almost all of the tests all tests fixed add the plan fix bad rebase mostly fix tests...mostly completly unfuck rebase make example look better okay, apparently the test app works fuck the tests add reactworkermount break events revert other changes revert reactjs changes maybe fix things fix server rendering okay now all tests pass begin cutting over to workermount combine resolveDOMNodeHandle() and ReactDOMNodeMapping move more stuff to dom node handles sample apps work whatttttt change container handles to use opaque ids rename markup to image fix todo add helpful comment update make tests run again Begin work on ReactRemote bridge worker to dom remove another reference to innerHTML Add bootstrapping abilitiy Rename ReactRemoteModule to RemoteModule Bring ReactWorkerMount into the React global reactworker is running start adding injections set up bidirectional comms ReactWorkerReconcileTransaction move some things around move back containersByReactRootID begin to break more dependencies It finally works serialize events over the bridge remove some references to window in the event system ok it works entirely now make a new example for web workers Clean up ReactWorker API ReactWithWorkers entrypoint reset React.js Kill ReactInjection Remove todo remove some more todos fix unmounting reset basic example @vjeux comments, fix typehints fix typehints in ReactEventListener
Going to close this out since it's being split up and applied more piecemeal. |
Using this branch to sync internally with FB, still needs polish and to be split up into multiple diffs.