Feat(bundling): generate predictable filenames for bundles
Closed this issue · 4 comments
Which problem is this feature request solving?
I'm working netlify/cli#1236 on and need to read both the bundle file and manifest file from the .netlify/edge-handlers directory.
The manifest file has a predictable name manifest.json, but bundles have a hash as the filename.
Moreover, old bundles are not deleted between build commands and a new bundle is generated even if the code remains the same:

To reproduce:
- Set up a project with an
edge-handlersdirectory. - Run
netlify buildmultiple times (with CLI version>=v2.63.2) - See that each time a new bundle is created.
Describe the solution you'd like
We can keep the current behaviour and also save the latest bundle as latest or bundle.
Also, not sure why the hash changes if the code remains the same, but that is less of an issue (the main issue here is creating redundant files on users machines).
I believe the code responsible for that is here:
netlify-plugin-edge-handlers/src/index.js
Line 37 in 9657a5a
Describe alternatives you've considered
I can look at the creation date of files and use the most recent one.
Can you submit a pull request?
Yes, I believe we can update the code here to write bundle with a predictable name:
netlify-plugin-edge-handlers/src/index.js
Line 144 in 9657a5a
Update
As @ehmicky pointed out, I can read the manifest.json file and then use the sha property to determine the last bundle.
we can totally think about using a fixed name for handler bundles. i'd like to change that once we're tackling local serving of edge handlers and watching for changes / reloads
Done!