Skip to content

cli build web-component too syntax/cli构建的web-component一部分文件语法过高 #3683

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
wszgrcy opened this issue Mar 20, 2019 · 1 comment

Comments

@wszgrcy
Copy link

wszgrcy commented Mar 20, 2019

Version

3.5.0

Reproduction link

https://github.com/wszgrcy/vue-web-component

Environment info

Environment Info:

  System:
    OS: Windows 10
    CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
  Binaries:
    Node: 10.13.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.15.2 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 42.17134.1.0
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0-beta.2
    @vue/babel-plugin-transform-vue-jsx:  1.0.0-beta.2
    @vue/babel-preset-app:  3.5.1
    @vue/babel-preset-jsx:  1.0.0-beta.2
    @vue/babel-sugar-functional-vue:  1.0.0-beta.2
    @vue/babel-sugar-inject-h:  1.0.0-beta.2
    @vue/babel-sugar-v-model:  1.0.0-beta.2
    @vue/babel-sugar-v-on:  1.0.0-beta.2
    @vue/cli-overlay:  3.5.1
    @vue/cli-plugin-babel: ^3.5.0 => 3.5.1
    @vue/cli-plugin-typescript: ^3.5.0 => 3.5.1
    @vue/cli-service: ^3.5.0 => 3.5.1
    @vue/cli-shared-utils:  3.5.1
    @vue/component-compiler-utils:  2.6.0
    @vue/preload-webpack-plugin:  1.1.0
    @vue/web-component-wrapper:  1.2.0
    typescript: ^3.2.1 => 3.3.3333
    vue: ^2.6.6 => 2.6.9
    vue-class-component: ^6.0.0 => 6.3.2
    vue-hot-reload-api:  2.3.3
    vue-loader:  15.7.0
    vue-property-decorator: ^7.0.0 => 7.3.0
    vue-style-loader:  4.1.2
    vue-template-compiler: ^2.5.21 => 2.6.9
    vue-template-es2015-compiler:  1.9.1
  npmGlobalPackages:
    @vue/cli: Not Found

Steps to reproduce

问题说明

  • 安装后运行npm run wc
  • 其中App.vue中20行处的箭头函数代码,在导出文件dist/custom-vue.js已经转换为普通函数
  • 但是这个文件的374行左右查找const hyphenate会发现一些依赖命令自动导入的一些文件,没有转换语法
  • 按理说,同样的配置,那么既然自己写的代码能进行转换语法,由cli引入的文件,同样应该可以
  • 没有主动设置忽略哪些文件,不知道是我的配置问题还是说生成的时候确实有些文件是noParse的

What is expected?

转换规则配置文件应该对于引入文件同样适应,而不应该被处于默认不解析

What is actually happening?

自动引入的依赖文件没有被转化语法


  • 不知道是不是这个原因,因为不支持web-component的,一定会不支持箭头函数特性,所以就算转换低语法,也同样不能引入
  • 但是web-component有一些polyfill可以使一些低版本浏览器也能运行,这时一些函数就必须转换了.
  • 昨天通过实验,手动将导出文件的custom-vue.js用Babel再次转换,然后加入polyfill测试是可以跑在ie11这样的原生不支持web-component的浏览器上的,但是之前由于导出文件的部分导入文件没有转换,使得启动失败
@haoqunjiang
Copy link
Member

It is intentional.

https://github.com/vuejs/vue-web-component-wrapper/

  • If targeting browsers that does not support ES2015:

    You might want to reconsider since you'll be better off not using Web Components in this case.

Also see vuejs/vue-web-component-wrapper#32 (comment)
And here's a workaround vuejs/vue-web-component-wrapper#31 (comment)

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

No branches or pull requests

2 participants