From 386c64e15b421fe05a0dd1e68b150a4bfe6fb344 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 25 Jun 2020 01:39:42 -0600 Subject: [PATCH 1/4] docs: add kamranayub as a contributor (#721) * docs: update README.md * docs: update .all-contributorsrc Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> --- .all-contributorsrc | 10 ++++++++++ README.md | 1 + 2 files changed, 11 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index cf2f3bdd..8c2cb0b5 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1121,6 +1121,16 @@ "contributions": [ "doc" ] + }, + { + "login": "kamranayub", + "name": "Kamran Ayub", + "avatar_url": "https://avatars1.githubusercontent.com/u/563819?v=4", + "profile": "http://kamranicus.com/", + "contributions": [ + "code", + "test" + ] } ], "contributorsPerLine": 7, diff --git a/README.md b/README.md index d42f9c6d..babd3f04 100644 --- a/README.md +++ b/README.md @@ -588,6 +588,7 @@ Thanks goes to these people ([emoji key][emojis]):
Artem Zakharchenko

📖
Michael

📖
Braden Lee

📖 +
Kamran Ayub

💻 ⚠️ From 3c9d7b4dc132d515ebbae1dd422c37b145bc2a3b Mon Sep 17 00:00:00 2001 From: Nick McCurdy Date: Thu, 2 Jul 2020 19:28:50 -0400 Subject: [PATCH 2/4] chore: create new jobs for React next (fixes #726) (#728) - Tests with both React stable and next for all builds (push and cron) - Allow next releases to fail the build so we can still release - Solves cron issues like #726 that are only caused by next releases --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ac04499f..c2f47b7a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,11 +8,14 @@ node_js: - 12 - 14 - node +env: + - REACT_NEXT=false + - REACT_NEXT=true install: - npm install # as requested by the React team :) # https://reactjs.org/blog/2019/10/22/react-release-channels.html#using-the-next-channel-for-integration-testing - - if [ "$TRAVIS_EVENT_TYPE" = "cron" ]; then npm install react@next + - if [ "$REACT_NEXT" = true ]; then npm install react@next react-dom@next; fi script: - npm run validate @@ -23,6 +26,8 @@ branches: - beta jobs: + allow_failures: + - env: REACT_NEXT=true include: - stage: release node_js: 14 From 604d3e96364175974fcb2d12fc7fa02b1c50d2e6 Mon Sep 17 00:00:00 2001 From: Matan Borenkraout Date: Sun, 5 Jul 2020 20:15:38 +0300 Subject: [PATCH 3/4] fix: React next fails on build (#726) (#732) * fix: Fix build on react@next * Working on ^16.9 and lower than 16.8 * Solution works in 16.8 also * Fixes from code review * Import only the function we need --- package.json | 3 ++- src/flush-microtasks.js | 32 +++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 802a2e34..ea03d463 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "license": "MIT", "dependencies": { "@babel/runtime": "^7.10.3", - "@testing-library/dom": "^7.17.1" + "@testing-library/dom": "^7.17.1", + "semver": "^7.3.2" }, "devDependencies": { "@reach/router": "^1.3.3", diff --git a/src/flush-microtasks.js b/src/flush-microtasks.js index 2638da04..99b56ea5 100644 --- a/src/flush-microtasks.js +++ b/src/flush-microtasks.js @@ -1,3 +1,6 @@ +import React from 'react' +import satisfies from 'semver/functions/satisfies' + /* istanbul ignore file */ // the part of this file that we need tested is definitely being run // and the part that is not cannot easily have useful tests written @@ -15,8 +18,15 @@ function getIsUsingFakeTimers() { ) } +const globalObj = typeof window === 'undefined' ? global : window +let Scheduler = globalObj.Scheduler +const isModernScheduleCallbackSupported = satisfies(React.version, '>16.8.6', { + includePrerelease: true, +}) + 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. @@ -25,6 +35,8 @@ try { // assuming we're in node, let's try to get node's // version of setImmediate, bypassing fake timers if any. enqueueTask = nodeRequire.call(module, 'timers').setImmediate + // import React's scheduler so we'll be able to schedule our tasks later on. + Scheduler = nodeRequire.call(module, 'scheduler') } catch (_err) { // we're in a browser // we can't use regular timers because they may still be faked @@ -49,6 +61,20 @@ try { } } +function scheduleCallback(cb) { + const NormalPriority = Scheduler + ? Scheduler.NormalPriority || Scheduler.unstable_NormalPriority + : null + + const scheduleFn = Scheduler + ? Scheduler.scheduleCallback || Scheduler.unstable_scheduleCallback + : callback => callback() + + return isModernScheduleCallbackSupported + ? scheduleFn(NormalPriority, cb) + : scheduleFn(cb) +} + export default function flushMicroTasks() { return { then(resolve) { @@ -59,7 +85,11 @@ export default function flushMicroTasks() { jest.advanceTimersByTime(0) resolve() } else { - enqueueTask(resolve) + scheduleCallback(() => { + enqueueTask(() => { + resolve() + }) + }) } }, } From 47e6da6e2f8c30dfded0a97100237118a185d80d Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sun, 5 Jul 2020 11:17:02 -0600 Subject: [PATCH 4/4] docs: add MatanBobi as a contributor (#733) * docs: update README.md * docs: update .all-contributorsrc Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> --- .all-contributorsrc | 9 +++++++++ README.md | 1 + 2 files changed, 10 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 8c2cb0b5..0a5aea46 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1131,6 +1131,15 @@ "code", "test" ] + }, + { + "login": "MatanBobi", + "name": "Matan Borenkraout", + "avatar_url": "https://avatars2.githubusercontent.com/u/12711091?v=4", + "profile": "https://twitter.com/matanbobi", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 7, diff --git a/README.md b/README.md index babd3f04..f33fde6c 100644 --- a/README.md +++ b/README.md @@ -589,6 +589,7 @@ Thanks goes to these people ([emoji key][emojis]):
Michael

📖
Braden Lee

📖
Kamran Ayub

💻 ⚠️ +
Matan Borenkraout

💻