vuejs / vue-cli

🛠️ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.75k stars 6.33k forks source link

打包谷歌浏览器插件应用时,默认的es6.promise引用错误,如何取消默认引用 #3299

Closed imloama closed 5 years ago

imloama commented 5 years ago

Version

3.3.0

Reproduction link

https://github.com/imloama/fireflywallet-chrome

Environment info

  System:
    OS: macOS High Sierra 10.13.6
    CPU: (4) x64 Intel(R) Core(TM) i5-4200M CPU @ 2.50GHz
  Binaries:
    Node: 8.12.0 - /usr/local/bin/node
    Yarn: 1.10.1 - /usr/local/bin/yarn
    npm: 6.4.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 71.0.3578.98
    Firefox: Not Found
    Safari: 11.1.2
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0-beta.1
    @vue/babel-plugin-transform-vue-jsx:  1.0.0-beta.1
    @vue/babel-preset-app:  3.3.0
    @vue/babel-preset-jsx:  1.0.0-beta.1
    @vue/babel-sugar-functional-vue:  1.0.0-beta.1
    @vue/babel-sugar-inject-h:  1.0.0-beta.1
    @vue/babel-sugar-v-model:  1.0.0-beta.1
    @vue/babel-sugar-v-on:  1.0.0-beta.1
    @vue/cli-overlay:  3.3.0
    @vue/cli-plugin-babel: ^3.3.0 => 3.3.0
    @vue/cli-service: ^3.3.0 => 3.3.0
    @vue/cli-shared-utils:  3.3.0
    @vue/component-compiler-utils:  2.5.0
    @vue/preload-webpack-plugin:  1.1.0
    @vue/web-component-wrapper:  1.2.0
    babel-helper-vue-jsx-merge-props:  2.0.3
    babel-plugin-transform-vue-jsx:  4.0.1
    vue: ^2.5.21 => 2.5.21
    vue-awesome-swiper: >=2.6.7 => 3.1.3
    vue-clipboard2: ^0.2.1 => 0.2.1
    vue-hot-reload-api:  2.3.1
    vue-i18n: >=7.2.0 => 8.7.0
    vue-loader:  15.5.1
    vue-methods-promise: >=0.2.2 => 0.2.2
    vue-pull-refresh: >=0.2.6 => 0.2.7
    vue-qr: >=1.2.3 => 1.5.2
    vue-router: ^3.0.1 => 3.0.2
    vue-style-loader:  4.1.2
    vue-template-compiler: ^2.5.21 => 2.5.21
    vue-template-es2015-compiler:  1.7.0
    vue-toasted: >=1.1.21 => 1.1.26
    vuedraggable: >=2.16.0 => 2.17.0
    vuetify: >=1.0.0 => 1.4.1
    vuex: ^3.0.1 => 3.0.1
  npmGlobalPackages:
    @vue/cli: 3.3.0

Steps to reproduce

  1. 执行npm run build
  2. 谷歌浏览器的应用管理引用dist文件夹
  3. 打开新Tab后,查看界面出现错误,"Uncaught (in promise) abort({}).Build with -s ASSERTIONS=1 for more info."错误来自于引用的es6.promise
  4. 在babel.config.js中设置polyfills为空,不起作用。

What is expected?

取消强制引用的es6.promise

What is actually happening?

无法取消es6.promise

haoqunjiang commented 5 years ago

这个错误是从一个 Promise 中抛出来的,但不是 Promise polyfill 本身的错误,而是你引用的库的某个调用的问题。从网上查到的信息来看,这个应该是 Emscripten 编译的本地模块导致的,而且应该跟 Chrome extension 的 CSP 策略有关。 https://github.com/kripken/emscripten/issues/5911#issuecomment-366029402

imloama commented 5 years ago

谢谢 @sodatea

通过设置config.optimization.minimize(false),还原所有变量原始名称,确认是依赖的依赖中的js-nacl导致的,纯前台方式没问题,如果用chrome extension的形式打开,会出现错误,暂时未解决,不影响业务。