Promise.finally is not defined in Electron with Babel

I have a so weird problem that I don’t have an idea where to search for the error.
The error I found is:

myFunction().finally is not a function

where myFunction return a return (new ApolloClient({link, cache})).query().

The weird stuff is that it works on Chrome but not on Electron.

The code is compiled using Webpack 4 and the following JS Loaders:

let jsLoaders = [{
    loader: 'babel-loader',
    options: {
        cacheDirectory: true,
        presets: ['@babel/preset-env'],
        plugins: [
            '@babel/plugin-transform-runtime',
            '@babel/plugin-proposal-optional-chaining',
            '@babel/plugin-proposal-nullish-coalescing-operator',
            'angularjs-annotate',
        ].concat(isDevelopment ? ['@babel/plugin-transform-modules-commonjs'] : []),
    },
}];

but even trying the update the babel presets with

presets: [['@babel/preset-env', {
            useBuiltIns: "usage",
            shippedProposals: true,
            corejs: "3.9.1",
        }]],

it works on Chrome but not Electron.

Another esoteric behaviour is that, using Electron, if I navigate to another specific page (discovered clicking around in the app), totally uncorrelated with the broken page, the broken page results fixed and start to find finally as a function…

Source: Ask Javascript Questions

LEAVE A COMMENT