This repository was archived by the owner on May 2, 2022. It is now read-only.
Make bundle filename consistent #66
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #50.
At the moment, the filename of a bundle is always different each time bundling is performed, even if the Edge handlers source files have not changed. This might be a problem:
.netlify/edge-handlers/even when nothing has changedThe reason the bundle filename always changes is because each Edge handler is exported using a unique ID. That ID is part of the final bundle and is randomly generated.
This PR solves this problem by generating this unique ID by performing a SHA1 cheksum on the Edge handler filename instead.
If any Edge handler source file's contents changes, the bundle filename will still change since it is based not only on each generated ID, but also on a concatenation of all Edge handlers source files.
One side-effect this PR is that
idinnetlifyRegistry.set("handlerFilename", "id")will remain the same across builds if the handler filename has not changed. However, it is guaranteed to be unique within a specific build, since two Edge handlers cannot have the same filename (full file paths can also be used in the future). Please let me know if this is a problem with hownetlifyRegistryis implemented. I am guessing not but I want to confirm.