diff --git a/packages/flutter_tools/lib/src/web/compiler_config.dart b/packages/flutter_tools/lib/src/web/compiler_config.dart index 352baa5b0e..7f868bb1d6 100644 --- a/packages/flutter_tools/lib/src/web/compiler_config.dart +++ b/packages/flutter_tools/lib/src/web/compiler_config.dart @@ -38,6 +38,7 @@ sealed class WebCompilerConfig { Map get _buildKeyMap => { 'optimizationLevel': optimizationLevel, + 'webRenderer': renderer.name, }; } diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart index 6afa297992..54c246248f 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart @@ -951,6 +951,68 @@ void main() { } } + test('Dart2JSTarget has unique build keys for compiler configurations', () { + const List testConfigs = [ + // Default values + JsCompilerConfig(), + + // Each individual property being made non-default + JsCompilerConfig(csp: true), + JsCompilerConfig(dumpInfo: true), + JsCompilerConfig(nativeNullAssertions: true), + JsCompilerConfig(optimizationLevel: 0), + JsCompilerConfig(noFrequencyBasedMinification: true), + JsCompilerConfig(sourceMaps: false), + JsCompilerConfig(renderer: WebRendererMode.canvaskit), + + // All properties non-default + JsCompilerConfig( + csp: true, + dumpInfo: true, + nativeNullAssertions: true, + optimizationLevel: 0, + noFrequencyBasedMinification: true, + sourceMaps: false, + renderer: WebRendererMode.canvaskit, + ), + ]; + + final Iterable buildKeys = testConfigs.map((JsCompilerConfig config) { + final Dart2JSTarget target = Dart2JSTarget(config); + return target.buildKey; + }); + + // Make sure all the build keys are unique. + expect(buildKeys.toSet().length, buildKeys.length); + }); + + test('Dart2Wasm has unique build keys for compiler configurations', () { + const List testConfigs = [ + // Default values + WasmCompilerConfig(), + + // Each individual property being made non-default + WasmCompilerConfig(optimizationLevel: 0), + WasmCompilerConfig(renderer: WebRendererMode.canvaskit), + WasmCompilerConfig(stripWasm: false), + + // All properties non-default + WasmCompilerConfig( + optimizationLevel: 0, + stripWasm: false, + renderer: WebRendererMode.canvaskit, + ), + ]; + + final Iterable buildKeys = testConfigs.map((WasmCompilerConfig config) { + final Dart2WasmTarget target = Dart2WasmTarget(config); + return target.buildKey; + }); + + // Make sure all the build keys are unique. + expect(buildKeys.toSet().length, buildKeys.length); + }); + test('Generated service worker is empty with none-strategy', () => testbed.run(() { final String fileGeneratorsPath = environment.artifacts.getArtifactPath(Artifact.flutterToolsFileGenerators);