fix: Correctly zip local (and aliased) packages#1685
fix: Correctly zip local (and aliased) packages#1685darthmaim wants to merge 2 commits intowxt-dev:mainfrom
Conversation
❌ Deploy Preview for creative-fairy-df92c4 failed.
|
8038445 to
961f783
Compare
961f783 to
4e52907
Compare
|
I did some more tests today, and while this does fix the handling of The generated package.json will look like this: "dependencies": {
"@local/dependency": "workspace:*",
},
"resolutions": {
"@local/dependency@link:../../packages/dependency": "file://./.wxt/local_modules/local-dependency-0.0.1.tgz"
}Trying to install this with I'll look into adding special handling for Maybe downloaded "dependencies": {
"@local/dependency": "file://./.wxt/local_modules/local-dependency-0.0.1.tgz",
} |
|
@darthmaim Are you have a plan to go on with that? |
|
@darthmaim One more poke :) |
|
I'll try to take a look at this next weekend, I honestly don't remember much of what I was doing in this PR 😅 |
|
@darthmaim No problem, we'll try to be more active from now 😄 |
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.