Skip to content

Vue config Externals Array Syntax does not work #4413

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

Closed
johannes-z opened this issue Aug 8, 2019 · 3 comments · Fixed by #4429
Closed

Vue config Externals Array Syntax does not work #4413

johannes-z opened this issue Aug 8, 2019 · 3 comments · Fixed by #4429

Comments

@johannes-z
Copy link

Version

4.0.0-alpha.5

Environment info

System:
    OS: Windows 10
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
  Binaries:
    Node: 11.13.0
    Yarn: 1.16.0
    npm: 6.7.0
  Browsers:
    Edge: 44.18362.1.0
  npmGlobalPackages:
    @vue/cli: Not Found

Steps to reproduce

Using a vue.config.js like this:

module.exports = {
  chainWebpack: config => {
    config.externals([
      /@namespace/,
      {
        'jquery': 'jquery',
        'test': 'test',
      },
    ])
  },
}

What is expected?

All the config.externals should be externalized.

What is actually happening?

None of the libraries are externalized, because vue-cli (?) changes the externals to:

{ '0': /@namespace/,
  '1': { jquery: 'jquery', test: 'test' },
  vue: { commonjs: 'vue', commonjs2: 'vue', root: 'Vue' } }

This causes the node_modules\webpack\lib\ExternalModuleFactoryPlugin.jsto ignore the externals.


I'm not sure if this is caused by the cli or by webpack-chain, but since vue-cli is adding the vue property to the object, I'm guessing that it's vue-cli's doing.

@haoqunjiang
Copy link
Member

Thanks for submitting this issue! Due to our limited time, we ask you to include a reproduction link to a minimal full reproduction of your problem (for example in a GitHub repository) so we can find what is causing the issue. Thank you for your understanding!

@haoqunjiang haoqunjiang added the needs reproduction This issue is missing a minimal runnable reproduction, provided by the author label Aug 8, 2019
@johannes-z
Copy link
Author

@sodatea Sure, here's the repro: https://github.com/johannes-z/vue-cli-externals
Just npm install and npm run build. The test.umd-report.html shows that the external dependencies are still added to the bundle.

@haoqunjiang haoqunjiang added bug and removed needs reproduction This issue is missing a minimal runnable reproduction, provided by the author labels Aug 9, 2019
haoqunjiang added a commit to haoqunjiang/vue-cli that referenced this issue Aug 13, 2019
haoqunjiang added a commit that referenced this issue Aug 21, 2019
@johannes-z
Copy link
Author

johannes-z commented Aug 30, 2019

@sodatea Hi, are you sure this is resolved? I just updated the RC0 and it has wrong externals: Nevermind, forgot to update vue-cli-service.

λ vue -V
4.0.0-rc.0

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