Skip to content

Commit

Permalink
Fix react-scripts to work with alphas after 16.0.0
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Brandon Dail committed Feb 12, 2018
1 parent 2bcbcaf commit 1acea67
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fixtures/dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion fixtures/dom/src/react-loader.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import semver from 'semver'

/**
* Take a version from the window query string and load a specific
* version of React.
Expand Down Expand Up @@ -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 =
Expand Down
4 changes: 4 additions & 0 deletions fixtures/dom/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 1acea67

Please sign in to comment.