Unverified Commit 0dace489 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Add comments to package scheme fix (#45997)

parent 0b2bf994
......@@ -53,12 +53,22 @@ class WebEntrypointTarget extends Target {
final bool shouldInitializePlatform = environment.defines[kInitializePlatform] == 'true';
final bool hasPlugins = environment.defines[kHasWebPlugins] == 'true';
final String importPath = fs.path.absolute(targetFile);
// Use the package uri mapper to find the correct package-scheme import path
// for the user application. If the application has a mix of package-scheme
// and relative imports for a library, then importing the entrypoint as a
// file-scheme will cause said library to be recognized as two distinct
// libraries. This can cause surprising behavior as types from that library
// will be considered distinct from each other.
final PackageUriMapper packageUriMapper = PackageUriMapper(
importPath,
PackageMap.globalPackagesPath,
null,
null,
);
// By construction, this will only be null if the .packages file does not
// have an entry for the user's application.
final Uri mainImport = packageUriMapper.map(importPath);
if (mainImport == null) {
throw Exception('Missing package definition for $mainImport');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment