Repository: rollup/rollup
File: src/ModuleLoader.ts (TypeScript)

Code before:
						? normalizeRelativeExternalId(resolveIdResult, importer)
						: resolveIdResult
			};
		}

		const id = makeAbsoluteExternalsRelative
			? normalizeRelativeExternalId(source, importer)
			: source;
		if (resolveIdResult !== false && !this.options.external(id, importer, true)) {
			return null;
		}
		return {
			external: isNotAbsoluteExternal(id, source, makeAbsoluteExternalsRelative) || 'absolute',
			id
		};
	}

	private getResolveDynamicImportPromises(module: Module): ResolveDynamicDependencyPromise[] {
		return module.dynamicImports.map(async dynamicImport => {
			const resolvedId = await this.resolveDynamicImport(
				module,
				dynamicImport.argument,
				module.id,
				getAttributesFromImportExpression(dynamicImport.node)
			);
			dynamicImport.node.shouldBindAttributes = !resolvedId;
			if (resolvedId && typeof resolvedId === 'object') {
				dynamicImport.id = resolvedId.id;
			}
			return [dynamicImport, resolvedId] as const;
		});
	}

	private getResolveStaticDependencyPromises(module: Module): ResolveStaticDependencyPromise[] {
		return Array.from(
			module.sourcesWithAttributes,
			async ([source, attributes]) =>
				[
					source,
					(module.resolvedIds[source] =
						module.resolvedIds[source] ||
						this.handleInvalidResolvedId(
							await this.resolveId(source, module.id, EMPTY_OBJECT, false, attributes),
							source,
							module.id,
							attributes
						))
				] as const
		);
	}


Review comment (suggestion):
If `resolvedId` is a string, this basically means we are blindly replacing the import with this string and it also counts as "unresolved". Therefore, the flag on the node should be set exactly in the same cases where we set `dynamicImport.id = resolvedId.id` below. Unfortunately, I do not think we have access to this dynamicImport data structure in the ImportExpression, otherwise we could just remove the flag altogether.

Code after:
						? normalizeRelativeExternalId(resolveIdResult, importer)
						: resolveIdResult
			};
		}

		const id = makeAbsoluteExternalsRelative
			? normalizeRelativeExternalId(source, importer)
			: source;
		if (resolveIdResult !== false && !this.options.external(id, importer, true)) {
			return null;
		}
		return {
			external: isNotAbsoluteExternal(id, source, makeAbsoluteExternalsRelative) || 'absolute',
			id
		};
	}

	private getResolveDynamicImportPromises(module: Module): ResolveDynamicDependencyPromise[] {
		return module.dynamicImports.map(async dynamicImport => {
			const resolvedId = await this.resolveDynamicImport(
				module,
				dynamicImport.argument,
				module.id,
				getAttributesFromImportExpression(dynamicImport.node)
			);
			if (!resolvedId || typeof resolvedId === 'string') {
				dynamicImport.node.shouldIncludeDynamicAttributes = true;
			} else {
				dynamicImport.node.shouldIncludeDynamicAttributes = !!resolvedId.external;
				dynamicImport.id = resolvedId.id;
			}
			return [dynamicImport, resolvedId] as const;
		});
	}

	private getResolveStaticDependencyPromises(module: Module): ResolveStaticDependencyPromise[] {
		return Array.from(
			module.sourcesWithAttributes,
			async ([source, attributes]) =>
				[
					source,
					(module.resolvedIds[source] =
						module.resolvedIds[source] ||
						this.handleInvalidResolvedId(
							await this.resolveId(source, module.id, EMPTY_OBJECT, false, attributes),
							source,
							module.id,
							attributes
						))
				] as const
		);