Index: lib/src/util/dart.dart |
diff --git a/lib/src/util/dart.dart b/lib/src/util/dart.dart |
index 05cd260a96b92433ba073b65aed9c4a6785de6e5..e18b50d0334adfb85134166a80ac70e1aef8a05d 100644 |
--- a/lib/src/util/dart.dart |
+++ b/lib/src/util/dart.dart |
@@ -6,6 +6,7 @@ import 'dart:async'; |
import 'dart:isolate'; |
import 'package:analyzer/analyzer.dart'; |
+import 'package:package_resolver/package_resolver.dart'; |
import 'package:source_span/source_span.dart'; |
import 'string_literal_iterator.dart'; |
@@ -16,13 +17,18 @@ import 'string_literal_iterator.dart'; |
/// they will be resolved in the same context as the host isolate. [message] is |
/// passed to the [main] method of the code being run; the caller is responsible |
/// for using this to establish communication with the isolate. |
-Future<Isolate> runInIsolate(String code, message, {bool checked}) async { |
+/// |
+/// If [resolver] is passed, its package resolution strategy is used to resolve |
+/// code in the spawned isolate. It defaults to [PackageResolver.current]. |
+Future<Isolate> runInIsolate(String code, message, {PackageResolver resolver, |
+ bool checked}) async { |
+ resolver ??= PackageResolver.current; |
return await Isolate.spawnUri( |
Uri.parse('data:application/dart;charset=utf-8,' + Uri.encodeFull(code)), |
[], |
message, |
- packageRoot: await Isolate.packageRoot, |
- packageConfig: await Isolate.packageConfig, |
+ packageRoot: await resolver.packageRoot, |
+ packageConfig: await resolver.packageConfigUri, |
checked: checked); |
} |