Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not importing Promise.allSettled with useBuiltIns: 'usage' #10883

Open
leomp12 opened this issue Dec 17, 2019 · 8 comments · May be fixed by #10929
Open

Not importing Promise.allSettled with useBuiltIns: 'usage' #10883

leomp12 opened this issue Dec 17, 2019 · 8 comments · May be fixed by #10929

Comments

@leomp12
Copy link

@leomp12 leomp12 commented Dec 17, 2019

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
@babel-bot

This comment has been minimized.

Copy link
Collaborator

@babel-bot babel-bot commented Dec 17, 2019

Hey @leomp12! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

@zloirock

This comment has been minimized.

Copy link
Member

@zloirock zloirock commented Dec 17, 2019

@leomp12

This comment has been minimized.

Copy link
Author

@leomp12 leomp12 commented Dec 17, 2019

@zloirock you're suggesting to set corejs: '3.4'?
I've tried specifying corejs: '3.4' (^3.4.8), also tried specifying corejs: '3.5' (^3.5.0), unsuccessfully...
it only worked for me when I added import 'core-js/modules/es.promise.all-settled' it manually in the source code.

@zloirock

This comment has been minimized.

Copy link
Member

@zloirock zloirock commented 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.

@leomp12

This comment has been minimized.

Copy link
Author

@leomp12 leomp12 commented Dec 17, 2019

Update: Hadn't tried before with corejs: { version: 3, proposals: true }, worked! 😅

But I had tried before with shippedProposals: true and it didn't work, shippedProposals !== corejs.proposals? 😕

@zloirock

This comment has been minimized.

Copy link
Member

@zloirock zloirock commented 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 -)

@zloirock

This comment has been minimized.

Copy link
Member

@zloirock zloirock commented Dec 17, 2019

shippedProposals makes no sense for core-js@3. corejs.proposals injects all built-ins proposals on usage.

@leomp12

This comment has been minimized.

Copy link
Author

@leomp12 leomp12 commented Dec 17, 2019

Got it, thanks @zloirock .
So I will keep the import 'core-js/modules/es.promise.all-settled' in source code for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.