Skip to content
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

@typescript/ata JSR registry support #3202

Open
nicu-chiciuc opened this issue Aug 13, 2024 · 3 comments
Open

@typescript/ata JSR registry support #3202

nicu-chiciuc opened this issue Aug 13, 2024 · 3 comments

Comments

@nicu-chiciuc
Copy link

I understand this is not a critical issue. I've already tried to make some changes and open a PR but I think the issue might need some more thought put in.

I was trying to figure out a way to be able to allow imports of JSR packages in the monaco editor.

@typescript/ata relies on jsdelivr so the JSR packages aren't available there.

Issues I've encountered

1. Not clear how imports should work. In Deno it's possible to do it like this:

import { something } from 'jsr:@scope/package';

For Node, (https://jsr.io/docs/npm-compatibility), it's necessary to add a new registry https://npm.jsr.io/ and the name of the package gets transformed to

import {} from '@jsr/scope__package'

or packages.json can be updated like this:

 // package.json
 {
   "type": "module",
   "dependencies": {
-    "@jsr/luca__cases": "1"
+    "@luca/cases": "npm:@jsr/luca__cases@1"
   }
 }

2. Where to import the files from

Initially I tried querying jsr.io directly: https://jsr.io/@luca/flag/meta.json
based on https://jsr.io/docs/api

Then I figured it'd be better to use the npm compatibility layer so I get well formed ESM instead of Typescript.
I've used things like https://npm.jsr.io/@jsr/tscu__dependent

The issue now is that I don't get access to specific files, but to a tarball of a specific version.


At this point it's not clear what solution should be correct.
I figured maybe I'll open a discussion on this.

@orta
Copy link
Contributor

orta commented Aug 13, 2024

Before even cosindering syntax etc, the thing that makes ATA possible (reasonably cheaply time/resources wise) via jsdelivr is that they have an API which returns a list of the file tree we can work from. Then it's a matter of grabbing all the .d.ts files and re-implementing that in the vfs.

Without going back to a version of ATA which reads and parses every file to incrementally learn the shape of the file/dep graph, which this version of ATA probably doesn't want to do (as it's focused on web/playground)

You'd probably be better off asking the jsdelivr folks if they are interested in covering jsr (or asking jsr if they are interested in making a 'tree' like API)

@jakebailey
Copy link
Member

The issue now is that I don't get access to specific files, but to a tarball of a specific version.

I'm pretty sure the original files are accessible via paths like https://jsr.io/@luca/flag/1.0.0/main.ts (the API page indicates so).

@nicu-chiciuc
Copy link
Author

nicu-chiciuc commented Aug 14, 2024

I'm pretty sure the original files are accessible via paths like https://jsr.io/@luca/flag/1.0.0/main.ts (the API page indicates so).

Yes, but that's available only for the original files. I guess I could continue trying going in this direction. I was afraid this would get messy if the packages had other JSR deps.

examples:
https://jsr.io/@luca/flag/1.0.1_meta.json
https://jsr.io/@luca/flag/1.0.1/main.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants