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

vite打包会引入未使用的组件,该组件使用defineComponent包裹 #7020

Closed
7 tasks done
luoyi58624 opened this issue Feb 21, 2022 · 1 comment · Fixed by #10205
Closed
7 tasks done

vite打包会引入未使用的组件,该组件使用defineComponent包裹 #7020

luoyi58624 opened this issue Feb 21, 2022 · 1 comment · Fixed by #10205
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)

Comments

@luoyi58624
Copy link

Describe the bug

1.这是使用vite库模式打包出来的es代码,分别导出一个简单组件和函数
image
2.然后app.vue使用hello函数
image
3.最后打包
image

tip:若删除defineComponent,vite则不会将该组件打包进来!

Reproduction

https://gitee.com/luoyi666/vite-tsx-lib

System Info

System:
    OS: Windows 10 10.0.22000
    CPU: (16) x64 AMD Ryzen 7 5800H with Radeon Graphics
    Memory: 2.55 GB / 15.86 GB
  Binaries:
    Node: 16.13.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.3.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (98.0.1108.56)
    Internet Explorer: 11.0.22000.120
  npmPackages:
    @vitejs/plugin-vue: ^2.2.0 => 2.2.2
    @vitejs/plugin-vue-jsx: ^1.3.7 => 1.3.7
    vite: ^2.8.0 => 2.8.4

Used Package Manager

pnpm

Logs

No response

Validations

@869288142
Copy link

@luoyi58624

add /*#__pure__*/ annotation to defineComponent, it work.

@vitejs/plugin-vue-jsx only transform jsx. may be it can automatically
add /*#__pure__*/ to jsx or tsx ?

image

@haoqunjiang haoqunjiang added plugin: vue p2-nice-to-have Not breaking anything but nice to have (priority) and removed pending triage labels Apr 20, 2022
@sapphi-red sapphi-red linked a pull request Sep 23, 2022 that will close this issue
9 tasks
@github-actions github-actions bot locked and limited conversation to collaborators Nov 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants