You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Forgive me in advance if I am missing something obvious here, but shouldn't the hashes generated by adding a [hash] inside the template value for entryNames be based on the contents of the output file itself?
As expected, running this would produce a foo.KRQXUUXA.css file inside a newly created out directory. So far so good. But consider changing the template a little bit:
constesbuild=require('esbuild');esbuild.build({entryPoints: ['style.css'],entryNames: 'bar.[hash]',// <= foo becomes bar hereoutdir: 'out',logLevel: 'info'});
This produces a the absolute same file, but named differently - bar.HKT67FGH.css. You can even change the template of entryNames to entryNames: '[dir]/bar.[hash]' and it will once again produce another file with a different hash. Why is that?
I am using "esbuild": "^0.14.5" on Ubuntu 20.04 if that is of any importance.
Thanks in advance!
The text was updated successfully, but these errors were encountered:
barca-reddit
changed the title
Changing the entryNames placeholder value generates a different (inconsistent) hashes.
Changing the entryNames placeholder value generates different (inconsistent) hashes.
Dec 16, 2021
shouldn't the hashes generated by adding a [hash] inside the template value for entryNames be based on the contents of the output file itself?
No. Using the contents of the output file for the hash is incorrect, and causes bugs like this: #928. In JavaScript, two input files with the same contents are not considered the same file by the runtime. Loading both of them will load the module twice, not once, and the functions and objects in each file have their own object identity. The hash needs to take into account the file path too because it needs to respect JavaScript's semantics.
If this is something unique to esbuild, perhaps consider adding a quick paragraph about it in the docs, because I think when most people hear the word hash, they imagine it relates to the file contents alone, so a quick disclaimer about it would be really nice to avoid potential confusion in the future.
I could be wrong about either of those things, but at least that's how I imagined this works. But in any case this is not a big issue so thanks for the quick response and thanks for building this amazing tool!
Hello.
Forgive me in advance if I am missing something obvious here, but shouldn't the hashes generated by adding a
[hash]
inside the template value forentryNames
be based on the contents of the output file itself?Consider the following super simple example:
style.css
esbuild.js
As expected, running this would produce a
foo.KRQXUUXA.css
file inside a newly createdout
directory. So far so good. But consider changing the template a little bit:This produces a the absolute same file, but named differently -
bar.HKT67FGH.css
. You can even change the template ofentryNames
toentryNames: '[dir]/bar.[hash]'
and it will once again produce another file with a different hash. Why is that?I am using
"esbuild": "^0.14.5"
onUbuntu 20.04
if that is of any importance.Thanks in advance!
The text was updated successfully, but these errors were encountered: