element-plus / element-plus-icons

Main package for storing Element Plus icon resources.
MIT License
138 stars 100 forks source link

@element-plus/icons-vue包无法被vite treeshake #44

Closed nhpupu closed 2 years ago

nhpupu commented 2 years ago

在npm中的@element-plus/icons-vue包无法被vite treeshake。打包后,会把全部icon都打入包中。

反而是被标为deprecated的@element-plus/icons包可以被treeshake。

版本

复现

直接从node_modules中的文件就能看出区别。

  1. pnpm create vite创建一个vite vue-ts项目
  2. 进入目录
  3. pnpm i @element-plus/icons @element-plus/icons-vue
  4. 找个地方使用icon(要实际使用,只import的话会被整个treeshake)
  5. pnpm build

可以发现从不同的包引用icon时,输出文件的大小有区别(53KB vs 255KB)。 输出文件中http://www.w3.org/2000/svg字符串的出现数目也能说明问题。

sxzz commented 2 years ago

请尝试使用最新版本

nhpupu commented 2 years ago

确认在@element-plus/icons-vue@2.0.4中问题已修复