Description
While looking into discrepancies between local builds of https://github.com/WordPress/wordpress-develop/ and the corresponding commit on https://github.com/wordPress/wordpress, I noticed that there were unexplained changes to the hash values calculated based on the contents of the corresponding files.
It seems that when wp-build compiles files, it's including the absolute path of the file in the // wasm-inline: comment, which will vary based on OS and location of the repository within the filesystem when the build script is run. The hash is then generated from the full contents of the file, including the path noted within the inline comment. This makes each build non-reproducible.
Non-reproducible builds can result in unnecessary code churn and inconsistent build script results, which makes it difficult to validate build tool-related changes do not have unexpected outcomes.
Step-by-step reproduction instructions
You can reproduce the problem with the following steps:
- Clone gutenberg twice into two different paths (ie.
gutenberg-one, gutenberg-two.
- Run
npm install && npm run build in both.
- Run the following commands:
git diff --no-index \
/path/to/repo/gutenberg-a/build/modules/vips/worker.min.js \
/path/to/repo/gutenberg-b/build/modules/vips/worker.min.js
git diff --no-index \
/path/to/repo/gutenberg-a/build/modules/vips/worker.min.asset.php \
/path/to/repo/gutenberg-b/build/modules/vips/worker.min.asset.php
Notice the differences in build output despite source files being exactly the same. Note: git diff --no-index /path/to/gutenberg-one/build /path/to/gutenberg-two/build will also work. But there will be many more files without including the fix from #76098.
Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.
Description
While looking into discrepancies between local builds of https://github.com/WordPress/wordpress-develop/ and the corresponding commit on https://github.com/wordPress/wordpress, I noticed that there were unexplained changes to the hash values calculated based on the contents of the corresponding files.
It seems that when
wp-buildcompiles files, it's including the absolute path of the file in the// wasm-inline:comment, which will vary based on OS and location of the repository within the filesystem when the build script is run. The hash is then generated from the full contents of the file, including the path noted within the inline comment. This makes each build non-reproducible.Non-reproducible builds can result in unnecessary code churn and inconsistent build script results, which makes it difficult to validate build tool-related changes do not have unexpected outcomes.
Step-by-step reproduction instructions
You can reproduce the problem with the following steps:
gutenberg-one,gutenberg-two.npm install && npm run buildin both.Notice the differences in build output despite source files being exactly the same. Note:
git diff --no-index /path/to/gutenberg-one/build /path/to/gutenberg-two/buildwill also work. But there will be many more files without including the fix from #76098.Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.