question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not importing Promise.allSettled with useBuiltIns: 'usage'

See original GitHub issue

Bug Report

Current Behavior I’m using Promise.allSettled on source code but core-js/modules/es.promise.all-settled is not being imported on output. Other polyfills like core-js/modules/es.promise and core-js/modules/es.promise.finally are normally imported, the problem seems to be only with allSettled.

Is it because Promise.allSettled() is still a Draft?

Input Code

Promise.allSettled(promises)
  .then(() => {
    // do stuff
  })

https://github.com/ecomclub/storefront-template/blob/930db9e9bae1d59d7b09e2292f878c0bbb5d1e2d/template/js/lib/load-widgets.js#L52

Expected behavior/code

import 'core-js/modules/es.promise.all-settled'

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)

  • Filename: babel.config.js
{
  presets: [
    ['@babel/preset-env', { useBuiltIns: 'usage', corejs: 3 }]
  ],
  plugins: [
    '@babel/plugin-syntax-dynamic-import'
  ]
}
  • Filename: .eslintrc.js
module.exports = {
  parser: "babel-eslint",
};
  • Filename: .browserslistrc
last 1 version
not dead
> 0.2%

Environment

  System:
    OS: Linux 5.4 Arch Linux
  Binaries:
    Node: 13.3.0 - /usr/bin/node
    Yarn: 1.21.1 - /usr/bin/yarn
    npm: 6.13.4 - /usr/bin/npm
  npmPackages:
    @babel/core: ^7.7.5 => 7.7.5 
    @babel/plugin-syntax-dynamic-import: ^7.7.4 => 7.7.4 
    @babel/preset-env: ^7.7.6 => 7.7.6 
    babel-loader: ^8.0.6 => 8.0.6 
    webpack: ^4.41.2 => 4.41.2

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
zloirockcommented, Dec 17, 2019

Sure, but if you don’t need the rest proposals and the size of the bundle makes sense for you - I don’t recommend to do it, import 'core-js/modules/es.promise.all-settled' could be better -)

1reaction
zloirockcommented, Dec 17, 2019

You should use something like corejs: '3.5', but now it will not work since built-ins definitions are obsolete on the Babel’s side. For useBuiltIns: 'entry', corejs: '3.5' will fix it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Promise.allSettled in babel ES6 implementation - Stack Overflow
On babel's core-js Promise , there is no allSettled method. Currently I'm using q.allSettled as a workaround: import { allSettled } from 'q';....
Read more >
babel/polyfill
We do not recommend that you import the whole polyfill directly: either try the useBuiltIns options or import only the polyfills you need...
Read more >
Promise.allSettled in babel ES6 implementation-node.js
create a new promise with an executor function; use a counter/result array in the scope of the executor; register a then() callback with...
Read more >
Promise.allSettled() - JavaScript - MDN Web Docs
The Promise.allSettled() method takes an iterable of promises as input and returns a single Promise. This returned promise fulfills when all of the...
Read more >
Browser Compatibility | Vue CLI
By default, it passes useBuiltIns: 'usage' to @babel/preset-env ... This will import ALL polyfills based on your browserslist targets so ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found