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

Prevent bundling of Node polyfills when importing TestUtils/TestRenderer #15305

Merged
merged 1 commit into from
Apr 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/shared/enqueueTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ import warningWithoutStack from './warningWithoutStack';
let didWarnAboutMessageChannel = false;
let enqueueTask;
try {
// read require off the module object to get around the bundlers.
// we don't want them to detect a require and bundle a Node polyfill.
let requireString = ('require' + Math.random()).slice(0, 7);
let nodeRequire = module && module[requireString];
// assuming we're in node, let's try to get node's
// version of setImmediate, bypassing fake timers if any
let r = require; // trick packagers not to bundle this stuff.
enqueueTask = r('timers').setImmediate;
// version of setImmediate, bypassing fake timers if any.
enqueueTask = nodeRequire('timers').setImmediate;
} catch (_err) {
// we're in a browser
// we can't use regular timers because they may still be faked
Expand Down