feat: add JSR protocol support for package specifiers #8691
+304
−0
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.
Motivation
Given that JSR is an MIT-licensed open-source solution and is already supported by other package managers such as Volt and pnpm, I believe npm should also adopt this feature to maintain consistency within the JavaScript ecosystem and provide a seamless user experience.
Current Behavior
Before this change, installing JSR packages is possible by adding the following to the
package.json
:This approach is rather messy and relies on the npm compatibility registry API to download packages from the JSR registry.
Proposed Solution
The proposed solution would be to handle installing packages from JSR natively. Installing a package from JSR would be simplified to:
Which then installs a JSR package into the
package.json
as follows:Dependencies
This PR depends on npm/npm-package-arg#214 being merged first.
Reference
This implementation is based on the approach discussed in pnpm/pnpm#8941.