feat: Add option to strip workspace:
protocol from dependencies in zipped sources
#1689
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
This adds a new option
zip.stripWorkspaceProtocol
to strip theworkspace:
protocol from dependencies when zipping the sources. All package managers exceptnpm
do this when publishing packages1, and since creating the zip is a form of publishing,wxt
should do the same.This is an option defaulting to false, as some people zip monorepos using
sourcesRoot: '../..',
or similar, where theworkspace:
protocol should be kept.Note that this only strips the prefix for now (so
workspace:*
becomes*
, instead of replacing*
,^
and~
with the version defined in the workspace like the package managers do.Manual Testing
Create a new extension in a monorepo depending on a workspace dependency, and then create the zip using
wxt zip -b firefox
. Check the generatedpackage.json
in the sources.zip.I was sadly not able to write a e2e test for this, as all the tests run with
--ignore-workspace
added at various points. Maybe the e2e tests could be improved to create the projects in a path outside thewxt
repo (maybe/tmp/wxt-e2e/<id>
, instead ofe2e/dist/<id>
, so scenarios using workspace could be tested.Related PRs
Footnotes
Here is the documentation of the different package managers on how they handle
workspace:
: pnpm / yarn / deno / bun ↩