Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/flutter_tools/lib/src/build_system/targets/web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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});

Expand All @@ -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>[
const Source.hostArtifact(HostArtifact.flutterWebSdk),
];

@override
List<Source> get outputs => const <Source>[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}));
}