Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Commit

Permalink
Babel 6
Browse files Browse the repository at this point in the history
  • Loading branch information
steida committed Dec 25, 2015
1 parent acf6d98 commit 9e17eca
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 77 deletions.
32 changes: 6 additions & 26 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,32 +1,12 @@
{
"presets": ["es2015", "react", "stage-1"],
"plugins": ["transform-runtime", "add-module-exports"],
"env": {
"production": {
"optional": [
"optimisation.react.constantElements",
"optimisation.react.inlineElements"
"plugins": [
"transform-react-constant-elements",
"transform-react-inline-elements"
]
}
},
"whitelist": [
"es6.arrowFunctions",
"es6.blockScoping",
"es6.classes",
"es6.destructuring",
"es6.modules",
"es6.parameters",
"es6.properties.computed",
"es6.properties.shorthand",
"es6.spread",
"es6.templateLiterals",
"es7.classProperties",
"es7.decorators",
"es7.objectRestSpread",
"es7.trailingFunctionCommas",
"flow",
"react",
"react.displayName",
"regenerator",
"es6.constants",
"es7.asyncFunctions"
]
}
}
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
android/**
assets/**
build/**
node_modules/**
27 changes: 20 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,37 @@
},
"dependencies": {
"autoprefixer": "^6.1.0",
"babel": "^5.8.29",
"babel-core": "^5.8.29",
"babel-eslint": "^4.1.5",
"babel-loader": "^5.3.3",
"babel-plugin-react-transform": "^1.1.1",
"babel-core": "^6.3.26",
"babel-eslint": "^5.0.0-beta6",
"babel-loader": "^6.2.0",
"babel-plugin-add-module-exports": "^0.1.2",
"babel-plugin-react-transform": "^2.0.0",
"babel-plugin-transform-react-constant-elements": "^6.3.13",
"babel-plugin-transform-react-inline-elements": "^6.3.13",
"babel-plugin-transform-runtime": "^6.3.13",
"babel-preset-es2015": "^6.3.13",
"babel-preset-es2015-node5": "^1.1.1",
"babel-preset-react": "^6.3.13",
"babel-preset-react-hmre": "^1.0.0",
"babel-preset-stage-1": "^6.3.13",
"babel-register": "^6.3.13",
"babel-runtime": "^6.3.19",
"bluebird": "^3.0.5",
"body-parser": "^1.12.4",
"chai": "^3.4.1",
"chai-as-promised": "^5.2.0",
"chai-immutable": "^1.5.2",
"classnames": "^2.1.1",
"compression": "^1.4.0",
"cors": "^2.6.0",
"css-loader": "^0.23.0",
"del": "^2.1.0",
"eslint": "^1.10.3",
"eslint-loader": "^1.1.1",
"eslint-plugin-babel": "^3.0.0",
"eslint-plugin-import": "^0.12.1",
"eslint-plugin-react": "^3.8.0",
"eslint-plugin-react": "^3.13.0",
"eslint-plugin-standard": "^1.3.1",
"estraverse": "^4.1.1",
"express": "^4.13.3",
"express-device": "^0.4.1",
Expand Down Expand Up @@ -77,7 +91,6 @@
"redux-logger": "^2.1.1",
"redux-promise-middleware": "2.2.3",
"redux-storage": "^1.2.4",
"regenerator": "^0.8.42",
"run-sequence": "^1.0.2",
"sass-loader": "^3.0.0",
"serialize-javascript": "^1.1.2",
Expand Down
13 changes: 7 additions & 6 deletions src/browser/app/App.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ import mapDispatchToProps from '../../common/app/mapDispatchToProps';
import mapStateToProps from '../../common/app/mapStateToProps';
import {connect} from 'react-redux';

// // logRenderTime is useful for app with huge UI to check render performance.
// import logRenderTime from '../lib/logRenderTime';

@connect(mapStateToProps, mapDispatchToProps)
// @logRenderTime
export default class App extends Component {
class App extends Component {

static propTypes = {
children: PropTypes.object.isRequired,
Expand Down Expand Up @@ -45,3 +40,9 @@ export default class App extends Component {
}

}

// // logRenderTime is useful for app with huge UI to check render performance.
// import logRenderTime from '../lib/logRenderTime';
// App = logRenderTime(App)

export default connect(mapStateToProps, mapDispatchToProps)(App);
3 changes: 0 additions & 3 deletions src/browser/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import {Provider} from 'react-redux';
// TODO: Add app storage example.
// import storage from 'redux-storage';

// Enabling ES7 `async/await` in browser:
if (process.env.IS_BROWSER) require('regenerator/runtime');

const app = document.getElementById('app');
const engine = createEngine('este-app');
const initialState = window.__INITIAL_STATE__;
Expand Down
9 changes: 5 additions & 4 deletions src/browser/todos/Page.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import React, {PropTypes} from 'react';
import fetch from '../components/fetch';
import {fetchUserTodos} from '../../common/todos/actions';

// This decorator (higher order component) fetches todos both in browser and
// on server side. It's true isomorphic data fetching and rendering.
@fetch(fetchUserTodos)
export default class Page extends Component {
class Page extends Component {

static propTypes = {
actions: PropTypes.object,
Expand All @@ -32,3 +29,7 @@ export default class Page extends Component {
}

}

// This higher order component fetches todos both in browser and on server side.
// It's true isomorphic data fetching and rendering.
export default fetch(fetchUserTodos)(Page);
12 changes: 12 additions & 0 deletions src/server/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": ["es2015-node5", "react", "stage-1"],
"plugins": ["transform-runtime", "add-module-exports"],
"env": {
"production": {
"plugins": [
"transform-react-constant-elements",
"transform-react-inline-elements"
]
}
}
}
6 changes: 3 additions & 3 deletions src/server/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require('babel/register')({optional: ['es7']});
require('babel-register');

const serverConfig = require('./config');

if (!process.env.NODE_ENV)
throw new Error('Environment variable NODE_ENV isn\'t set. Remember it\'s up your production enviroment to set NODE_ENV and maybe other variables.');
// if (!process.env.NODE_ENV)
// throw new Error('Environment variable NODE_ENV isn\'t set. Remember it\'s up your production enviroment to set NODE_ENV and maybe other variables.');

// http://formatjs.io/guides/runtime-environments/#polyfill-node
if (global.Intl) {
Expand Down
1 change: 0 additions & 1 deletion webpack/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import path from 'path';

export const ABSOLUTE_BASE = path.normalize(path.join(__dirname, '..'));


const constants = Object.freeze({
ABSOLUTE_BASE: ABSOLUTE_BASE,
NODE_MODULES_DIR: path.join(ABSOLUTE_BASE, 'node_modules'),
Expand Down
36 changes: 10 additions & 26 deletions webpack/makeConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import path from 'path';
import webpack from 'webpack';
import ip from 'ip';

const devtools = process.env.CONTINUOUS_INTEGRATION
? 'inline-source-map'
// cheap-module-eval-source-map, because we want original source, but we don't
// care about columns, which makes this devtool faster than eval-source-map.
// http://webpack.github.io/docs/configuration.html#devtool
: 'cheap-module-eval-source-map';
// cheap-module-eval-source-map, because we want original source, but we don't
// care about columns, which makes this devtool faster than eval-source-map.
// http://webpack.github.io/docs/configuration.html#devtool
const devtools = 'cheap-module-eval-source-map';

const loaders = {
'css': '',
Expand Down Expand Up @@ -56,33 +54,19 @@ export default function makeConfig(isDevelopment) {
loader: 'url-loader?limit=100000',
test: /\.(gif|jpg|png|woff|woff2|eot|ttf|svg)$/
}, {
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
query: {
stage: 0,
// If cacheDirectory is enabled, it throws:
// Uncaught Error: locals[0] does not appear to be a `module` object with Hot Module replacement API enabled.
// cacheDirectory: true,
cacheDirectory: true,
plugins: ['transform-runtime', 'add-module-exports'],
presets: ['es2015', 'react', 'stage-1'],
env: {
development: {
// react-transform belongs to webpack config only, not to .babelrc
plugins: ['react-transform'],
extra: {
'react-transform': {
transforms: [{
transform: 'react-transform-hmr',
imports: ['react'],
locals: ['module']
}, {
transform: 'react-transform-catch-errors',
imports: ['react', 'redbox-react']
}]
}
}
presets: ['react-hmre']
}
}
},
test: /\.js$/
}
}].concat(stylesLoaders())
},
output: isDevelopment ? {
Expand Down
2 changes: 1 addition & 1 deletion webpack/server/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
if (process.env.NODE_ENV === 'production')
throw new Error('Do not start webpack hot reload server in production environment. You are likely using wrong npm start script');

require('babel/register')({stage: 0});
require('babel-register');

require('./main');

0 comments on commit 9e17eca

Please sign in to comment.