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

Add recipe for remote node modules #27

Open
nandorojo opened this issue Jun 8, 2024 · 11 comments
Open

Add recipe for remote node modules #27

nandorojo opened this issue Jun 8, 2024 · 11 comments

Comments

@nandorojo
Copy link
Contributor

nandorojo commented Jun 8, 2024

A useful feature is to let you use any node modules in the editor. However, this requires 1) parsing the file, 2) querying NPM for their types (potentially@types/package-name) and lastly inserting the types into codemirror-ts. It could be useful to document the ideal way to handle 2 or maybe abstract it into a function

For deno, these would be URLs and/or npm:package-name, but it could be cool to support both

@tmcw
Copy link
Member

tmcw commented Jun 8, 2024

Yep! The answer to this is ata but the long answer is, whew, it's hard and we've poured days into improving type acquisition and it is still really tough. Making TypeScript and Deno get along is extremely hard - TypeScript doesn't support npm: or jsr: prefixes, doesn't support URLs for imports, etc. So you have to do a lot of arbitrary trickery to make the two get along.

I've been planning on refactoring our code and might be able to make it OSS, but can't promise that it'll be all that robust 😭

@stevekrouse
Copy link

We're also thinking about integrating with Deno LSP run on a server somewhere.

In theory it could also be fun to try getting the Deno LSP server running in wasm on the browser but I am not very hopeful about that.

@nandorojo
Copy link
Contributor Author

would be very cool

@nandorojo
Copy link
Contributor Author

btw @tmcw thanks for sharing ata, not sure how I missed that. I might just try a regex to find-and-replace the npm: and jsr: prefixes. As for the URL imports...well that sounds harder haha.

I'll play with this and share any updates.

@nandorojo
Copy link
Contributor Author

I've been planning on refactoring our code and might be able to make it OSS, but can't promise that it'll be all that robust 😭

Even if it's not...anything helps!

@nandorojo
Copy link
Contributor Author

Just as a note: I managed to get this working with @typescript/ata. However, I haven't yet figured out a way to get the types working with deno. If there's anything you can share about the tricks you used to support these prefixes after fetching the files from ata, would be super appreciated.

@nandorojo
Copy link
Contributor Author

Possibly some relevant notes for Deno here: microsoft/TypeScript-Website#2097

@nandorojo
Copy link
Contributor Author

I managed to get this working for npm: imports. It involves some minor hacks but it's actually quite good and uses internals from @typescript/ata. Let me know if you'd like me to share it here and I can put it together. I think it could be worth adding as an extension to this library.

@tmcw
Copy link
Member

tmcw commented Jun 12, 2024

All right - here's our deno-ata repo: https://github.com/val-town/deno-ata

Pretty unfinished/unpolished, this is derived from a refactor that I've been working on of this code.

@nandorojo
Copy link
Contributor Author

thank you! it’s private though btw

@tmcw
Copy link
Member

tmcw commented Jun 12, 2024

Whoops - it's public now

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