feat: support bare specifiers in mappings - #508
Merged
Conversation
A mapping key that isn't a path or url is now resolved via the config
file's import map, so a specifier in a deno.json's `imports` can be
mapped to an npm package:
```jsonc
// deno.json
{
"imports": {
"my-lib": "https://deno.land/x/my-lib@39.0.0/src/index.ts"
}
}
```
```ts
await build({
// ...etc...
mappings: {
"my-lib": {
name: "npm-target-for-my-lib",
version: "^39.0.0",
},
},
});
```
Closes denoland#357
Claude-Session: https://claude.ai/code/session_01SqfDuWeEek5XnHSbXxCUE9
- only treat a mapping key as a path when it has a scheme, is relative or absolute, or exists on disk, so that a bare specifier with an extension works (ex. `chart.js`) - resolve using the referrer's resolution mode and fall back to the other entry points - show the key the user specified in the "not found" error - error when two mappings resolve to the same specifier - resolve in a deterministic order Claude-Session: https://claude.ai/code/session_01SqfDuWeEek5XnHSbXxCUE9
…pecifiers # Conflicts: # deno.jsonc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #357
A
mappingskey had to be a path or url, so a specifier that only exists in the deno.json'simportscouldn't be mapped by the name that appears in the code. Now a bare specifier key is resolved via the config file's import map:Details:
mod.tskeeps resolving to a file). Everything else is a bare specifier, which means package names containing a dot likechart.jswork.