mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[flutter_tools] make gallery hot reload 5x faster with one neat trick (#56224)
This commit is contained in:
parent
c8c55b4098
commit
6d1966efcc
@ -74,7 +74,8 @@ class ManifestAssetBundle implements AssetBundle {
|
||||
final Map<String, DevFSContent> entries = <String, DevFSContent>{};
|
||||
|
||||
// If an asset corresponds to a wildcard directory, then it may have been
|
||||
// updated without changes to the manifest.
|
||||
// updated without changes to the manifest. These are only tracked for
|
||||
// the current project.
|
||||
final Map<Uri, Directory> _wildcardDirectories = <Uri, Directory>{};
|
||||
|
||||
final LicenseCollector licenseCollector = LicenseCollector(fileSystem: globals.fs);
|
||||
@ -203,7 +204,8 @@ class ManifestAssetBundle implements AssetBundle {
|
||||
final Map<_Asset, List<_Asset>> packageAssets = _parseAssets(
|
||||
packageConfig,
|
||||
packageFlutterManifest,
|
||||
wildcardDirectories,
|
||||
// Do not track wildcard directories for dependencies.
|
||||
<Uri>[],
|
||||
packageBasePath,
|
||||
packageName: package.name,
|
||||
);
|
||||
|
||||
@ -14,6 +14,7 @@ import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/devfs.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:platform/platform.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
import '../src/context.dart';
|
||||
@ -223,6 +224,48 @@ assets:
|
||||
FileSystem: () => MemoryFileSystem.test(),
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
|
||||
testUsingContext('does not track wildcard directories from dependencies', () async {
|
||||
globals.fs.file('.packages').writeAsStringSync(r'''
|
||||
example:lib/
|
||||
foo:foo/lib/
|
||||
''');
|
||||
globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt'))
|
||||
.createSync(recursive: true);
|
||||
globals.fs.file('pubspec.yaml')
|
||||
..createSync()
|
||||
..writeAsStringSync(r'''
|
||||
name: example
|
||||
dependencies:
|
||||
foo: any
|
||||
''');
|
||||
globals.fs.file('foo/pubspec.yaml')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync(r'''
|
||||
name: foo
|
||||
|
||||
flutter:
|
||||
assets:
|
||||
- bar/
|
||||
''');
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
globals.fs.file('foo/bar/fizz.txt').createSync(recursive: true);
|
||||
|
||||
await bundle.build(manifestPath: 'pubspec.yaml');
|
||||
|
||||
expect(bundle.entries, hasLength(4));
|
||||
expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false);
|
||||
|
||||
// Does not track dependency's wildcard directories.
|
||||
globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt'))
|
||||
.deleteSync();
|
||||
|
||||
expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => MemoryFileSystem.test(),
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
Platform: () => FakePlatform(operatingSystem: 'linux'),
|
||||
});
|
||||
}
|
||||
|
||||
class MockDirectory extends Mock implements Directory {}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user