Invalidate the WebStaticAssets target if the web sdk changes. (#123739)

Invalidate the `WebStaticAssets` target if the web sdk changes.
This commit is contained in:
Jackson Gardner 2023-03-29 19:20:19 -07:00 committed by GitHub
parent 06f015a8c0
commit b57c59b4a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 3 deletions

View file

@ -494,8 +494,8 @@ class WebReleaseBundle extends Target {
/// Static assets provided by the Flutter SDK that do not change, such as
/// CanvasKit.
///
/// These assets can be cached forever and are only invalidated when the
/// Flutter SDK is upgraded to a new version.
/// These assets can be cached until a new version of the flutter web sdk is
/// downloaded.
class WebBuiltInAssets extends Target {
const WebBuiltInAssets(this.fileSystem, {required this.isWasm});
@ -512,7 +512,9 @@ class WebBuiltInAssets extends Target {
List<String> get depfiles => const <String>[];
@override
List<Source> get inputs => const <Source>[];
List<Source> get inputs => const <Source>[
Source.hostArtifact(HostArtifact.flutterWebSdk),
];
@override
List<Source> get outputs => const <Source>[];

View file

@ -946,4 +946,26 @@ void main() {
.childFile('canvaskit.wasm')
.existsSync(), true);
}));
test('wasm copies over canvaskit again if the web sdk changes', () => testbed.run(() async {
final File canvasKitInput = globals.fs.file('bin/cache/flutter_web_sdk/canvaskit/canvaskit.wasm')
..createSync(recursive: true);
canvasKitInput.writeAsStringSync('foo', flush: true);
await WebBuiltInAssets(globals.fs, isWasm: true).build(environment);
final File canvasKitOutputBefore = environment.outputDir.childDirectory('canvaskit')
.childFile('canvaskit.wasm');
expect(canvasKitOutputBefore.existsSync(), true);
expect(canvasKitOutputBefore.readAsStringSync(), 'foo');
canvasKitInput.writeAsStringSync('bar', flush: true);
await WebBuiltInAssets(globals.fs, isWasm: true).build(environment);
final File canvasKitOutputAfter = environment.outputDir.childDirectory('canvaskit')
.childFile('canvaskit.wasm');
expect(canvasKitOutputAfter.existsSync(), true);
expect(canvasKitOutputAfter.readAsStringSync(), 'bar');
}));
}