From 1acea67d00c160832c9dffc5845438aa28c7a6cd Mon Sep 17 00:00:00 2001 From: Brandon Dail Date: Mon, 12 Feb 2018 14:17:14 -0800 Subject: [PATCH] Fix react-scripts to work with alphas after 16.0.0 The current logic just checks if the version is an alpha with a major version of 16 to account for weirdness with the 16 RC releases, but now we have alphas for newer minor releases that don't have weirdness --- fixtures/dom/package.json | 2 +- fixtures/dom/src/react-loader.js | 7 ++++++- fixtures/dom/yarn.lock | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/fixtures/dom/package.json b/fixtures/dom/package.json index b8de05fc70fbd..87b765f42610a 100644 --- a/fixtures/dom/package.json +++ b/fixtures/dom/package.json @@ -13,7 +13,7 @@ "query-string": "^4.2.3", "react": "^15.4.1", "react-dom": "^15.4.1", - "semver": "^5.3.0" + "semver": "^5.5.0" }, "scripts": { "start": "react-scripts start", diff --git a/fixtures/dom/src/react-loader.js b/fixtures/dom/src/react-loader.js index 1c496c78f1b47..baa9ed6e13dd3 100644 --- a/fixtures/dom/src/react-loader.js +++ b/fixtures/dom/src/react-loader.js @@ -1,3 +1,5 @@ +import semver from 'semver' + /** * Take a version from the window query string and load a specific * version of React. @@ -46,10 +48,13 @@ export default function loadReact() { let query = parseQuery(window.location.search); let version = query.version || 'local'; + if (version !== 'local') { + const {major, minor, prerelease} = semver(version); + const [preReleaseStage, preReleaseVersion] = prerelease; // The file structure was updated in 16. This wasn't the case for alphas. // Load the old module location for anything less than 16 RC - if (parseInt(version, 10) >= 16 && version.indexOf('alpha') < 0) { + if (major >= 16 && !(minor === 0 && preReleaseStage === 'alpha')) { REACT_PATH = 'https://unpkg.com/react@' + version + '/umd/react.development.js'; DOM_PATH = diff --git a/fixtures/dom/yarn.lock b/fixtures/dom/yarn.lock index 95d57f059be76..188f76fb40214 100644 --- a/fixtures/dom/yarn.lock +++ b/fixtures/dom/yarn.lock @@ -5890,6 +5890,10 @@ semver@^5.0.3: version "5.4.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e" +semver@^5.5.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab" + send@0.14.1: version "0.14.1" resolved "https://registry.yarnpkg.com/send/-/send-0.14.1.tgz#a954984325392f51532a7760760e459598c89f7a"