I accidentally caused a backward compatibility issue in my React application by utilizing Array.prototype.flat
. I was quite surprised that this problem persisted even after transpiling - I had assumed it would generate es2015-compatible code.
Is there a way to get Babel 7 to properly transpile this? (It seems like in Babel 6, there was a plugin for this but with the emergence of browser support, it may have been discontinued?)
Tools:
The configurations in my top-level files are as follows:
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