diff --git a/build_modules/CHANGELOG.md b/build_modules/CHANGELOG.md index 8dcfd048e..f6017f9a4 100644 --- a/build_modules/CHANGELOG.md +++ b/build_modules/CHANGELOG.md @@ -1,5 +1,7 @@ ## 1.0.7 +- Explicitly skip dart-ext uris during module creation. + - Filed Issue #2047 to track real support for native extensions. - Run workers with mode `detachedWithStdio` if no terminal is connected. ## 1.0.6 diff --git a/build_modules/lib/src/module_library.dart b/build_modules/lib/src/module_library.dart index 81056ec55..9f52ab2b6 100644 --- a/build_modules/lib/src/module_library.dart +++ b/build_modules/lib/src/module_library.dart @@ -78,6 +78,10 @@ class ModuleLibrary { if (directive is! UriBasedDirective) continue; var path = (directive as UriBasedDirective).uri.stringValue; var uri = Uri.parse(path); + if (uri.isScheme('dart-ext')) { + // TODO: What should we do for native extensions? + continue; + } if (uri.scheme == 'dart') { sdkDeps.add(uri.path); continue; diff --git a/build_resolvers/CHANGELOG.md b/build_resolvers/CHANGELOG.md index 1de493032..ac8cb4dfc 100644 --- a/build_resolvers/CHANGELOG.md +++ b/build_resolvers/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.0.3 + +- Fixes a bug where transitive `dart-ext:` imports would cause the resolver + to fail. These uris will now be ignored. + ## 1.0.2 - Ensure that `BuildAssetUriResolver.restoreAbsolute` never returns null. diff --git a/build_resolvers/lib/src/build_asset_uri_resolver.dart b/build_resolvers/lib/src/build_asset_uri_resolver.dart index 8ffe14e4b..d13421664 100644 --- a/build_resolvers/lib/src/build_asset_uri_resolver.dart +++ b/build_resolvers/lib/src/build_asset_uri_resolver.dart @@ -13,6 +13,8 @@ import 'package:analyzer/src/generated/source.dart'; import 'package:build/build.dart' show AssetId, BuildStep; import 'package:path/path.dart' as p; +const _ignoredSchemes = ['dart', 'dart-ext']; + class BuildAssetUriResolver extends UriResolver { final _cachedAssetDependencies = >{}; final _cachedAssetContents = {}; @@ -48,7 +50,10 @@ class BuildAssetUriResolver extends UriResolver { var unit = parseDirectives(contents, suppressErrors: true); var dependencies = unit.directives .whereType() - .where((d) => !Uri.parse(d.uri.stringValue).isScheme('dart')) + .where((directive) { + var uri = Uri.parse(directive.uri.stringValue); + return !_ignoredSchemes.any(uri.isScheme); + }) .map((d) => AssetId.resolve(d.uri.stringValue, from: assetId)) .where((id) => id != null) .toSet(); @@ -79,7 +84,7 @@ class BuildAssetUriResolver extends UriResolver { /// /// Returns null if the Uri cannot be parsed or is not cached. AssetId lookupAsset(Uri uri) { - if (uri.isScheme('dart')) return null; + if (_ignoredSchemes.any(uri.isScheme)) return null; if (uri.isScheme('package') || uri.isScheme('asset')) { final assetId = AssetId.resolve('$uri'); return _cachedAssetContents.containsKey(assetId) ? assetId : null; diff --git a/build_resolvers/pubspec.yaml b/build_resolvers/pubspec.yaml index 9ee4d69e4..035ac2ee4 100644 --- a/build_resolvers/pubspec.yaml +++ b/build_resolvers/pubspec.yaml @@ -1,5 +1,5 @@ name: build_resolvers -version: 1.0.2 +version: 1.0.3 description: Resolve Dart code in a Builder author: Dart Team homepage: https://github.com/dart-lang/build/tree/master/build_resolvers diff --git a/build_resolvers/test/resolver_test.dart b/build_resolvers/test/resolver_test.dart index 5d3e0a32f..8e59cab69 100644 --- a/build_resolvers/test/resolver_test.dart +++ b/build_resolvers/test/resolver_test.dart @@ -103,7 +103,11 @@ void main() { test('should resolve types and library uris', () { return resolveSources({ 'a|web/main.dart': ''' + // dart and dart-ext uris should be ignored import 'dart:core'; + import 'dart-ext:some-ext'; + + // package: and relative uris should be available import 'package:a/a.dart'; import 'package:a/b.dart'; import 'sub_dir/d.dart';