esbuild output with `preserveSymlinks = false` contains machine-specific relative paths
Originally reported in https://github.com/aspect-build/rules_esbuild/pull/32#issuecomment-1193356744:
Another problem with
preserveSymlinks = falsefor our needs in Bazel is that ESBuild leaves comments in the output that contain resolved file paths. WithpreserveSymlinks = falsethese can refer to paths like.../home/matt/.cache/bazel_matt/.../.../...which, across different users and checkouts, will generate downstream cache misses on actions that depend on the outputs.
At Figma we encountered this issue with a write_source_files target that writes an esbuild bundle. The associated diff_test fails with rules_esbuild 0.12+ because the generated relative path differs between local development and CI.
Related to #58.
As a workaround, you could write another rule after the esbuild to sanitize paths in the file before passing it to write_source_files