From a0b460b084c256739699fbe27ae4af4c25ee7c98 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Sun, 17 Apr 2016 21:06:51 +0100 Subject: [PATCH] Include react-addons-perf for non-production builds This makes it possible to gather a few performance stats --- package.json | 1 + src/vector/index.js | 9 ++++++++- webpack.config.js | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 7673f61aed..21e40ecbd3 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,7 @@ "parallelshell": "^1.2.0", "phantomjs-prebuilt": "^2.1.7", "react-addons-test-utils": "^15.0.1", + "react-addons-perf": "^15.0", "rimraf": "^2.4.3", "source-map-loader": "^0.1.5", "webpack": "^1.12.14" diff --git a/src/vector/index.js b/src/vector/index.js index 6dd975d2af..e3178c96e5 100644 --- a/src/vector/index.js +++ b/src/vector/index.js @@ -27,8 +27,15 @@ require('gemini-scrollbar/gemini-scrollbar.css'); require('gfm.css/gfm.css'); require('highlight.js/styles/github.css'); + + // add React and ReactPerf to the global namespace, to make them easier to + // access via the console +global.React = require("react"); +if (process.env.NODE_ENV !== 'production') { + global.ReactPerf = require("react-addons-perf"); +} + var RunModernizrTests = require("./modernizr"); // this side-effects a global -var React = require("react"); var ReactDOM = require("react-dom"); var sdk = require("matrix-react-sdk"); sdk.loadSkin(require('../component-index')); diff --git a/webpack.config.js b/webpack.config.js index dfe127d6f0..297881f331 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -41,6 +41,7 @@ module.exports = { // alias any requires to the react module to the one in our path, otherwise // we tend to get the react source included twice when using npm link. react: path.resolve('./node_modules/react'), + "react-addons-perf": path.resolve('./node_modules/react-addons-perf'), // same goes for js-sdk "matrix-js-sdk": path.resolve('./node_modules/matrix-js-sdk'),