-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Getting different hashes when running build on the same files #13071
Comments
Looking through some older issues on Rollup, this person was able to have a reproduceable build showing different hashes: This was apparently addressed in Rollup 3 by changing how the reference IDs are set. But I came across this issue which says that Vite uses a different scheme, at least until Vite 5. rollup/rollup#4713 Could this potentially be why the builds are non-deterministic? |
I upgraded from 4.2.0 -> 4.3.4 and it's no longer creating different hashes. Not sure what changed in between. |
Upon further investigation I've determined the difference between the two versions was the CDN in the import function:
We are using vite_ruby + vite_rails so this might be better asked in that repo. But for some reason it wasn't always using the CDN part. I'm not sure how this is inserted by Vite... |
FWIW we had fixed a similar issue (#11911) in Vite 4.3.0, where the CSS build has a race condition if you have multiple CSS with the same content, causing the hash to be non-deterministic. From what you've found so far, it doesn't seem to be the same issue. If you believe it's still a Vite issue though, please provide a repro so we can debug it. |
@bluwy I have encountered the same issue as well and have provided a reproducible example. https://github.com/ttionya/vite-non-deterministic-build-repro |
I have written a plugin that prints all the parameters in the transform hook. During two consecutive builds, although the order of their outputs is different, I found that there is only one instance where the content of the output differs after adjusting the order. plugins: [
function() {
return {
name: 'test',
transform: (...args) => {
console.log(args)
}
}
}()
] I have removed a significant amount of irrelevant code, so the hash of the artifact is different from the one in the repro. First build: [
'export { __moduleExports as default } from "C:/Users/admin/Projects/My/vite-non-deterministic-build-repro/node_modules/dayjs/dayjs.min.js";',
'\x00C:/Users/admin/Projects/My/vite-non-deterministic-build-repro/node_modules/dayjs/dayjs.min.js?commonjs-proxy'
]
�[2mdist/�[22m�[36massets/index-e2988d1d.js �[39m�[1m�[2m 1.10 kB�[22m�[1m�[22m�[2m │ gzip: 0.63 kB�[22m
�[2mdist/�[22m�[36massets/vendor-3bedaa96.js �[39m�[1m�[2m81.22 kB�[22m�[1m�[22m�[2m │ gzip: 32.73 kB�[22m
�[32m✓ built in 1.97s�[39m Second build: [
'import { getDefaultExportFromCjs } from "\x00commonjsHelpers.js";\n' +
'import { __require as requireDayjs_min } from "C:/Users/admin/Projects/My/vite-non-deterministic-build-repro/node_modules/dayjs/dayjs.min.js";\n' +
'var dayjs_minExports = requireDayjs_min();\n' +
'export { dayjs_minExports as __moduleExports };export default /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);',
'\x00C:/Users/admin/Projects/My/vite-non-deterministic-build-repro/node_modules/dayjs/dayjs.min.js?commonjs-es-import'
]
�[2mdist/�[22m�[36massets/index-73275ff8.js �[39m�[1m�[2m 1.10 kB�[22m�[1m�[22m�[2m │ gzip: 0.63 kB�[22m
�[2mdist/�[22m�[36massets/vendor-2f895bab.js �[39m�[1m�[2m81.26 kB�[22m�[1m�[22m�[2m │ gzip: 32.75 kB�[22m
�[32m✓ built in 2.97s�[39m Should we continue the discussion under this issue or open a new one? |
We have the same issue, if this can help here an example of two different output for index.js
|
always build different content with core-js module: |
After investgate, I found this is cause by babel-runtime of ant design vue, our project use @babel/runtime and babel-runtime the same time. My resolution is to alias the babel-runtime to @babel/runtime like:
|
Facing the same issue! waiting for a fix. |
Going to close this as it seems like it's a Vite Ruby issue. Otherwise for non-deterministic builds with CJS deps, it's tracked at #13672 |
Describe the bug
We're trying to deploy an upgrade from Vite 2.9 -> 4 and we're having a problem where 2 servers are getting different hashes.
I reproduced this locally, just by running build, I've run it about 30 times in a row and it always outputs one of two files:
The diff between the two outputted files:
Any ideas on where this difference is being introduced?
Note: This is on my work production system with hundreds of files so it would be difficult to share a reproduceable build here. If that is 100% necessary I can delete this issue.
System Info
Vite configs:
https://gist.github.com/dmix/4059efd362348c6654ea29a111bdd081
Used Package Manager
yarn
Logs
Output showing two different hashes after running it only twice:
https://gist.github.com/dmix/3b6aa74e667c0cc13f137f182a53b2d5
Validations
The text was updated successfully, but these errors were encountered: