(
url: string,
importer: string | undefined,
cachedModule: EvaluatedModuleNode | undefined,
)
| 265 | } |
| 266 | |
| 267 | private async getModuleInformation( |
| 268 | url: string, |
| 269 | importer: string | undefined, |
| 270 | cachedModule: EvaluatedModuleNode | undefined, |
| 271 | ): Promise<EvaluatedModuleNode> { |
| 272 | if (this.closed) { |
| 273 | throw new Error(`Vite module runner has been closed.`) |
| 274 | } |
| 275 | |
| 276 | await this.ensureBuiltins() |
| 277 | |
| 278 | this.debug?.(class="st">'[module runner] fetching', url) |
| 279 | |
| 280 | const isCached = !!(typeof cachedModule === class="st">'object' && cachedModule.meta) |
| 281 | |
| 282 | const fetchedModule = class="cm">// fast return for established externalized pattern |
| 283 | ( |
| 284 | url.startsWith(class="st">'data:') || this.isBuiltin?.(url) |
| 285 | ? { externalize: url, type: class="st">'builtin' } |
| 286 | : await this.transport.invoke(class="st">'fetchModule', [ |
| 287 | url, |
| 288 | importer, |
| 289 | { |
| 290 | cached: isCached, |
| 291 | startOffset: this.evaluator.startOffset, |
| 292 | }, |
| 293 | ]) |
| 294 | ) as ResolvedResult |
| 295 | |
| 296 | if (class="st">'cache' in fetchedModule) { |
| 297 | if (!cachedModule || !cachedModule.meta) { |
| 298 | throw new Error( |
| 299 | `Module class="st">"${url}" was mistakenly invalidated during fetch phase.`, |
| 300 | ) |
| 301 | } |
| 302 | return cachedModule |
| 303 | } |
| 304 | |
| 305 | const moduleId = |
| 306 | class="st">'externalize' in fetchedModule |
| 307 | ? fetchedModule.externalize |
| 308 | : fetchedModule.id |
| 309 | const moduleUrl = class="st">'url' in fetchedModule ? fetchedModule.url : url |
| 310 | const module = this.evaluatedModules.ensureModule(moduleId, moduleUrl) |
| 311 | |
| 312 | if (class="st">'invalidate' in fetchedModule && fetchedModule.invalidate) { |
| 313 | this.evaluatedModules.invalidateModule(module) |
| 314 | } |
| 315 | |
| 316 | fetchedModule.url = moduleUrl |
| 317 | fetchedModule.id = moduleId |
| 318 | module.meta = fetchedModule |
| 319 | |
| 320 | return module |
| 321 | } |
| 322 | |
| 323 | class="cm">// override is allowed, consider this a public API |
| 324 | protected async directRequest( |
no test coverage detected