feat(jsr): improve jsr support#1186
Conversation
|
Apply |
|
Let's make a bit shorter ver resolver: export const VERSION: string = (() => {
const f = (file: string) =>
fs.readJsonSync(new URL(file, import.meta.url), { throws: false })
return (f('../package.json') || f('../jsr.json'))?.version
})() |
.nycrc
Outdated
| "reporter": ["html", "text"], | ||
| "lines": 98, | ||
| "branches": "90", | ||
| "branches": "89", |
There was a problem hiding this comment.
Can we fix this another way? Add some extra tests maybe.
There was a problem hiding this comment.
Can we fix this another way? Add some extra tests maybe.
I researched and found how to fix the branching like as globalThis.Deno ? globalThis.require('./cli.cjs') : module, so I lowered the coverage threshold. May be use istanbul ignore next directive, but I don't find anything in this repo.
There was a problem hiding this comment.
I'll take a closer look at the report
.size-limit.json
Outdated
| "name": "js parts", | ||
| "path": "build/*.{js,cjs}", | ||
| "limit": "815.7 kB", | ||
| "limit": "828.90 kB", |
There was a problem hiding this comment.
Added 10more by accident, I will refund
| return new Proxy<T>(api, { | ||
| get(_, key) { | ||
| return store.get(name)[key] | ||
| return store.get(name)[key] || store.get(name)?.default?.[key] |
There was a problem hiding this comment.
Nice catch, I'd suggest a minor improvement:
const store = new Map<string, any>()
const override = store.set.bind(store)
const trydef = (v: any) => v?.default || v
const wrap = <T extends object>(name: string, api: T): T => {
override(name, api)
return new Proxy<T>(api, {
get(_, key) {
return trydef(store.get(name))?.[key]
},
apply(_, self, args) {
return trydef(store.get(name) as TCallable).apply(self, args)
},
})
}
antongolub
left a comment
There was a problem hiding this comment.
LGTM. Thanks for the improvement!
|
jsr restricts global types changes. |
Fixes #1180
DenoVERSIONfrom jsr.ioverdor-corewith default exportscli.tsfor jsr.iosize-limit@antongolub