I inadvertently introduced a backwards compatibility issue in my React app by using Array.prototype.flat
. I was very surprised this didn't get resolved by transpiling - I thought this would result in es2015 compatible code.
How can I get Babel 7 to transpile this? (If my reading of the sources is right in Babel 6 there was still a plugin for this but since this has begun to roll out to browsers support has been dropped?)
Tools:
- @babel/core@7.0.0
- webpack@4.18.0
My top-level configuration files look like this:
webpack.config.js
var path = require('path')
module.exports = {
entry: "./src/index.js",
output: {
path: path.join(__dirname, 'dist', 'assets'),
filename: "bundle.js",
sourceMapFilename: "bundle.map"
},
devtool: '#source-map',
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules)/,
loader: 'babel-loader'
}
]
}}
.babelrc
{
"presets": [ "@babel/preset-env", "@babel/react" ],
"plugins": [["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal" }]]
}
.browserslistrc
chrome 58
ie 11