Skip to content

Commit 099895a

Browse files
eyebrowsoffiregilnobrega
authored andcommitted
Changing the renderer on the web target should change its build key. (flutter#147003)
Changing the web renderer doesn't directly modify the environment's dart defines, and so doesn't do a full build invalidation. We need to include the web renderer in the build key for the compiler configuration. This information is used directly by the web targets to modify the dart defines that are passed into the compiler, so we need to rebuild if this information changes.
1 parent f5a3a05 commit 099895a

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

packages/flutter_tools/lib/src/web/compiler_config.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ sealed class WebCompilerConfig {
3838

3939
Map<String, dynamic> get _buildKeyMap => <String, dynamic>{
4040
'optimizationLevel': optimizationLevel,
41+
'webRenderer': renderer.name,
4142
};
4243
}
4344

packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,68 @@ void main() {
951951
}
952952
}
953953

954+
test('Dart2JSTarget has unique build keys for compiler configurations', () {
955+
const List<JsCompilerConfig> testConfigs = <JsCompilerConfig>[
956+
// Default values
957+
JsCompilerConfig(),
958+
959+
// Each individual property being made non-default
960+
JsCompilerConfig(csp: true),
961+
JsCompilerConfig(dumpInfo: true),
962+
JsCompilerConfig(nativeNullAssertions: true),
963+
JsCompilerConfig(optimizationLevel: 0),
964+
JsCompilerConfig(noFrequencyBasedMinification: true),
965+
JsCompilerConfig(sourceMaps: false),
966+
JsCompilerConfig(renderer: WebRendererMode.canvaskit),
967+
968+
// All properties non-default
969+
JsCompilerConfig(
970+
csp: true,
971+
dumpInfo: true,
972+
nativeNullAssertions: true,
973+
optimizationLevel: 0,
974+
noFrequencyBasedMinification: true,
975+
sourceMaps: false,
976+
renderer: WebRendererMode.canvaskit,
977+
),
978+
];
979+
980+
final Iterable<String> buildKeys = testConfigs.map((JsCompilerConfig config) {
981+
final Dart2JSTarget target = Dart2JSTarget(config);
982+
return target.buildKey;
983+
});
984+
985+
// Make sure all the build keys are unique.
986+
expect(buildKeys.toSet().length, buildKeys.length);
987+
});
988+
989+
test('Dart2Wasm has unique build keys for compiler configurations', () {
990+
const List<WasmCompilerConfig> testConfigs = <WasmCompilerConfig>[
991+
// Default values
992+
WasmCompilerConfig(),
993+
994+
// Each individual property being made non-default
995+
WasmCompilerConfig(optimizationLevel: 0),
996+
WasmCompilerConfig(renderer: WebRendererMode.canvaskit),
997+
WasmCompilerConfig(stripWasm: false),
998+
999+
// All properties non-default
1000+
WasmCompilerConfig(
1001+
optimizationLevel: 0,
1002+
stripWasm: false,
1003+
renderer: WebRendererMode.canvaskit,
1004+
),
1005+
];
1006+
1007+
final Iterable<String> buildKeys = testConfigs.map((WasmCompilerConfig config) {
1008+
final Dart2WasmTarget target = Dart2WasmTarget(config);
1009+
return target.buildKey;
1010+
});
1011+
1012+
// Make sure all the build keys are unique.
1013+
expect(buildKeys.toSet().length, buildKeys.length);
1014+
});
1015+
9541016
test('Generated service worker is empty with none-strategy', () => testbed.run(() {
9551017
final String fileGeneratorsPath =
9561018
environment.artifacts.getArtifactPath(Artifact.flutterToolsFileGenerators);

0 commit comments

Comments
 (0)