Skip to content

Commit 1cd9c4f

Browse files
committed
Move babel config out to its own file
For reasons described within this diff.
1 parent 203c9c8 commit 1cd9c4f

2 files changed

Lines changed: 34 additions & 27 deletions

File tree

‎.babelrc‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"sourceMaps": true,
3+
"presets": [
4+
["@babel/preset-env", {
5+
"targets": {
6+
"browsers": [
7+
"last 2 versions"
8+
]
9+
}
10+
}],
11+
"@babel/preset-typescript",
12+
"@babel/preset-flow",
13+
"@babel/preset-react"
14+
],
15+
"plugins": [
16+
["@babel/plugin-proposal-decorators", {"legacy": true}],
17+
"@babel/plugin-proposal-export-default-from",
18+
"@babel/plugin-proposal-numeric-separator",
19+
"@babel/plugin-proposal-class-properties",
20+
"@babel/plugin-proposal-object-rest-spread",
21+
"@babel/plugin-transform-flow-comments",
22+
"@babel/plugin-syntax-dynamic-import",
23+
"@babel/plugin-transform-runtime"
24+
]
25+
}

‎webpack.config.js‎

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -93,34 +93,16 @@ module.exports = (env, argv) => ({
9393
exclude: /node_modules/,
9494
loader: 'babel-loader',
9595
options: {
96-
// We have the babel config here rather than a file to help
97-
// make it clearer what we're compiling to.
9896
cacheDirectory: true,
99-
sourceMaps: true,
100-
presets: [
101-
["@babel/preset-env", {
102-
"targets": {
103-
"browsers": [
104-
"last 2 versions",
105-
]
106-
},
107-
}],
108-
"@babel/preset-typescript",
109-
"@babel/preset-flow",
110-
"@babel/preset-react",
111-
],
112-
plugins: [
113-
// Most of these plugins are for the react-sdk to make itself
114-
// work correctly.
115-
["@babel/plugin-proposal-decorators", {"legacy": true}],
116-
"@babel/plugin-proposal-export-default-from",
117-
"@babel/plugin-proposal-numeric-separator",
118-
"@babel/plugin-proposal-class-properties",
119-
"@babel/plugin-proposal-object-rest-spread",
120-
"@babel/plugin-transform-flow-comments",
121-
"@babel/plugin-syntax-dynamic-import",
122-
"@babel/plugin-transform-runtime"
123-
],
97+
98+
// These two options are needed to load the babelrc file and
99+
// apply it to node_modules (ie: react-sdk and js-sdk). We
100+
// could put the babel config in this block instead, but we
101+
// publish riot-web to npm for some reason and that seems to
102+
// ship a lib directory. Therefore, we need the babel config
103+
// in a place where babel and babel-loader can reach it.
104+
babelrc: true,
105+
configFile: path.resolve(__dirname, ".babelrc"),
124106
}
125107
},
126108
{

0 commit comments

Comments
 (0)