✨ improve(patch): prevent duplicate entrypoint imports #2451
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.
Prevent duplicate entrypoint imports.
It is relatively easy to reproduce this. Just add a duplicate module to an entrypoint:
Before compilation, bud.js validates the configuration using webpack's validation API. At this point the following error is observed:
Initially, I thought about tightening the bud.entry parameter validation to prevent this, but that could cause ecosystem problems. For example, if multiple extensions add the same module to an entrypoint.
It would be possible to force extensions to check the imports array before adding a module, but this is more prone to error and doesn't confer any advantages. Since there is no scenario where a module would be intentionally included more than once it is better, I think, to dedupe each entrypoint's imports before compilation, which is what this PR does.
The solution is simple:
Type of change
PATCH: backwards compatible change