Presently if I wished to how can I write this in any javascript runtime and execute it? That is an astro
file from the astro framework.
// instance.astro
---
console.log('good day world')
---
<div>good day world</div>
Presently you may’t actually run this with out the framework it lives in. There isn’t any astro run instance.astro
command. Why would you want this? I am utilizing astro for instance, of a kind of file that compiles to TypeScript, there are dozens, vue
, svelte
, rescript
, dart
, the checklist goes on. The identical method you may’t simply run this astro file, you may’t actually run many of the others, some are framework particular, and a few are language flavors. Even when they embody a mechanism for execution there’s not loads of interoperability. There’s additionally not a complete not of choices with regards to the runtimes and the bundle managers these runtimes use (npm for node, url imports for deno).
The way in which vite + npm works is essentially totally different from how deno url imports work. When a bundle resembling @reggi/astro-stuff
has an astro file in its path instance.astro
vite has entry to this static file from the file system and may entry it. In vite + deno what I would like is that this:
https://deno.land/x/reggi@0.0.3/astro-stuff/instance.astro
This can be a astro file in a url import. Deno has no clue the best way to deal with this kind of file kind, or the astro syntax. You’ll be able to think about that inside the astro file, there could even be extra deno imports and deno would want to know the best way to recursively get the dependencies.
The dialog on whether or not or not deno ought to deal with this or userland ought to is lively right here.
Enter the “as-ts
language server”. In deno you may specify import maps.
{
"imports": {
"as-ts/": "https://localhost:3021/"
}
}
Then whenever you import a module you are able to do this:
import 'as-ts/https://deno.land/x/reggi@0.0.3/astro-stuff/instance.astro'
import 'as-ts/instance.astro'
The language server can be setup to take incoming native file requests or url requests fetch the file, cache and convert them into ts information. Deno would solely see the ts file and if there are extra imports deno would fetch these as nicely solely seeing the ts information.
The server would be capable to detect totally different file sorts
import 'as-ts/instance.svelte'
import 'as-ts/instance.mdx'