Skip to content

explicitly skip dart-ext: uris #2046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build_modules/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions build_modules/lib/src/module_library.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions build_resolvers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
9 changes: 7 additions & 2 deletions build_resolvers/lib/src/build_asset_uri_resolver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <AssetId, Set<AssetId>>{};
final _cachedAssetContents = <AssetId, String>{};
Expand Down Expand Up @@ -48,7 +50,10 @@ class BuildAssetUriResolver extends UriResolver {
var unit = parseDirectives(contents, suppressErrors: true);
var dependencies = unit.directives
.whereType<UriBasedDirective>()
.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();
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion build_resolvers/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
homepage: https://github.com/dart-lang/build/tree/master/build_resolvers
Expand Down
4 changes: 4 additions & 0 deletions build_resolvers/test/resolver_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down