Skip to content

Commit 615dfcd

Browse files
committed
Merge pull request #935 from josmardias/babel-6_
Update to Babel 6 (replaces #778)
2 parents c5fe738 + d564332 commit 615dfcd

File tree

7 files changed

+78
-52
lines changed

7 files changed

+78
-52
lines changed

.babelrc

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
{
2-
"stage": 0,
3-
"optional": "runtime",
4-
"loose": "all",
2+
"presets": ["react", "es2015", "stage-0"],
3+
54
"plugins": [
6-
"typecheck"
5+
"transform-runtime",
6+
"add-module-exports",
7+
"transform-decorators-legacy",
8+
"transform-react-display-name"
79
],
10+
811
"env": {
912
"development": {
1013
"plugins": [
11-
"react-transform"
12-
],
13-
"extra": {
14-
"react-transform": {
15-
"transforms": [{
16-
"transform": "react-transform-catch-errors",
17-
"imports": [
18-
"react",
19-
"redbox-react"
14+
"typecheck",
15+
["react-transform", {
16+
"transforms": [{
17+
"transform": "react-transform-catch-errors",
18+
"imports": ["react", "redbox-react"]
19+
}
2020
]
21-
}]
22-
}
23-
}
21+
}]
22+
]
2423
}
2524
}
2625
}

package.json

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
"start": "concurrent --kill-others \"npm run start-prod\" \"npm run start-prod-api\"",
2828
"start-prod": "better-npm-run start-prod",
2929
"start-prod-api": "better-npm-run start-prod-api",
30-
"build": "webpack --verbose --colors --display-error-details --config webpack/prod.config.js",
31-
"postinstall": "webpack --display-error-details --config webpack/prod.config.js",
30+
"build": "better-npm-run build",
31+
"postinstall": "npm run build",
3232
"lint": "eslint -c .eslintrc src api",
3333
"start-dev": "better-npm-run start-dev",
3434
"start-dev-api": "better-npm-run start-dev-api",
@@ -79,16 +79,33 @@
7979
"UV_THREADPOOL_SIZE": 100,
8080
"NODE_PATH": "./src"
8181
}
82+
},
83+
"build": {
84+
"command": "webpack --verbose --colors --display-error-details --config webpack/prod.config.js",
85+
"env": {
86+
"NODE_ENV": "production"
87+
}
8288
}
8389
},
8490
"dependencies": {
85-
"babel": "~5.8.29",
86-
"babel-plugin-typecheck": "^2.0.0",
91+
"babel-core": "^6.5.2",
92+
"babel-loader": "^6.2.1",
93+
"babel-plugin-add-module-exports": "^0.1.2",
94+
"babel-plugin-transform-decorators-legacy": "^1.3.4",
95+
"babel-plugin-transform-react-display-name": "^6.3.13",
96+
"babel-plugin-transform-runtime": "^6.3.13",
97+
"babel-polyfill": "^6.3.14",
98+
"babel-preset-es2015": "^6.3.13",
99+
"babel-preset-react": "^6.3.13",
100+
"babel-preset-stage-0": "^6.3.13",
101+
"babel-register": "^6.3.13",
102+
"babel-runtime": "^6.3.19",
87103
"body-parser": "^1.14.1",
88104
"compression": "^1.6.0",
89105
"express": "^4.13.3",
90106
"express-session": "^1.12.1",
91107
"file-loader": "^0.8.5",
108+
"hoist-non-react-statics": "^1.0.3",
92109
"http-proxy": "^1.12.0",
93110
"invariant": "^2.2.0",
94111
"less": "^2.5.3",
@@ -122,37 +139,35 @@
122139
},
123140
"devDependencies": {
124141
"autoprefixer-loader": "^3.1.0",
125-
"babel-core": "~5.8.33",
126-
"babel-eslint": "^4.1.3",
127-
"babel-loader": "~5.3.3",
128-
"babel-plugin-react-transform": "~1.1.1",
129-
"babel-runtime": "~5.8.29",
142+
"babel-eslint": "^5.0.0-beta6",
143+
"babel-plugin-react-transform": "^2.0.0",
144+
"babel-plugin-typecheck": "^3.6.0",
130145
"better-npm-run": "^0.0.4",
131146
"bootstrap-sass": "^3.3.5",
132147
"bootstrap-sass-loader": "^1.0.9",
133148
"chai": "^3.3.0",
149+
"clean-webpack-plugin": "^0.1.6",
134150
"concurrently": "^0.1.1",
151+
"css-loader": "^0.23.1",
135152
"eslint": "1.10.3",
136153
"eslint-config-airbnb": "0.1.0",
137154
"eslint-loader": "^1.0.0",
138155
"eslint-plugin-import": "^0.8.0",
139156
"eslint-plugin-react": "^3.5.0",
140-
"clean-webpack-plugin": "^0.1.6",
141-
"css-loader": "^0.23.1",
142157
"extract-text-webpack-plugin": "^0.9.1",
143158
"font-awesome": "^4.4.0",
144159
"font-awesome-webpack": "0.0.4",
145-
"karma": "^0.13.10",
146160
"json-loader": "^0.5.4",
161+
"karma": "^0.13.10",
147162
"karma-cli": "^0.1.1",
148163
"karma-mocha": "^0.2.0",
149164
"karma-mocha-reporter": "^1.1.1",
150165
"karma-phantomjs-launcher": "^0.2.1",
151166
"karma-sourcemap-loader": "^0.3.5",
152167
"karma-webpack": "^1.7.0",
153168
"mocha": "^2.3.3",
154-
"phantomjs": "^1.9.18",
155169
"node-sass": "^3.4.2",
170+
"phantomjs": "^1.9.18",
156171
"phantomjs-polyfill": "0.0.1",
157172
"react-a11y": "^0.2.6",
158173
"react-addons-test-utils": "^0.14.0",

server.babel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ try {
1212
console.error(err);
1313
}
1414

15-
require('babel-core/register')(config);
15+
require('babel-register')(config);

src/client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* THIS IS THE ENTRY POINT FOR THE CLIENT, JUST LIKE server.js IS THE ENTRY POINT FOR THE SERVER.
33
*/
4-
import 'babel/polyfill';
4+
import 'babel-polyfill';
55
import React from 'react';
66
import ReactDOM from 'react-dom';
77
import createStore from './redux/create';

src/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require('babel/polyfill');
1+
require('babel-polyfill');
22

33
const environment = {
44
development: {

webpack/dev.config.js

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
require('babel/polyfill');
1+
require('babel-polyfill');
22

33
// Webpack config for development
44
var fs = require('fs');
55
var path = require('path');
66
var webpack = require('webpack');
7-
var WebpackIsomorphicTools = require('webpack-isomorphic-tools');
87
var assetsPath = path.resolve(__dirname, '../static/dist');
98
var host = (process.env.HOST || 'localhost');
109
var port = parseInt(process.env.PORT) + 1 || 3001;
@@ -23,23 +22,40 @@ try {
2322
console.error(err);
2423
}
2524

25+
2626
var babelrcObjectDevelopment = babelrcObject.env && babelrcObject.env.development || {};
27-
var babelLoaderQuery = Object.assign({}, babelrcObject, babelrcObjectDevelopment);
27+
28+
// merge global and dev-only plugins
29+
var combinedPlugins = babelrcObject.plugins || [];
30+
combinedPlugins = combinedPlugins.concat(babelrcObjectDevelopment.plugins);
31+
32+
var babelLoaderQuery = Object.assign({}, babelrcObjectDevelopment, babelrcObject, {plugins: combinedPlugins});
2833
delete babelLoaderQuery.env;
2934

35+
// Since we use .babelrc for client and server, and we don't want HMR enabled on the server, we have to add
36+
// the babel plugin react-transform-hmr manually here.
37+
38+
// make sure react-transform is enabled
3039
babelLoaderQuery.plugins = babelLoaderQuery.plugins || [];
31-
if (babelLoaderQuery.plugins.indexOf('react-transform') < 0) {
32-
babelLoaderQuery.plugins.push('react-transform');
40+
var reactTransform = null;
41+
for (var i = 0; i < babelLoaderQuery.plugins.length; ++i) {
42+
var plugin = babelLoaderQuery.plugins[i];
43+
if (Array.isArray(plugin) && plugin[0] === 'react-transform') {
44+
reactTransform = plugin;
45+
}
3346
}
3447

35-
babelLoaderQuery.extra = babelLoaderQuery.extra || {};
36-
if (!babelLoaderQuery.extra['react-transform']) {
37-
babelLoaderQuery.extra['react-transform'] = {};
48+
if (!reactTransform) {
49+
reactTransform = ['react-transform', {transforms: []}];
50+
babelLoaderQuery.plugins.push(reactTransform);
3851
}
39-
if (!babelLoaderQuery.extra['react-transform'].transforms) {
40-
babelLoaderQuery.extra['react-transform'].transforms = [];
52+
53+
if (!reactTransform[1] || !reactTransform[1].transforms) {
54+
reactTransform[1] = Object.assign({}, reactTransform[1], {transforms: []});
4155
}
42-
babelLoaderQuery.extra['react-transform'].transforms.push({
56+
57+
// make sure react-transform-hmr is enabled
58+
reactTransform[1].transforms.push({
4359
transform: 'react-transform-hmr',
4460
imports: ['react'],
4561
locals: ['module']

webpack/prod.config.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require('babel/polyfill');
1+
require('babel-polyfill');
22

33
// Webpack config for creating the production bundle.
44
var path = require('path');
@@ -58,6 +58,10 @@ module.exports = {
5858
// css files from the extract-text-plugin loader
5959
new ExtractTextPlugin('[name]-[chunkhash].css', {allChunks: true}),
6060
new webpack.DefinePlugin({
61+
'process.env': {
62+
NODE_ENV: '"production"'
63+
},
64+
6165
__CLIENT__: true,
6266
__SERVER__: false,
6367
__DEVELOPMENT__: false,
@@ -67,14 +71,6 @@ module.exports = {
6771
// ignore dev config
6872
new webpack.IgnorePlugin(/\.\/dev/, /\/config$/),
6973

70-
// set global vars
71-
new webpack.DefinePlugin({
72-
'process.env': {
73-
// Useful to reduce the size of client-side libraries, e.g. react
74-
NODE_ENV: JSON.stringify('production')
75-
}
76-
}),
77-
7874
// optimizations
7975
new webpack.optimize.DedupePlugin(),
8076
new webpack.optimize.OccurenceOrderPlugin(),

0 commit comments

Comments
 (0)