Support for declaring extensions as peer dependencies #11808
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.
What it does
Ensures that the ExtensionPackageCollector also correctly picks up packages that are declared as peer dependencies.
This change allows extension providers to declare their dependencies to Theia core extensions as peer dependencies. This can simplify version management and eliminates the need for yarn resolutions (or a similar feature) to ensure that only one version of Theia extensions is resolved.
This topics has already been discussed multiple times:
The question whether we actually want to change inter dependencies between Theia core packages to peer dependencies is still up for discussion.
Nevertheless, ensuring the the application builder also supports and correctly loads Theia extensions that are declared as peer dependencies is a good idea.
This is an opt-in feature that does not break any existing applications and gives third party extension providers the opportunity to use peer dependencies if they want to.
Contributed on behalf of STMicroelectronics
How to test
Can for instance be tested with the "@theia/api-samples" package by simply switching all dependencies to peerDependencies:
Building this change on master results in a corrupt application. I.e. the browser application no longer loads and the following error is logged:
![Screenshot from 2022-10-27 18-15-20](https://user-images.githubusercontent.com/2311075/198344022-2c93e262-e36d-48fe-964b-f858955dad0a.png)
In the generated frontend index.js file you can see that the api-samples frontend module gets loaded before the required core modules which causes the error.
Building this change on the PR branch causes no errors. The browser application loads as expected and the module loading is in correct order.
Review checklist
Reminder for reviewers