Skip to content

fix(generator): add core-js as direct dependency of generated projects #3736

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

Merged
merged 1 commit into from
Mar 31, 2019

Conversation

haoqunjiang
Copy link
Member

No description provided.

@haoqunjiang haoqunjiang merged commit 5eb1425 into vuejs:dev Mar 31, 2019
@cyrilf
Copy link

cyrilf commented May 12, 2019

Hey @sodatea,

Could you explain me what is this change doing?
I'm a bit confused if I have to keep core-js as a dependency of my project or if I could move it to the dev-dependencies (or get rid of it all in all).

Thanks for your time! ✌️

@haoqunjiang
Copy link
Member Author

@cyrilf
If you are using babel to transpile your code, babel may add some polyfill imports to the transpiled code for it to function correctly.
E.g.

const a = new Map()

will be transpiled into

import "core-js/modules/es6.map";
var a = new Map();

as map is not natively supported in IE9.

So technically speaking the core-js package is a dependency of your project.

In the past we utilized the package hoisting feature of npm and hide it behind @vue/cli-plugin-babel.
But after core-js 3 came out:

  1. the internal directory structure of core-js changed a lot, we need to make sure users only get the correct version of core-js so as not to break their app
  2. other packages in the project's dependency chain may have already depended on core-js@3, so we can't be sure if the root level core-js dependency is of the right version (as npm package hoisting is non-deterministic) without explicitly listing it in package.json.

To conclude:
you should keep it as a dependency.

@cyrilf
Copy link

cyrilf commented May 12, 2019

Got it! 👍
Thanks a lot for this clear and explicit explanation. 👌

@zWingz
Copy link

zWingz commented Oct 12, 2019

Thanks for explanation @sodatea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants