|
10 | 10 | * const workspace = new Workspace({ |
11 | 11 | * // optional options |
12 | 12 | * }); |
13 | | - * const { loader, diagnostics } = await workspace.createLoader({ |
14 | | - * entrypoints: ["./mod.ts"] |
15 | | - * }); |
| 13 | + * const loader = await workspace.createLoader(); |
| 14 | + * const diagnostics = await loader.addEntrypoints(["./mod.ts"]) |
16 | 15 | * if (diagnostics.length > 0) { |
17 | 16 | * throw new Error(diagnostics[0].message); |
18 | 17 | * } |
@@ -68,12 +67,6 @@ export interface WorkspaceOptions { |
68 | 67 | noTranspile?: boolean; |
69 | 68 | } |
70 | 69 |
|
71 | | -/** Options for loading. */ |
72 | | -export interface LoaderOptions { |
73 | | - /** Entrypoints to create the loader for. */ |
74 | | - entrypoints: string[]; |
75 | | -} |
76 | | - |
77 | 70 | /** File type. */ |
78 | 71 | export enum MediaType { |
79 | 72 | JavaScript = 0, |
@@ -156,20 +149,9 @@ export class Workspace implements Disposable { |
156 | 149 | } |
157 | 150 |
|
158 | 151 | /** Creates a loader that uses this this workspace. */ |
159 | | - async createLoader( |
160 | | - options: LoaderOptions, |
161 | | - ): Promise<{ loader: Loader; diagnostics: EntrypointDiagnostic[] }> { |
162 | | - if (this.#debug) { |
163 | | - console.error( |
164 | | - `Creating loader for entrypoints:\n ${ |
165 | | - options.entrypoints.join("\n ") |
166 | | - }`, |
167 | | - ); |
168 | | - } |
| 152 | + async createLoader(): Promise<Loader> { |
169 | 153 | const wasmLoader = await this.#inner.create_loader(); |
170 | | - const loader = new Loader(wasmLoader, this.#debug); |
171 | | - const diagnostics = await loader.addEntrypoints(options.entrypoints); |
172 | | - return { loader, diagnostics }; |
| 154 | + return new Loader(wasmLoader, this.#debug); |
173 | 155 | } |
174 | 156 | } |
175 | 157 |
|
@@ -202,11 +184,11 @@ export class Loader implements Disposable { |
202 | 184 | this.#inner.free(); |
203 | 185 | } |
204 | 186 |
|
205 | | - /** Adds additional entrypoints to the loader after the fact. |
| 187 | + /** Adds entrypoints to the loader. |
206 | 188 | * |
207 | | - * This may be useful for having a JSR specifier asynchronously |
208 | | - * stored in the internal module graph on the fly, which will allow |
209 | | - * it to be synchronously resolved. |
| 189 | + * It's useful to specify entrypoints so that the loader can resolve |
| 190 | + * npm: and jsr: specifiers the same way that Deno does when not using |
| 191 | + * a lockfile. |
210 | 192 | */ |
211 | 193 | async addEntrypoints( |
212 | 194 | entrypoints: string[], |
|
0 commit comments