(
{ attributes, id, meta, moduleSideEffects, syntheticNamedExports }: ResolvedId,
importer: string | undefined,
isEntry: boolean,
isPreload: PreloadType
)
| 402 | // its dependencies to be loaded. |
| 403 | // Otherwise, it returns immediately. |
| 404 | private async fetchModule( |
| 405 | { attributes, id, meta, moduleSideEffects, syntheticNamedExports }: ResolvedId, |
| 406 | importer: string | undefined, |
| 407 | isEntry: boolean, |
| 408 | isPreload: PreloadType |
| 409 | ): Promise<Module> { |
| 410 | const existingModule = this.modulesById.get(id); |
| 411 | if (existingModule instanceof Module) { |
| 412 | if (importer && doAttributesDiffer(attributes, existingModule.info.attributes)) { |
| 413 | this.options.onLog( |
| 414 | LOGLEVEL_WARN, |
| 415 | logInconsistentImportAttributes(existingModule.info.attributes, attributes, id, importer) |
| 416 | ); |
| 417 | } |
| 418 | await this.handleExistingModule(existingModule, isEntry, isPreload); |
| 419 | return existingModule; |
| 420 | } |
| 421 | |
| 422 | if (existingModule instanceof ExternalModule) { |
| 423 | return error(logExternalModulesCannotBeTransformedToModules(existingModule.id)); |
| 424 | } |
| 425 | |
| 426 | const module = new Module( |
| 427 | this.graph, |
| 428 | id, |
| 429 | this.options, |
| 430 | isEntry, |
| 431 | moduleSideEffects, |
| 432 | syntheticNamedExports, |
| 433 | meta, |
| 434 | attributes |
| 435 | ); |
| 436 | this.modulesById.set(id, module); |
| 437 | const loadPromise: LoadModulePromise = this.addModuleSource(id, importer, module).then(() => [ |
| 438 | this.getResolveStaticDependencyPromises(module), |
| 439 | this.getResolveDynamicImportPromises(module), |
| 440 | loadAndResolveDependenciesPromise |
| 441 | ]); |
| 442 | const loadAndResolveDependenciesPromise = waitForDependencyResolution(loadPromise).then(() => |
| 443 | this.pluginDriver.hookParallel('moduleParsed', [module.info]) |
| 444 | ); |
| 445 | loadAndResolveDependenciesPromise.catch(() => { |
| 446 | /* avoid unhandled promise rejections */ |
| 447 | }); |
| 448 | this.moduleLoadPromises.set(module, loadPromise); |
| 449 | const resolveDependencyPromises = await loadPromise; |
| 450 | if (!isPreload) { |
| 451 | await this.fetchModuleDependencies(module, ...resolveDependencyPromises); |
| 452 | } else if (isPreload === RESOLVE_DEPENDENCIES) { |
| 453 | await loadAndResolveDependenciesPromise; |
| 454 | } |
| 455 | return module; |
| 456 | } |
| 457 | |
| 458 | private async fetchModuleDependencies( |
| 459 | module: Module, |
no test coverage detected