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

Do we need both of core-js and core-js-pure in the bundle? #848

Closed
intelcoder opened this issue Jul 24, 2020 · 3 comments
Closed

Do we need both of core-js and core-js-pure in the bundle? #848

intelcoder opened this issue Jul 24, 2020 · 3 comments
Labels

Comments

@intelcoder
Copy link

intelcoder commented Jul 24, 2020

I am using core-js to support IE11 mainly for promise and generator(Saga)
In my bundle I see core-js and core-js-pure. Do we need both of them?

Screen Shot 2020-07-23 at 9 24 27 AM

I have some setup on babelrc.

["@babel/preset-env", {
      "useBuiltIns": "usage",
      "corejs": 3,
      "targets": {
        "ie": "11"
      }
}]

["@babel/transform-runtime", {
      "corejs": 3
}],
index.js

I have this code on my root for clientside
import 'core-js/stable'
import 'regenerator-runtime/runtime'

@zloirock
Copy link
Owner

No. It's 3 different ways of core-js usage. You should use only one of them:

  • core-js direct import
  • core-js injecting by usage plugin from @babel/preset-env
  • core-js injecting without global pollution by @babel/transform-runtime plugin

@perqa
Copy link

perqa commented Dec 7, 2021

What if I include a library which uses core-js-pure into my app which only uses core-js by direct import? I guess it is inevitable then to get both core-js-pure and core-js in the bundle?

@zloirock
Copy link
Owner

zloirock commented Dec 7, 2021

@perqa yes. Now, since core-js and core-js-pure have the same commonjs API structure, you can try to configure webpack aliases or something similar, but it can be dangerous. However, I'm planning to add a way to avoid this duplication properly. This issue is tracked in #833.

ndepaola added a commit to ndepaola/CubeCobra that referenced this issue Oct 22, 2023
seems a bit weird to me that we need to pin this dependency twice.
there's some discussion on this here:
zloirock/core-js#848
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants