resolve method
Resolve a single ModuleImport to a Module.
Implementation
Future<Module> resolve(ModuleImport import_) async {
// Fast path: integrity hash present and cached.
if (import_.integrity.isNotEmpty && cache.has(import_.integrity)) {
return cache.get(import_.integrity)!;
}
// Dispatch on source type.
final module = await _fetch(import_);
// Verify integrity if specified.
if (import_.integrity.isNotEmpty) {
if (!verifyIntegrity(module, import_.integrity)) {
throw StateError(
'Integrity check failed for module "${import_.name}". '
'Expected: ${import_.integrity}, '
'Got: ${computeIntegrity(module)}',
);
}
}
// Cache the resolved module.
cache.put(module);
// Recursively resolve this module's own imports.
await _resolveTransitive(module);
return module;
}