prevent setAssets from modifying original externals array #450
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.
When using this plugin with wds and hot reloading, we noticed that as we reloaded, we'd receive an increasing number of warnings from the plugin with every reload. There'd be no warnings at first, then the first reload, there'd be one warning about how we should put a resource into externals, then a second reload there'd be warnings about all of our external resources.
I tracked it down to
setAssets
, which is being modified as it checks the externals to ensure they're defined. However, that means that multiple entries into this function destroy the original array, and produce these warnings. During the initial build, we'd have our array full; first reload, we'd have it slightly empty; second reload and forward, the externals array would be empty.The change here seems like the simplest fix to the problem, and I don't believe should introduce any unexpected issues. I've confirmed that it does resolve the problem on our end.