element-plus / element-plus

🎉 A Vue.js 3 UI Library made by Element team
https://element-plus.org
MIT License
24.69k stars 16.87k forks source link

[Build] [image] rollup build后生成文件名具有随机性,相同代码build多次,结果不同 #19013

Open zwc-real opened 6 days ago

zwc-real commented 6 days ago

Bug Type: Build

Environment

Reproduction

Related Component

Reproduction Link

Github Repo

Steps to reproduce

pnpm install

pnpm build

What is Expected?

element-plus/packages/components/image/src/image.ts编译为dist/element-plus/es/components/image/src/image.mjs

element-plus/packages/components/image/src/image.vue编译为dist/element-plus/es/components/image/src/image2.mjs

与官方提供的npm下载包一致

What is actually happening?

image.vue和image.ts文件,会随机编译成image.mjs和image2.mjs。代码相同的情况下,每次编译生成的产物会不同,具有不确定性

Additional comments

(empty)

zwc-real commented 4 days ago

https://github.com/element-plus/element-plus/blob/990aa4b768619d4a57cc17d21f5fc85c4a420c21/internal/build/src/tasks/modules.ts#L17-L23

由于rollup build是多线程的,element-plus中出现了较多同目录下相同名称不同后缀名的文件,且保持了原有目录结构、文件名未添加hash指纹,所以build产生的文件名会根据build完成的先后顺序随机变化。 为了保持构建后文件名以及内容对应的相对稳定,建议根据不同后缀名分批次按顺序构建。