make hot reload reflect changes to asset transformer configurations (#144660)

In service of https://github.com/flutter/flutter/issues/143348

This PR makes hot reloads reflect changes to transformer configurations under the `assets` section in pubspec.yaml.
This PR is optimized for ease of implementation, and should not be merged as-is. If it is merged as-is, seriously consider creating a tech debt issue and assigning it to someone to make sure it gets resolved.
This commit is contained in:
Andrew Kolos
2024-03-24 21:13:11 -07:00
committed by GitHub
parent a5cf4191dc
commit cd785544fa
2 changed files with 84 additions and 6 deletions

View File

@@ -428,6 +428,73 @@ flutter:
),
);
});
testWithoutContext("AssetBundleEntry::content::isModified is true when an asset's transformers change in between builds", () async {
final FileSystem fileSystem = MemoryFileSystem.test();
fileSystem.file('my-asset.txt').createSync();
final BufferLogger logger = BufferLogger.test();
final FakePlatform platform = FakePlatform();
fileSystem.file('.packages').createSync();
fileSystem.file('pubspec.yaml')
..createSync()
..writeAsStringSync(r'''
name: example
flutter:
assets:
- path: my-asset.txt
transformers:
- package: my-transformer-one
''');
final ManifestAssetBundle bundle = ManifestAssetBundle(
logger: logger,
fileSystem: fileSystem,
platform: platform,
flutterRoot: Cache.defaultFlutterRoot(
platform: platform,
fileSystem: fileSystem,
userMessages: UserMessages(),
),
);
await bundle.build(
packagesPath: '.packages',
flutterProject: FlutterProject.fromDirectoryTest(
fileSystem.currentDirectory,
),
);
expect(bundle.entries['my-asset.txt']!.content.isModified, isTrue);
await bundle.build(
packagesPath: '.packages',
flutterProject: FlutterProject.fromDirectoryTest(
fileSystem.currentDirectory,
),
);
expect(bundle.entries['my-asset.txt']!.content.isModified, isFalse);
fileSystem.file('pubspec.yaml').writeAsStringSync(r'''
name: example
flutter:
assets:
- path: my-asset.txt
transformers:
- package: my-transformer-one
- package: my-transformer-two
''');
await bundle.build(
packagesPath: '.packages',
flutterProject: FlutterProject.fromDirectoryTest(
fileSystem.currentDirectory,
),
);
expect(bundle.entries['my-asset.txt']!.content.isModified, isTrue);
});
});
group('AssetBundle.build (web builds)', () {