Unverified Commit 412e4dd5 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] migrate devfs web to package_config (#54299)

parent dbecf2af
......@@ -10,12 +10,7 @@ import 'package:dwds/dwds.dart';
import 'package:logging/logging.dart';
import 'package:meta/meta.dart';
import 'package:mime/mime.dart' as mime;
// TODO(bkonyi): remove deprecated member usage, https://github.com/flutter/flutter/issues/51951
// ignore: deprecated_member_use
import 'package:package_config/discovery.dart';
// TODO(bkonyi): remove deprecated member usage, https://github.com/flutter/flutter/issues/51951
// ignore: deprecated_member_use
import 'package:package_config/packages.dart';
import 'package:package_config/package_config.dart';
import 'package:shelf/shelf.dart' as shelf;
import 'package:shelf/shelf_io.dart' as shelf;
......@@ -31,6 +26,7 @@ import '../bundle.dart';
import '../cache.dart';
import '../compile.dart';
import '../convert.dart';
import '../dart/package_map.dart';
import '../devfs.dart';
import '../globals.dart' as globals;
import '../web/bootstrap.dart';
......@@ -142,15 +138,21 @@ class WebAssetServer implements AssetReader {
try {
final InternetAddress address = (await InternetAddress.lookup(hostname)).first;
final HttpServer httpServer = await HttpServer.bind(address, port);
// TODO(bkonyi): remove deprecated member usage, https://github.com/flutter/flutter/issues/51951
// ignore: deprecated_member_use
final Packages packages = await loadPackagesFile(
Uri.base.resolve('.packages'), loader: (Uri uri) => globals.fs.file(uri).readAsBytes());
final PackageConfig packageConfig = await loadPackageConfigUri(
globals.fs.file(PackageMap.globalPackagesPath).absolute.uri,
loader: (Uri uri) {
final File file = globals.fs.file(uri);
if (!file.existsSync()) {
return null;
}
return file.readAsBytes();
}
);
final Map<String, String> digests = <String, String>{};
final Map<String, String> modules = <String, String>{};
final WebAssetServer server = WebAssetServer(
httpServer,
packages,
packageConfig,
address,
modules,
digests,
......@@ -248,9 +250,7 @@ class WebAssetServer implements AssetReader {
// RandomAccessFile and read on demand.
final Map<String, Uint8List> _files = <String, Uint8List>{};
final Map<String, Uint8List> _sourcemaps = <String, Uint8List>{};
// TODO(bkonyi): remove deprecated member usage, https://github.com/flutter/flutter/issues/51951
// ignore: deprecated_member_use
final Packages _packages;
final PackageConfig _packages;
final InternetAddress internetAddress;
/* late final */ Dwds dwds;
Directory entrypointCacheDirectory;
......
......@@ -18,12 +18,7 @@ import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/build_runner/devfs_web.dart';
import 'package:logging/logging.dart';
import 'package:mockito/mockito.dart';
// TODO(bkonyi): remove deprecated member usage, https://github.com/flutter/flutter/issues/51951
// ignore: deprecated_member_use
import 'package:package_config/discovery.dart';
// TODO(bkonyi): remove deprecated member usage, https://github.com/flutter/flutter/issues/51951
// ignore: deprecated_member_use
import 'package:package_config/packages.dart';
import 'package:package_config/package_config.dart';
import 'package:platform/platform.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:shelf/shelf.dart';
......@@ -43,14 +38,12 @@ void main() {
Testbed testbed;
WebAssetServer webAssetServer;
Platform linux;
// TODO(bkonyi): remove deprecated member usage, https://github.com/flutter/flutter/issues/51951
// ignore: deprecated_member_use
Packages packages;
PackageConfig packages;
Platform windows;
MockHttpServer mockHttpServer;
setUpAll(() async {
packages = await loadPackagesFile(Uri.base.resolve('.packages'));
packages = await loadPackageConfigUri(Uri.base.resolve('.packages'));
});
setUp(() {
......@@ -354,6 +347,7 @@ void main() {
}));
test('Can start web server with specified assets', () => testbed.run(() async {
globals.fs.file('.packages').writeAsStringSync('\n');
final File outputFile = globals.fs.file(globals.fs.path.join('lib', 'main.dart'))
..createSync(recursive: true);
outputFile.parent.childFile('a.sources').writeAsStringSync('');
......@@ -442,6 +436,7 @@ void main() {
}));
test('Launches DWDS with the correct arguments', () => testbed.run(() async {
globals.fs.file('.packages').writeAsStringSync('\n');
final WebAssetServer server = await WebAssetServer.start(
'localhost',
8123,
......
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