@@ -12,6 +12,7 @@ import 'package:dwds/dwds.dart';
1212import 'package:file/file.dart' ;
1313import 'package:logging/logging.dart' ;
1414import 'package:meta/meta.dart' ;
15+ import 'package:package_config/package_config.dart' ;
1516import 'package:path/path.dart' as p;
1617
1718import 'asset.dart' ;
@@ -30,8 +31,7 @@ class WebDevFS {
3031 this .fileSystem,
3132 this .hostname,
3233 this .port,
33- this .packagesFilePath,
34- this .packagesPath,
34+ this .packageConfigPath,
3535 this .root,
3636 this .urlTunneller,
3737 });
@@ -40,24 +40,31 @@ class WebDevFS {
4040 TestAssetServer assetServer;
4141 final String hostname;
4242 final int port;
43- final String packagesFilePath;
44- final String packagesPath;
43+ final String packageConfigPath;
4544 final String root;
4645 final UrlEncoder urlTunneller;
4746 Directory _savedCurrentDirectory;
4847 List <Uri > sources;
48+ PackageConfig _packageConfig;
4949
5050 Future <Uri > create () async {
5151 _savedCurrentDirectory = fileSystem.currentDirectory;
52- fileSystem.currentDirectory = packagesPath;
52+ // package_config.json is located in <project directory>/.dart_tool/package_config
53+ var projectDirectory = p.dirname (p.dirname (packageConfigPath));
54+
55+ fileSystem.currentDirectory = projectDirectory;
56+
57+ _packageConfig = await loadPackageConfigUri (Uri .file (packageConfigPath),
58+ loader: (Uri uri) => fileSystem.file (uri).readAsBytes ());
59+
5360 assetServer = await TestAssetServer .start (
54- fileSystem, root, hostname, port, urlTunneller);
61+ fileSystem, root, hostname, port, urlTunneller, _packageConfig );
5562 return Uri .parse ('http://$hostname :$port ' );
5663 }
5764
5865 Future <void > dispose () {
5966 fileSystem.currentDirectory = _savedCurrentDirectory;
60- return assetServer.close ();
67+ return assetServer? .close ();
6168 }
6269
6370 Future <UpdateFSReport > update ({
@@ -102,11 +109,9 @@ class WebDevFS {
102109 generator.reset ();
103110
104111 var compilerOutput = await generator.recompile (
105- 'org-dartlang-app:///$mainPath ' ,
106- invalidatedFiles,
107- outputPath: p.join (dillOutputPath, 'app.dill' ),
108- packagesFilePath: packagesFilePath,
109- );
112+ Uri .parse ('org-dartlang-app:///$mainPath ' ), invalidatedFiles,
113+ outputPath: p.join (dillOutputPath, 'app.dill' ),
114+ packageConfig: _packageConfig);
110115 if (compilerOutput == null || compilerOutput.errorCount > 0 ) {
111116 return UpdateFSReport (success: false );
112117 }
0 commit comments