diff --git a/src/mod.ts b/src/mod.ts index 923f364..c2b18f4 100644 --- a/src/mod.ts +++ b/src/mod.ts @@ -156,7 +156,7 @@ export class Workspace implements Disposable { } const wasmLoader = await this.#inner.create_loader(); const loader = new Loader(wasmLoader, this.#debug); - await loader.addRoots(options.entrypoints); + await loader.addEntrypoints(options.entrypoints); return loader; } } @@ -186,14 +186,14 @@ export class Loader implements Disposable { this.#inner.free(); } - /** Adds additional roots to the loader. + /** Adds additional entrypoints to the loader after the fact. * - * This may be useful for having a JSR specifier stored - * in the internal module graph on the fly, which will allow - * it to be resolved. + * This may be useful for having a JSR specifier asynchronously + * stored in the internal module graph on the fly, which will allow + * it to be synchronously resolved. */ - addRoots(entrypoints: string[]): Promise { - return this.#inner.add_roots(entrypoints); + addEntrypoints(entrypoints: string[]): Promise { + return this.#inner.add_entrypoints(entrypoints); } /** Resolves a specifier using the given referrer and resolution mode. */ diff --git a/src/rs_lib/lib.rs b/src/rs_lib/lib.rs index 611d9e1..0258e9f 100644 --- a/src/rs_lib/lib.rs +++ b/src/rs_lib/lib.rs @@ -333,19 +333,27 @@ impl DenoLoader { self.graph.serialize(&serializer).unwrap() } - pub async fn add_roots(&mut self, roots: Vec) -> Result<(), JsValue> { + pub async fn add_entrypoints( + &mut self, + entrypoints: Vec, + ) -> Result<(), JsValue> { // only allow one async task to modify the graph at a time let task_queue = self.task_queue.clone(); task_queue - .run(async { self.add_roots_inner(roots).await.map_err(create_js_error) }) + .run(async { + self + .add_entrypoints_internal(entrypoints) + .await + .map_err(create_js_error) + }) .await } - async fn add_roots_inner( + async fn add_entrypoints_internal( &mut self, - roots: Vec, + entrypoints: Vec, ) -> Result<(), anyhow::Error> { - let roots = roots + let roots = entrypoints .into_iter() .map(|e| self.resolve_entrypoint(e)) .collect::, _>>()?;