-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: support JSON entrypoints in JSR packages #476
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# https://jsr.io/@scope/a/meta.json | ||
{ | ||
"versions": { | ||
"1.0.0": {} | ||
} | ||
} | ||
|
||
# https://jsr.io/@scope/a/1.0.0_meta.json | ||
{ | ||
"manifest": {}, | ||
"exports": { | ||
".": "./data.json" | ||
} | ||
} | ||
|
||
# https://jsr.io/@scope/a/1.0.0/data.json | ||
HEADERS: {"content-type":"application/json"} | ||
{ | ||
"data": 5 | ||
} | ||
|
||
# mod.ts | ||
import test from 'jsr:@scope/a' with { "type": "json" }; | ||
console.log(test); | ||
|
||
# output | ||
{ | ||
"roots": [ | ||
"file:///mod.ts" | ||
], | ||
"modules": [ | ||
{ | ||
"kind": "esm", | ||
"dependencies": [ | ||
{ | ||
"specifier": "jsr:@scope/a", | ||
"code": { | ||
"specifier": "jsr:@scope/a", | ||
"span": { | ||
"start": { | ||
"line": 0, | ||
"character": 17 | ||
}, | ||
"end": { | ||
"line": 0, | ||
"character": 31 | ||
} | ||
} | ||
}, | ||
"assertionType": "json" | ||
} | ||
], | ||
"size": 76, | ||
"mediaType": "TypeScript", | ||
"specifier": "file:///mod.ts" | ||
}, | ||
{ | ||
"kind": "asserted", | ||
"specifier": "https://jsr.io/@scope/a/1.0.0/data.json", | ||
"size": 16, | ||
"mediaType": "Json" | ||
} | ||
], | ||
"redirects": { | ||
"jsr:@scope/a": "https://jsr.io/@scope/a/1.0.0/data.json" | ||
}, | ||
"packages": { | ||
"@scope/a": "@scope/a@1.0.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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What it was doing here was quite broken handling of attribute types. The change I made is also broken, but slightly better. To fix this properly we need to key on attribute type in addition to specifier for pending loads, but that's a big change for the future (that said, what we probably want to do is not allow two imports to the same specifier with different attribute types for the time being, but I think that's maybe handled by v8?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not really handled by V8 - given (specifier, attributes) it is embedders responsibility to provide the proper source for the module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, ok, I'll do a follow-up to fix. Before it was actually only sometimes erroring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Back in the wmr days we serialized the import attributes to query params and added that to the file URL. That worked quite well and allowed us to keep the cache logic flat