rules_nodejs
rules_nodejs copied to clipboard
Feature request: support entryNames property in esbuild
🚀 feature request
Relevant Rules
esbuild
Description
If you build with an esbuild config, you can set the entryNames
option, per the docs. This option is particularly useful for including the hash in the filename of the generated bundle, and thereby enabling a far-future expiration date on the JS bundle. Without it, the cache headers need to be set to invalidate the file immediately, lest the bundle is updated but the previously cached version served by the HTTP cache.
However, all that said the esbuild rule does not know that the entryNames
option has been set, and Bazel goes looking for the declared output JS (and sourcemap file), i.e., it goes looking for foo.js
rather than – say – foo-abcde123.js
, and the build fails.
Describe the solution you'd like
Ideally the esbuild rule would support hashing in the entry point filenames akin to the way it accepts the chunk outputs from esbuild today. I presume, therefore, the esbuild rule would need an extra arg that maps to a predefined entryNames
arg in esbuild
.
Describe alternatives you've considered
An alternative would be a separate build step to hash the JS after esbuild has output it, but it seems a shame when esbuild supports it directly.
Update: it looks to work if the splitting
is set to True
in the esbuild rule, I guess because the expected output is a directory rather than an individual file. Not sure, then, if it needs an extra arg or not!
This issue has been automatically marked as stale because it has not had any activity for 6 months. It will be closed if no further activity occurs in 30 days. Collaborators can add a "cleanup" or "need: discussion" label to keep it open indefinitely. Thanks for your contributions to rules_nodejs!
This issue was automatically closed because it went 30 days without any activity since it was labeled "Can Close?"
Hey sorry @paullewis I assume you've switched to aspect_rules_esbuild by now?
I have indeed, yes 😄