2

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'.

David
  • 330
  • 1
  • 3
  • 11

0 Answers0