A simple implementation of deno_core's ModuleLoader trait which supports loading modules from the network.
MIT License
The deno_core
crate, part of the
Deno Javascript/Typescript runtime, provides a high-level
interface over the V8 Javascript engine, with an event loop abstraction that
integrates with Rust async
code. This includes facilities for handling ES
modules and dynamic imports.
However, deno_core
does not by itself resolve and fetch modules. Instead it
provides a
ModuleLoader
trait, alongside with two implementations:
NoopModuleLoader
,
which fails when importing modules, and
FsModuleLoader
,
which is limited to modules in the filesystem. deno_core
does not provide an
implementation of ModuleLoader
which performs network requests, and the
implementation in the Deno program is tightly coupled with Deno's network fetch
infrastructure and with its Typescript compilation pipeline, so it can't be
easily copied.
This crate provides a simple implementation of ModuleLoader
that does load
modules from the network, built on top of reqwest
.
Things it supports:
{type: "json"}
import attributes just work)Things it doesn't plan to support (but hey, file an issue if it bugs you):
"lodash"
), URL specifiers which are not supported in browsers (like Deno'snpm:
URL support), or any other mapping from the import specifier to the{type: "my-custom-type"}
). CSStokio
.deno-simple-module-loader
doesn't work with versions of deno_core
lower than
0.246.0. (The current version at the time of writing is 0.248.0).
This is a work in progress. No guarantees, yadda yadda.