Proposing a dyno loader, “as-ts” language server in userland?

Currently if all I want is how do I write it in a JavaScript runtime and execute it? this one astro File from Astro Framework.

// example.astro
---
console.log('hello world')
---
<div>hello world</div>
enter fullscreen mode

exit fullscreen mode

Currently you can’t really run it without the framework it lives in. nobody is here astro run example.astro command. Why would you need this? I’m using astro as an example, a type file that compiles into typescript, there are dozens, vue, svelte, rescript, dart, the list goes on. In the same way you can’t just run this astro file, you can’t really run most others, some are framework specific, and some are language flavors. Even if they include a mechanism for execution, there isn’t much difference. When it comes to runtimes and package managers use those runtimes (npm for node, url import for deno) there isn’t even one of the options.

The way vite+npm works is fundamentally different from the way deno url import works. when a package like @reggi/astro-stuff There is an astro file in its path example.astro vite has access to this static file from the file system and can access it. What I want in Vite + deno is this:

https://deno.land/x/reggi@0.0.3/astro-stuff/example.astro
enter fullscreen mode

exit fullscreen mode

This url is an astro file in import. Deno has no clue how to handle this type of file type, or the astro syntax. You can imagine that within the astro file, there could be even more dyno imports and dyno would need to know how to get the dependencies recursively.

The conversation on whether Dino should handle this or the userland should be active here.

enter the “as-ts Language Server”. In Dino you can specify import maps.

{
  "imports": {
    "as-ts/": "https://localhost:3021/"
  }
}
enter fullscreen mode

exit fullscreen mode

Then when you import a module you can do:

import 'as-ts/https://deno.land/x/reggi@0.0.3/astro-stuff/example.astro'
enter fullscreen mode

exit fullscreen mode

import 'as-ts/example.astro'
enter fullscreen mode

exit fullscreen mode

The language server will be set up to take the incoming local file requests or url requests, the file will be cached and converted to ts files. Deno will only look at the ts file and if there are more imports then deno will only get them by looking at the ts files.

The server will be able to detect different file types

import 'as-ts/example.svelte'
enter fullscreen mode

exit fullscreen mode

import 'as-ts/example.mdx'
enter fullscreen mode

exit fullscreen mode

Leave a Comment