Skip to content

Commit ef142b7

Browse files
committed
babel 7 upgrade WIP
1 parent 50d6622 commit ef142b7

File tree

12 files changed

+13914
-11783
lines changed

12 files changed

+13914
-11783
lines changed

.babelrc

Lines changed: 0 additions & 5 deletions
This file was deleted.

babel.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const presets = [
2+
'./config/babel/node-ssr',
3+
];
4+
5+
module.exports = { presets };

config/babel/node-ssr.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/* Babel preset for NodeJS build with support of server-side JSX rendering. */
22

33
const _ = require('lodash');
4-
const config = _.cloneDeep(require('./webpack'));
4+
const babelConfig = require('./webpack');
5+
6+
const config = babelConfig();
57

68
const cssModulesTransformPluginOps = {
79
extensions: ['.css', '.scss'],
@@ -12,7 +14,6 @@ const transformAssetsPluginOptions = {
1214
};
1315

1416
config.plugins = config.plugins.concat([
15-
'dynamic-import-node',
1617
['transform-assets', transformAssetsPluginOptions],
1718
['css-modules-transform', cssModulesTransformPluginOps],
1819
]);

config/babel/webpack.js

Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,47 @@
11
/* Babel preset for the Webpack build. */
2-
3-
const reactCssModulesPluginOps = {
4-
filetypes: {
5-
'.scss': {
6-
syntax: 'postcss-scss',
2+
/* eslint-disable */
3+
module.exports = () => {
4+
const reactCssModulesPluginOps = {
5+
filetypes: {
6+
'.scss': {
7+
syntax: 'postcss-scss',
8+
},
79
},
8-
},
9-
};
10+
};
1011

11-
const config = {
12-
presets: [
13-
'env',
14-
'react',
15-
'stage-2',
16-
],
17-
plugins: [
18-
['module-resolver', {
19-
extensions: ['.js', '.jsx'],
20-
root: [
21-
'./src/shared',
22-
'./src',
12+
const config = {
13+
presets: [
14+
'@babel/env',
15+
'@babel/react',
16+
],
17+
plugins: [
18+
require('@babel/plugin-syntax-dynamic-import'),
19+
require('@babel/plugin-syntax-import-meta'),
20+
[require('@babel/plugin-proposal-decorators'), { legacy: true }],
21+
[require('@babel/plugin-proposal-class-properties'), { loose: false }],
22+
require('@babel/plugin-proposal-json-strings'),
23+
[
24+
'module-resolver',
25+
{
26+
extensions: ['.js', '.jsx'],
27+
root: ['./src/shared', './src'],
28+
},
2329
],
24-
}],
25-
'inline-react-svg',
26-
'transform-runtime',
27-
['react-css-modules', reactCssModulesPluginOps],
28-
],
29-
};
30+
'inline-react-svg',
31+
[require('@babel/plugin-transform-runtime')],
32+
['react-css-modules', reactCssModulesPluginOps],
33+
],
34+
};
3035

31-
switch (process.env.BABEL_ENV) {
32-
case 'development':
33-
reactCssModulesPluginOps.generateScopedName = '[path][name]___[local]___[hash:base64:6]';
34-
config.plugins.push('react-hot-loader/babel');
35-
break;
36-
case 'production':
37-
reactCssModulesPluginOps.generateScopedName = '[hash:base64:6]';
38-
break;
39-
default:
40-
}
41-
42-
module.exports = config;
36+
switch (process.env.BABEL_ENV) {
37+
case 'development':
38+
reactCssModulesPluginOps.generateScopedName = '[path][name]___[local]___[hash:base64:6]';
39+
config.plugins.push('react-hot-loader/babel');
40+
break;
41+
case 'production':
42+
reactCssModulesPluginOps.generateScopedName = '[hash:base64:6]';
43+
break;
44+
default:
45+
}
46+
return config;
47+
};

config/webpack/app-base.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ module.exports = function configFactory(ops) {
8686
}
8787

8888
entry.polyfills = _.union(entry.polyfills, [
89-
'babel-polyfill',
89+
'@babel/polyfill',
9090
'nodelist-foreach-polyfill',
9191
]);
9292

@@ -147,7 +147,7 @@ module.exports = function configFactory(ops) {
147147
loader: 'babel-loader',
148148
options: {
149149
babelrc: false,
150-
forceEnv: o.babelEnv,
150+
envName: o.babelEnv,
151151
presets: ['topcoder-react-utils/config/babel/webpack'],
152152
},
153153
}, {

config/webpack/lib-base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ module.exports = function configFactory(ops) {
110110
loader: 'babel-loader',
111111
options: {
112112
babelrc: false,
113-
forceEnv: ops.babelEnv,
113+
envName: ops.babelEnv,
114114
presets: ['topcoder-react-utils/config/babel/webpack'],
115115
},
116116
}, {

0 commit comments

Comments
 (0)