rules_nodejs icon indicating copy to clipboard operation
rules_nodejs copied to clipboard

Feature request: support entryNames property in esbuild

Open paullewis opened this issue 2 years ago • 1 comments

🚀 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.

paullewis avatar May 26 '22 13:05 paullewis

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!

paullewis avatar May 26 '22 13:05 paullewis

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!

github-actions[bot] avatar Nov 26 '22 02:11 github-actions[bot]

This issue was automatically closed because it went 30 days without any activity since it was labeled "Can Close?"

github-actions[bot] avatar Dec 27 '22 02:12 github-actions[bot]

Hey sorry @paullewis I assume you've switched to aspect_rules_esbuild by now?

alexeagle avatar Dec 27 '22 16:12 alexeagle

I have indeed, yes 😄

paullewis avatar Dec 28 '22 11:12 paullewis