X Tutup
Skip to content

Commit 225dfdd

Browse files
xabikosSteveSandersonMS
authored andcommitted
aspnet#31 Ugrade to Babel 6 and update the ReactGrid sample
1 parent 73e218d commit 225dfdd

File tree

5 files changed

+14
-16
lines changed

5 files changed

+14
-16
lines changed

samples/react/ReactGrid/ReactApp/data/columnMeta.jsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class RowActionsComponent extends React.Component {
77
}
88
}
99

10-
var columnMeta = [
10+
export const columnMeta = [
1111
{
1212
"columnName": "id",
1313
"order": 1,
@@ -58,6 +58,3 @@ var columnMeta = [
5858
"customComponent": RowActionsComponent
5959
}
6060
];
61-
62-
export var columnMeta;
63-

samples/react/ReactGrid/ReactApp/data/fakeData.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var fakeData = [
1+
export const fakeData = [
22
{
33
"id": 0,
44
"name": "Mayer Leonard",
@@ -2484,6 +2484,3 @@ var fakeData = [
24842484
"favoriteNumber": 1
24852485
}
24862486
];
2487-
2488-
export var fakeData;
2489-

samples/react/ReactGrid/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "ReactExample",
33
"version": "0.0.0",
44
"dependencies": {
5-
"babel-core": "^5.8.29",
5+
"babel-core": "^6.4.0",
66
"bootstrap": "^3.3.5",
77
"formsy-react": "^0.17.0",
88
"formsy-react-components": "^0.6.3",
@@ -14,7 +14,9 @@
1414
"underscore": "^1.8.3"
1515
},
1616
"devDependencies": {
17-
"babel-loader": "^5.3.2",
17+
"babel-loader": "^6.2.1",
18+
"babel-preset-es2015": "^6.3.13",
19+
"babel-preset-react": "^6.3.13",
1820
"css-loader": "^0.21.0",
1921
"extract-text-webpack-plugin": "^0.8.2",
2022
"file-loader": "^0.8.4",

samples/react/ReactGrid/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = {
88
},
99
module: {
1010
loaders: [
11-
{ test: /\.jsx?$/, loader: 'babel-loader' },
11+
{ test: /\.jsx?$/, loader: 'babel-loader', exclude: /node_modules/, query: { presets: ['es2015', 'react'] } },
1212
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') },
1313
{ test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' }
1414
]

src/Microsoft.AspNet.ReactServices/Content/Node/react-rendering.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ var React = require('react');
44
var ReactDOMServer = require('react-dom/server');
55
var createMemoryHistory = require('history/lib/createMemoryHistory');
66
var babelCore = require('babel-core');
7-
var babelConfig = {};
7+
var babelConfig = {
8+
presets: ["es2015", "react"]
9+
};
810

9-
var origJsLoader = require.extensions['.js'];
11+
var origJsLoader = require.extensions['.js'];
1012
require.extensions['.js'] = loadViaBabel;
1113
require.extensions['.jsx'] = loadViaBabel;
1214

@@ -20,7 +22,7 @@ function findReactComponent(options) {
2022
}
2123
return loadedModule[options.exportName];
2224
} else if (typeof loadedModule === 'function') {
23-
// Otherwise, if the module itself is a function, assume that is the component
25+
// Otherwise, if the module itself is a function, assume that is the component
2426
return loadedModule;
2527
} else if (typeof loadedModule.default === 'function') {
2628
// Otherwise, if the module has a default export which is a function, assume that is the component
@@ -33,11 +35,11 @@ function findReactComponent(options) {
3335
function loadViaBabel(module, filename) {
3436
// Assume that all the app's own code is ES2015+ (optionally with JSX), but that none of the node_modules are.
3537
// The distinction is important because ES2015+ forces strict mode, and it may break ES3/5 if you try to run it in strict
36-
// mode when the developer didn't expect that (e.g., current versions of underscore.js can't be loaded in strict mode).
38+
// mode when the developer didn't expect that (e.g., current versions of underscore.js can't be loaded in strict mode).
3739
var useBabel = filename.indexOf('node_modules') < 0;
3840
if (useBabel) {
3941
var transformedFile = babelCore.transformFileSync(filename, babelConfig);
40-
return module._compile(transformedFile.code, filename);
42+
return module._compile(transformedFile.code, filename);
4143
} else {
4244
return origJsLoader.apply(this, arguments);
4345
}

0 commit comments

Comments
 (0)
X Tutup