Use React and React-DOM through global to use the exact same dependency everywhere

This commit is contained in:
Aurelsicoko 2017-09-22 16:56:09 +02:00
parent a67229496e
commit b8accc03b9
55 changed files with 30 additions and 61 deletions

View File

@ -7,8 +7,6 @@
import 'babel-polyfill';
// Import all the third party stuff
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { ConnectedRouter } from 'react-router-redux';
import createHistory from 'history/createBrowserHistory';
@ -121,7 +119,6 @@ window.Strapi = {
apiUrl,
refresh: (pluginId) => ({
translationMessages: (translationMessagesUpdated) => {
console.log(translationMessagesUpdated);
render(merge({}, translationMessages, translationMessagesUpdated));
},
leftMenuSections: (leftMenuSectionsUpdated) => {

View File

@ -4,8 +4,6 @@
*
*/
import React from 'react';
import styles from './styles.scss';
class Header extends React.Component { // eslint-disable-line react/prefer-stateless-function

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import { defineMessages, FormattedMessage } from 'react-intl';
import LocaleToggle from 'containers/LocaleToggle';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import { Link } from 'react-router-dom';
import styles from './styles.scss';

View File

@ -5,7 +5,6 @@
*/
import _ from 'lodash';
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { Link } from 'react-router-dom';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { map } from 'lodash';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import ReactCSSTransitionGroup from 'react/lib/ReactCSSTransitionGroup';
import Notification from 'components/Notification';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import ToggleOption from 'components/ToggleOption';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { injectIntl, intlShape } from 'react-intl';

View File

@ -9,7 +9,6 @@
* the linting exception.
*/
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { createStructuredSelector } from 'reselect';

View File

@ -11,7 +11,6 @@
* the linting exception.
*/
import React from 'react';
import PropTypes from 'prop-types';
import { Switch, Route } from 'react-router-dom';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import { connect } from 'react-redux';
import Helmet from 'react-helmet';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import { connect } from 'react-redux';
import Helmet from 'react-helmet';
import { FormattedMessage } from 'react-intl';

View File

@ -6,7 +6,6 @@
* IntlProvider component and i18n messages (loaded from `app/translations`)
*/
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';

View File

@ -9,7 +9,6 @@
* the linting exception.
*/
import React from 'react';
import PropTypes from 'prop-types';
import { defineMessages, FormattedMessage } from 'react-intl';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { createStructuredSelector } from 'reselect';

View File

@ -3,8 +3,7 @@
* PluginPage
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import Helmet from 'react-helmet';

View File

@ -12,5 +12,7 @@
<!-- The app hooks into this div -->
<div id="app"></div>
<!-- A lot of magic happens in this file. HtmlWebpackPlugin automatically includes all assets (e.g. bundle.js, main.css) with the correct HTML tags, which is why they are missing in this HTML file. Don't add any assets here! (Check out webpackconfig.js if you want to know more) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react-with-addons.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react-dom.min.js"></script>
</body>
</html>

View File

@ -1,4 +1,4 @@
import React from 'react';
import PropTypes from 'prop-types';
import hoistNonReactStatics from 'hoist-non-react-statics';

View File

@ -1,4 +1,4 @@
import React from 'react';
import PropTypes from 'prop-types';
import hoistNonReactStatics from 'hoist-non-react-statics';

View File

@ -30,7 +30,7 @@
},
"devDependencies": {
"cross-env": "^5.0.5",
"eslint": "^4.7.1",
"eslint": "^4.7.2",
"eslint-config-airbnb": "^15.1.0",
"eslint-config-airbnb-base": "^11.3.2",
"eslint-config-prettier": "^2.5.0",

View File

@ -71,6 +71,7 @@
"no-use-before-define": 0,
"prefer-template": 2,
"class-methods-use-this": 0,
"react/react-in-jsx-scope": 0,
"react/forbid-prop-types": 0,
"react/jsx-first-prop-new-line": [
2,

View File

@ -16,8 +16,13 @@ module.exports = (options) => ({
publicPath: '/',
}, options.output), // Merge with env dependent settings
module: {
// Comment
noParse: [
/\/react\//g,
/\/react-dom\//g,
],
loaders: [{
test: /\.js$/, // Transform all .js files required somewhere with Babel
test: /\.js$/, // Transform all .js files required somewhere with Babel,
use: {
loader: 'babel-loader',
options: {
@ -140,6 +145,8 @@ module.exports = (options) => ({
],
alias: {
moment: 'moment/moment.js',
'react': 'React',
'react-dom': 'React-DOM',
},
symlinks: false,
extensions: [
@ -153,7 +160,7 @@ module.exports = (options) => ({
'main',
],
},
externals: generateExternals(),
resolveLoader: {
modules: [
path.join(__dirname, '..', '..', '..', 'node_modules'),
@ -163,3 +170,10 @@ module.exports = (options) => ({
devtool: options.devtool,
target: 'web', // Make web variables accessible to webpack, e.g. window
});
function generateExternals() {
return {
'react': 'React',
'react-dom': 'ReactDOM',
};
}

View File

@ -5,7 +5,6 @@
* only setup and plugin code.
*/
import React from 'react';
import { Provider } from 'react-redux';
import App, { bootstrap } from 'containers/App'; // eslint-disable-line

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import styles from './styles.scss';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import moment from 'moment';
import PropTypes from 'prop-types';
import { get, isEmpty, map, mapKeys, isObject, reject, includes } from 'lodash';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import PluginHeaderTitle from 'components/PluginHeaderTitle';
import PluginHeaderActions from 'components/PluginHeaderActions';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import Button from 'components/Button';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import PropTypes from 'prop-types';
// modal

View File

@ -1,4 +1,4 @@
import React from 'react';
import PropTypes from 'prop-types';
import hoistNonReactStatics from 'hoist-non-react-statics';

View File

@ -1,4 +1,4 @@
import React from 'react';
import PropTypes from 'prop-types';
import hoistNonReactStatics from 'hoist-non-react-statics';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import PropTypes from 'prop-types';
class Container extends React.Component {

View File

@ -5,7 +5,6 @@
*/
// Dependencies.
import React from 'react';
import PropTypes from 'prop-types';
import { findIndex, get, omit, isFunction, merge } from 'lodash';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { map } from 'lodash';
@ -15,7 +14,7 @@ import styles from './styles.scss';
class EditFormRelations extends React.Component { // eslint-disable-line react/prefer-stateless-function
render() {
const relations = map(this.props.schema[this.props.currentModelName].relations, (relation, i) => {
switch (relation.nature) {
case 'oneToOne':
case 'oneToMany':

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { map } from 'lodash';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import { map } from 'lodash';
import PropTypes from 'prop-types';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import Select from 'react-select';
import PropTypes from 'prop-types';
import 'react-select/dist/react-select.css';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import Select from 'react-select';
import PropTypes from 'prop-types';
import 'react-select/dist/react-select.css';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import TableHeader from '../TableHeader';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import styles from './styles.scss';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import LimitSelect from '../LimitSelect';
@ -22,7 +21,7 @@ class TableFooter extends React.Component {
limit={this.props.limit}
/>
</div>
<div className="col-lg-6">
<Pagination
limit={this.props.limit}

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import styles from './styles.scss';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { isEmpty } from 'lodash';

View File

@ -5,7 +5,6 @@
*
*/
import React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators, compose } from 'redux';
import { createStructuredSelector } from 'reselect';

View File

@ -5,7 +5,6 @@
*/
// Dependencies.
import React from 'react';
import moment from 'moment';
import { connect } from 'react-redux';
import { bindActionCreators, compose } from 'redux';

View File

@ -2,7 +2,6 @@
* Home
*/
import React from 'react';
import { connect } from 'react-redux';
import { createStructuredSelector } from 'reselect';
import { FormattedMessage } from 'react-intl';

View File

@ -4,7 +4,6 @@
*
*/
import React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators, compose } from 'redux';
import { createStructuredSelector } from 'reselect';

View File

@ -9,7 +9,6 @@
* the linting exception.
*/
import React from 'react';
import { FormattedMessage } from 'react-intl';
export default class NotFound extends React.Component {

View File

@ -34,7 +34,7 @@
"prebuild": "npm run build:clean && npm run test",
"build": "cross-env NODE_ENV=production webpack --config node_modules/strapi-helper-plugin/lib/internals/webpack/webpack.prod.babel.js --color -p --progress",
"build:clean": "rimraf admin/build",
"start": "cross-env NODE_ENV=development node node_modules/strapi-helper-plugin/lib/server",
"start": "cross-env NODE_ENV=development PLUGIN=true node node_modules/strapi-helper-plugin/lib/server",
"generate": "node_modules/plop/plop.js --plopfile node_modules/strapi-helper-plugin/lib/internals/generators/index.js",
"lint": "eslint --ignore-path .gitignore --config node_modules/strapi-helper-plugin/lib/internals/eslint/.eslintrc.json admin",
"pretest": "npm run lint",
@ -49,7 +49,7 @@
},
"devDependencies": {
"cross-env": "^5.0.5",
"eslint": "^4.7.1",
"eslint": "^4.7.2",
"eslint-config-airbnb": "^15.1.0",
"eslint-config-airbnb-base": "^11.3.2",
"eslint-config-prettier": "^2.5.0",

View File

@ -35,7 +35,7 @@
},
"devDependencies": {
"cross-env": "^5.0.5",
"eslint": "^4.7.1",
"eslint": "^4.7.2",
"eslint-config-airbnb": "^15.1.0",
"eslint-config-airbnb-base": "^11.3.2",
"eslint-config-prettier": "^2.5.0",