Promise.allSettled is not being pollyfilled or transpiled down by babel

881 views Asked by At

I'm trying to transpile code down to node v10.

It seems to mostly be working, however it seems to leave Promise.allSettled in the bundle and doesn't transpile it in a way that node v10 can interpret.

This is my webpack:

var path = require("path")
module.exports = {
  entry: "./index.js",
  output: {
    path: path.resolve(__dirname, "dist"),
    filename: "bundle.js",
  },
  target: "node",
  mode: "production",
  module: {
    rules: [{
      test: /\.m?js$/,
      exclude: /(node_modules|bower_components)/,
      use: {
        loader: "babel-loader",
        options: {
          presets: [
            [
              "@babel/preset-env", {
                targets: { node: "10.15.0" },
              }
            ]
          ],
        },
      },
    }],
  },
}

What can I do in order to get it to transpile down Promise.allSettled?

I have tried to follow this SO answer by changing the @babel/preset-env to this:

[
  "@babel/preset-env", {
    targets: { node: "10.15.0" },
    useBuiltIns: 'usage',
    corejs: {version: 3, proposals: true}
  }
]

However, that just gives me the error: Module not found: Error: Can't resolve 'core-js/modules/esnext.promise.all-settled'.

0

There are 0 answers