commit 4dd661c4ee7e1e53eb6d4ecb8ea3b4c874590be8
parent a3505d7bb42ac3afa5ad9c28b05bee75b44ff3f4
Author: Konstantin Tarkus <hello@tarkus.me>
Date: Mon, 9 Feb 2015 23:30:00 +0300
Replace `require(...)` statements with ES6 `import X from Y`
Diffstat:
15 files changed, 50 insertions(+), 52 deletions(-)
diff --git a/gulpfile.js b/gulpfile.js
@@ -39,7 +39,7 @@ var src = {};
var watch = false;
// The default task
-gulp.task('default', ['serve']);
+gulp.task('default', ['sync']);
// Clean up
gulp.task('clean', del.bind(null, [DEST]));
diff --git a/src/actions/AppActions.js b/src/actions/AppActions.js
@@ -8,10 +8,10 @@
'use strict';
-var Dispatcher = require('../core/Dispatcher');
-var ActionTypes = require('../constants/ActionTypes');
-var ExecutionEnvironment = require('react/lib/ExecutionEnvironment');
-var http = require('superagent');
+import Dispatcher from '../core/Dispatcher';
+import ActionTypes from '../constants/ActionTypes';
+import ExecutionEnvironment from 'react/lib/ExecutionEnvironment';
+import http from 'superagent';
module.exports = {
diff --git a/src/app.js b/src/app.js
@@ -8,14 +8,14 @@
'use strict';
-require('6to5/polyfill');
+import '6to5/polyfill';
-var React = require('react');
-var emptyFunction = require('react/lib/emptyFunction');
-var App = require('./components/App');
-var Dispatcher = require('./core/Dispatcher');
-var AppActions = require('./actions/AppActions');
-var ActionTypes = require('./constants/ActionTypes');
+import React from 'react';
+import emptyFunction from 'react/lib/emptyFunction';
+import App from './components/App';
+import Dispatcher from './core/Dispatcher';
+import AppActions from './actions/AppActions';
+import ActionTypes from './constants/ActionTypes';
var path = decodeURI(window.location.pathname);
var setMetaTag = (name, content) => {
diff --git a/src/components/App/App.js b/src/components/App/App.js
@@ -8,16 +8,16 @@
'use strict';
-require('./App.less');
+import './App.less';
-var React = require('react');
-var invariant = require('react/lib/invariant');
-var AppActions = require('../../actions/AppActions');
-var NavigationMixin = require('./NavigationMixin');
-var AppStore = require('../../stores/AppStore');
-var Navbar = require('../Navbar');
-var ContentPage = require('../ContentPage');
-var NotFoundPage = require('../NotFoundPage');
+import React from 'react';
+import invariant from 'react/lib/invariant';
+import AppActions from '../../actions/AppActions';
+import NavigationMixin from './NavigationMixin';
+import AppStore from '../../stores/AppStore';
+import Navbar from '../Navbar';
+import ContentPage from '../ContentPage';
+import NotFoundPage from '../NotFoundPage';
var Application = React.createClass({
diff --git a/src/components/App/NavigationMixin.js b/src/components/App/NavigationMixin.js
@@ -8,9 +8,9 @@
'use strict';
-var React = require('react');
-var ExecutionEnvironment = require('react/lib/ExecutionEnvironment');
-var AppActions = require('../../actions/AppActions');
+import React from 'react';
+import ExecutionEnvironment from 'react/lib/ExecutionEnvironment';
+import AppActions from '../../actions/AppActions';
var NavigationMixin = {
diff --git a/src/components/ContentPage/ContentPage.js b/src/components/ContentPage/ContentPage.js
@@ -8,7 +8,7 @@
'use strict';
-var React = require('react');
+import React from 'react';
var ContentPage = React.createClass({
diff --git a/src/components/HomePage/HomePage.js b/src/components/HomePage/HomePage.js
@@ -8,7 +8,7 @@
'use strict';
-var React = require('react');
+import React from 'react';
var HomePage = React.createClass({
diff --git a/src/components/Navbar/Navbar.js b/src/components/Navbar/Navbar.js
@@ -8,9 +8,7 @@
'use strict';
-var React = require('react');
-
-var logo = require('./logo-small.png');
+import React from 'react';
var Navbar = React.createClass({
diff --git a/src/components/NotFoundPage/NotFoundPage.js b/src/components/NotFoundPage/NotFoundPage.js
@@ -10,19 +10,19 @@
//require('./NotFoundPage.less');
-var React = require('react');
+import React from 'react';
var NotFoundPage = React.createClass({
render() {
- /* jshint ignore:start */
return (
+ /* jshint ignore:start */
<div>
<h1>Page Not Found</h1>
<p>Sorry, but the page you were trying to view does not exist.</p>
</div>
+ /* jshint ignore:end */
);
- /* jshint ignore:end */
}
});
diff --git a/src/components/TextBox/TextBox.js b/src/components/TextBox/TextBox.js
@@ -8,9 +8,9 @@
'use strict';
-require('./TextBox.less');
+import './TextBox.less';
-var React = require('react');
+import React from 'react';
var TextBox = React.createClass({
diff --git a/src/constants/ActionTypes.js b/src/constants/ActionTypes.js
@@ -8,7 +8,7 @@
'use strict';
-var keyMirror = require('react/lib/keyMirror');
+import keyMirror from 'react/lib/keyMirror';
var ActionTypes = keyMirror({
diff --git a/src/constants/PayloadSources.js b/src/constants/PayloadSources.js
@@ -8,7 +8,7 @@
'use strict';
-var keyMirror = require('react/lib/keyMirror');
+import keyMirror from 'react/lib/keyMirror';
var PayloadSources = keyMirror({
diff --git a/src/core/Dispatcher.js b/src/core/Dispatcher.js
@@ -8,9 +8,9 @@
'use strict';
-var Flux = require('flux');
-var PayloadSources = require('../constants/PayloadSources');
-var assign = require('react/lib/Object.assign');
+import Flux from 'flux';
+import PayloadSources from '../constants/PayloadSources';
+import assign from 'react/lib/Object.assign';
/**
* A singleton that operates as the central hub for application updates.
diff --git a/src/server.js b/src/server.js
@@ -8,11 +8,11 @@
'use strict';
-var _ = require('lodash');
-var fs = require('fs');
-var path = require('path');
-var express = require('express');
-var React = require('react');
+import _ from 'lodash';
+import fs from 'fs';
+import path from 'path';
+import express from 'express';
+import React from 'react';
// Set global variables
global.__DEV__ = process.env.NODE_ENV == 'development';
@@ -22,9 +22,9 @@ global.__SERVER__ = true;
var App = React.createFactory(require('./components/App'));
var templateFile = path.join(__dirname, 'templates/index.html');
var template = _.template(fs.readFileSync(templateFile, 'utf8'));
-var Dispatcher = require('./core/Dispatcher');
-var ActionTypes = require('./constants/ActionTypes');
-var AppStore = require('./stores/AppStore');
+import Dispatcher from './core/Dispatcher';
+import ActionTypes from './constants/ActionTypes';
+import AppStore from './stores/AppStore';
var server = express();
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js
@@ -8,11 +8,11 @@
'use strict';
-var Dispatcher = require('../core/Dispatcher');
-var ActionTypes = require('../constants/ActionTypes');
-var PayloadSources = require('../constants/PayloadSources');
-var EventEmitter = require('eventemitter3');
-var assign = require('react/lib/Object.assign');
+import Dispatcher from '../core/Dispatcher';
+import ActionTypes from '../constants/ActionTypes';
+import PayloadSources from '../constants/PayloadSources';
+import EventEmitter from 'eventemitter3';
+import assign from 'react/lib/Object.assign';
var CHANGE_EVENT = 'change';