fix: Correctly zip local (and aliased) packages #1685
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.
Overview
I've fixed handling of local (and aliased) packages when building the zip.
Before this fix it was not possible to include local dependencies in the sources zip, which for example can often happen in monorepos.
Testing
I've added a test case that tests the new behavior, and I've also tested this with a combination of scoped and unscoped packages.
Notes
should download local packages and produce a valid build when zipping sourcestest case is basically just a copy/paste of the existingshould download packages and produce a valid build when zipping sourcestest, the only difference being the local dependencies. It might be nicer to just include the local dependencies in the original test case?e2e/tests/__fixtures__/local-package. I originally wanted to create it withproject.addFile('local/package.json'), butpnpm.listDependenciescould not parse the output with the nested dependencies. This could be fixed by removing the-roption, but it was explicitly added in fix(zip): List all private packages correctly in a PNPM workspace #520, so I opted to store the local package outside of the extension directory.downloadDependencyneeds to be able to resolve relative dependencies, so I've added a newcwdoption similar to the one inlistDependenciesfile:(usual default for local dependencies) andlink:(whatpnpmresolvesworkspace:to),pnpmcreates an alias for one of them.downloadPrivatePackagesdid not create valid overrides for aliased packages, so I had to fix this too.npm-package-argfor parsing the package ids than using regex. Edit:npm-package-argdoesn't support parsing aliases.