Empty packages as valid v2 addons #2012
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.
The issue was initially raised by #1931.
Problem
In tests relying on ember-data 4.4, the rewritten-packages contain multiple copies of @ember-data/store. Only one copy has content, the others are empty. The only copy having content is the only "active" package.
During the build process, we expect requests for the empty packages to resolve to the corresponding "active" package; but instead, they resolved to the empty copy, which triggered a build error.
Cause
This was because when the core module-resolver handles an empty package, it returns before the rehoming to the active package can happen. The condition that triggered the return was:
if (!pck.isV2Addon()) return /* ... */
: in other words, empty packages generated by theEmptyPackageTree
plugin are not valid v2 addons, causing the module-resolver to give an unexpected answer.Solution
This PR changes the
EmptyPackageTree
plugin to add more information in thepackage.json
of the empty package: it now has the keys that identify a package as a valid v2 package.Once the module-resolver recognizes an empty package as a valid v2 package, it continues the execution until it rehomes the request and resolve to the active package.