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

core-js and core-js-pure import duplication #4742

Closed
MartinManev opened this issue Oct 22, 2019 · 1 comment · Fixed by #4777
Closed

core-js and core-js-pure import duplication #4742

MartinManev opened this issue Oct 22, 2019 · 1 comment · Fixed by #4777

Comments

@MartinManev
Copy link

Version

4.0.4

Environment info

Environment Info:

  System:
    OS: Linux 4.9 Debian GNU/Linux 9 (stretch) 9 (stretch)
    CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
  Binaries:
    Node: 10.16.3 - /usr/bin/node
    Yarn: Not Found
    npm: 6.12.0 - /usr/bin/npm
  Browsers:
    Chrome: 77.0.3865.90
    Firefox: 60.8.0
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0 
    @vue/babel-plugin-transform-vue-jsx:  1.0.0 
    @vue/babel-preset-app:  4.0.2 
    @vue/babel-preset-jsx:  1.1.1 
    @vue/babel-sugar-functional-vue:  1.0.0 
    @vue/babel-sugar-inject-h:  1.0.0 
    @vue/babel-sugar-v-model:  1.1.1 
    @vue/babel-sugar-v-on:  1.1.0 
    @vue/cli-overlay:  4.0.2 
    @vue/cli-plugin-babel: ^4.0.0 => 4.0.2 
    @vue/cli-plugin-router: ^4.0.0 => 4.0.2 
    @vue/cli-plugin-vuex: ^4.0.0 => 4.0.2 
    @vue/cli-service: ^4.0.0 => 4.0.2 
    @vue/cli-shared-utils:  4.0.2 
    @vue/component-compiler-utils:  3.0.0 
    @vue/preload-webpack-plugin:  1.1.1 
    @vue/web-component-wrapper:  1.2.0 
    vue: ^2.6.10 => 2.6.10 
    vue-hot-reload-api:  2.3.4 
    vue-loader:  15.7.1 
    vue-router: ^3.0.6 => 3.1.3 
    vue-style-loader:  4.1.2 
    vue-template-compiler: ^2.6.10 => 2.6.10 
    vue-template-es2015-compiler:  1.9.1 
    vuex: ^3.0.1 => 3.1.1 
  npmGlobalPackages:
    @vue/cli: 4.0.4

Steps to reproduce

Create a brand new project with Vue CLI 4.

Install webpack-bundle-analyzer and build. Only core-js is included in the bundle.

Open src/main.js and add the following to the Vue instance:

methods: {
  myfunc: async function () {},
},

Build with webpack-bundle-analyzer again. Now both core-js and core-js-pure are imported and there are a lot of duplicated imports between them.

What is expected?

Do not duplicate imports from core-js and core-js-pure.

What is actually happening?

The same imports are duplicated between core-js and core-js-pure.


Is this actually a bug or is it intended? I'm reporting it as a bug since it doesn't seem normal to me and I didn't have such problems with Vue CLI 3. I'd be happy if someone explained the reasoning behind this.

Screenshot from 2019-10-22 12-02-20

@haoqunjiang
Copy link
Member

haoqunjiang commented Oct 22, 2019

Seems a bug in @vue/babel-preset-app.

I don't have the time to fully investigate this problem today, but here are a few references to read about our approach:

If anyone comes up with a solution, a pull request would be much appreciated.

haoqunjiang added a commit to haoqunjiang/vue-cli that referenced this issue Oct 30, 2019
As recommended in babel/babel#9903.
Get rid of the module-resolver plugin, may fix vuejs#3928.
Seems to have fixed vuejs#4742 as well.
haoqunjiang added a commit that referenced this issue Nov 4, 2019
* refactor: use babel overrides to transpile babel runtime helpers

As recommended in babel/babel#9903.
Get rid of the module-resolver plugin, may fix #3928.
Seems to have fixed #4742 as well.

There may be a small breaking change: as we now use `excludes` & `includes`, babel requires `filename` option to be present (introduced in https://github.com/babel/babel/pull/10181/files). So users who call `babel.transformSync` directly may encounter an error.

However, as we explicitly stated that this preset is only used for Vue CLI internally, I don't expect too many such use cases there. And the error messages are clear enough.
Considering the benefits that this PR brings, I think it's an acceptable tradeoff.


 test: update tests for babel

* test: fix windows tests

* test: remove unused variables

* fix: fix scope package paths on Windows

* test: wait some time in router tests in case dom hasn't updated in time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants