Skip to content

Commit

Permalink
[major] move to react 16 exclusively (#635)
Browse files Browse the repository at this point in the history
  • Loading branch information
jchip authored Nov 21, 2017
1 parent aec2826 commit bf47f09
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 26 deletions.
6 changes: 4 additions & 2 deletions packages/electrode-archetype-opt-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ module.exports = {

If nothing is set, then default is to use `react`.

The other lib that's planned for support is [inferno](https://github.com/infernojs/inferno).
The other lib that is supported:

- [inferno](https://github.com/infernojs/inferno).

Note that since many other modules could depend on the original React lib so even if an app choose to use inferno, the `react` modules could still be installed.

Expand All @@ -29,7 +31,7 @@ In `package.json`:
```js
{
"optionalDependencies": {
"electrode-archetype-opt-react": "^0.1.0"
"electrode-archetype-opt-react": "^1.0.0"
}
}
```
Expand Down
17 changes: 10 additions & 7 deletions packages/electrode-archetype-opt-react/optional-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,29 @@ function findAppDir() {
}

const appDir = findAppDir();
const myPkg = require("./package.json");

if (cwd === appDir) {
try {
const myPkg = require("./package.json");
const appPkg = require(Path.join(appDir, "package.json"));
if (myPkg.name === appPkg.name) {
process.exit(0);
}
} catch (e) {
}
} catch (e) {}
}

const name = myPkg.name;
const myTag = "react";

try {
const config = require(Path.join(appDir, "archetype/config"));
const lib = config && config.options && config.options.reactLib;
if (lib && lib !== "react") {
console.log(`electrode-archetype-opt-react: archetype config set reactLib to ${lib} - skipping install`);
if (lib && lib !== myTag) {
console.log(
`${name}: archetype config set reactLib to ${lib} - skipping install because it's not ${myTag}`
);
process.exit(1);
}
} catch (e) {
}
} catch (e) {}

process.exit(0);
4 changes: 2 additions & 2 deletions packages/electrode-archetype-opt-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"preinstall": "node optional-check.js"
},
"dependencies": {
"react": "^16.0.0 || ^15.0.0 || ^0.14.0",
"react-dom": "^16.0.0 || ^15.0.0 || ^0.14.0"
"react": "^16.0.0",
"react-dom": "^16.0.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ const chai = require("chai");
const sinonChai = require("sinon-chai");
const chaiShallowly = require("chai-shallowly");
const chaiAsPromised = require("chai-as-promised");
const Enzyme = require("enzyme");
const Adapter = require("enzyme-adapter-react-16");

Enzyme.configure({ adapter: new Adapter() });

chai.use(chaiAsPromised);
chai.use(sinonChai);
Expand Down
8 changes: 4 additions & 4 deletions packages/electrode-archetype-react-app-dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"babel-preset-react": "^6.3.13",
"chai": "^4.0.0",
"chai-as-promised": "^7.1.1",
"chai-shallowly": "^0.9.10",
"chai-shallowly": "^1.0.0",
"clean-css": "^3.4.21",
"convert-source-map": "^1.5.0",
"css-loader": "^0.26.1",
Expand All @@ -49,6 +49,7 @@
"electrode-cdn-file-loader": "^1.0.0",
"electrode-electrify": "^1.0.0",
"electrode-webpack-reporter": "^0.3.13",
"enzyme-adapter-react-16": "^1.1.0",
"eslint": "^4.8.0",
"eslint-config-walmart": "^1.1.0",
"eslint-plugin-filenames": "^1.1.0",
Expand Down Expand Up @@ -93,10 +94,9 @@
"postcss-loader": "^0.11.1",
"prop-types": "^15.5.6",
"raw-loader": "^0.5.1",
"react-addons-test-utils": "^15.3.0",
"react-hot-loader": "^1.2.8",
"react-intl": "^2.1.0",
"react-test-renderer": "^15.5.4",
"react-test-renderer": "^16.1.1",
"require-at": "^1.0.0",
"rimraf": "^2.4.0",
"sinon": "^4.0.0",
Expand Down Expand Up @@ -128,7 +128,7 @@
"prettier": "^1.4.4"
},
"engines": {
"node": ">= 4 <= 8",
"node": ">= 6 <= 8",
"npm": ">= 3 <= 5"
}
}
4 changes: 2 additions & 2 deletions packages/electrode-archetype-react-app/arch-clap.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ function makeTasks() {
desc: AppMode.isSrc
? `Build your app's ${AppMode.src.dir} directory into ${AppMode.lib.dir} for production`
: "Build your app's client bundle",
task: ["build-dist", ".build-lib", "ss-prod-react", ".check.top.level.babelrc"]
task: ["build-dist", ".build-lib", ".check.top.level.babelrc"]
},

//
Expand Down Expand Up @@ -695,7 +695,7 @@ Individual .babelrc files were generated for you in src/client and src/server
"generate-service-worker": {
desc:
"Generate Service Worker using the options provided in the app/config/sw-precache-config.json " +
"file for prod/dev/hot mode",
"file for prod/dev/hot mode",
task: () => generateServiceWorker()
},
"optimize-stats": {
Expand Down
2 changes: 1 addition & 1 deletion packages/electrode-archetype-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"winston": "^2.3.1"
},
"engines": {
"node": ">= 4 <= 8",
"node": ">= 6 <= 8",
"npm": ">= 3 <= 5"
},
"nyc": {
Expand Down
15 changes: 7 additions & 8 deletions packages/electrode-archetype-react-app/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

const optionalRequire = require("optional-require")(require);
const optimizeModulesForProduction = require("./optimize-modules-for-production");
const babelRegister = optionalRequire("babel-register");
const isomorphicExtendRequire = require("isomorphic-loader/lib/extend-require");
const babelPolyfill = require("babel-polyfill");
const archetype = require("../config/archetype");
const AppMode = archetype.AppMode;
const Path = require("path");
Expand All @@ -20,7 +18,6 @@ const support = {
require("css-modules-require-hook")(options);
},
require: require("../require"),
babelRegister,
isomorphicExtendRequire: () => {
return isomorphicExtendRequire({
processAssets: assets => {
Expand All @@ -39,7 +36,6 @@ const support = {
}
});
},
babelPolyfill,
optimizeModulesForProduction
};

Expand Down Expand Up @@ -79,7 +75,8 @@ support.load = function(options, callback) {
}

if (br) {
if (!support.babelRegister) {
const babelRegister = optionalRequire("babel-register");
if (!babelRegister) {
console.log(
"To use babel-register mode, you need to install the babel-register and support modules."
);
Expand All @@ -94,13 +91,15 @@ support.load = function(options, callback) {
);

logger.info(
`Loading babel-register for runtime transpilation files (extensions: ${regOptions.extensions}).`
`Loading babel-register for runtime transpilation files (extensions: ${
regOptions.extensions
}).`
);
logger.info(`The transpilation only occurs the first time you load a file.`);
support.babelRegister(regOptions);
babelRegister(regOptions);
}

if (options.optimizeModulesForProduction !== false) {
if (options.optimizeModulesForProduction === true) {
const opts = options.optimizeModulesForProduction;

support.optimizeModulesForProduction(typeof opts === "object" && opts);
Expand Down

0 comments on commit bf47f09

Please sign in to comment.