[flutter_tools] Enable WebAssembly compilation everywhere, remove feature flag (#145562)

This commit is contained in:
Kevin Moore 2024-03-26 11:23:49 -07:00 committed by GitHub
parent 55528ba1b7
commit 388f3217e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 4 additions and 48 deletions

View file

@ -97,22 +97,18 @@ class BuildWebCommand extends BuildSubCommand {
);
//
// Experimental options
// WebAssembly compilation options
//
if (featureFlags.isFlutterWebWasmEnabled) {
argParser.addSeparator('Experimental options');
}
argParser.addSeparator('WebAssembly compilation options');
argParser.addFlag(
FlutterOptions.kWebWasmFlag,
help: 'Compile to WebAssembly rather than JavaScript.\n$kWasmMoreInfo',
negatable: false,
hide: !featureFlags.isFlutterWebWasmEnabled,
);
argParser.addFlag(
'strip-wasm',
help: 'Whether to strip the resulting wasm file of static symbol names.',
defaultsTo: true,
hide: !featureFlags.isFlutterWebWasmEnabled,
);
}
@ -148,16 +144,13 @@ class BuildWebCommand extends BuildSubCommand {
final List<WebCompilerConfig> compilerConfigs;
if (boolArg('wasm')) {
if (!featureFlags.isFlutterWebWasmEnabled) {
throwToolExit('Compiling to WebAssembly (wasm) is only available on the beta and master channels.');
}
if (stringArg(FlutterOptions.kWebRendererFlag) != argParser.defaultFor(FlutterOptions.kWebRendererFlag)) {
throwToolExit('"--${FlutterOptions.kWebRendererFlag}" cannot be combined with "--${FlutterOptions.kWebWasmFlag}"');
}
globals.logger.printBox(
title: 'Experimental feature',
title: 'New feature',
'''
WebAssembly compilation is experimental.
WebAssembly compilation is new. Understand the details before deploying to production.
$kWasmMoreInfo''',
);

View file

@ -12,7 +12,6 @@ import '../build_info.dart';
import '../bundle_builder.dart';
import '../devfs.dart';
import '../device.dart';
import '../features.dart';
import '../globals.dart' as globals;
import '../native_assets.dart';
import '../project.dart';
@ -240,7 +239,6 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
FlutterOptions.kWebWasmFlag,
help: 'Compile to WebAssembly rather than JavaScript.\n$kWasmMoreInfo',
negatable: false,
hide: !featureFlags.isFlutterWebWasmEnabled,
);
addDdsOptions(verboseHelp: verboseHelp);

View file

@ -42,9 +42,6 @@ abstract class FeatureFlags {
/// Whether custom devices are enabled.
bool get areCustomDevicesEnabled => false;
/// Whether WebAssembly compilation for Flutter Web is enabled.
bool get isFlutterWebWasmEnabled => false;
/// Whether animations are used in the command line interface.
bool get isCliAnimationEnabled => true;
@ -70,7 +67,6 @@ const List<Feature> allFeatures = <Feature>[
flutterIOSFeature,
flutterFuchsiaFeature,
flutterCustomDevicesFeature,
flutterWebWasm,
cliAnimation,
nativeAssets,
previewDevice,
@ -146,20 +142,6 @@ const Feature flutterCustomDevicesFeature = Feature(
),
);
/// Enabling WebAssembly compilation from `flutter build web`
const Feature flutterWebWasm = Feature(
name: 'WebAssembly compilation from flutter build web',
environmentOverride: 'FLUTTER_WEB_WASM',
beta: FeatureChannelSetting(
available: true,
enabledByDefault: true,
),
master: FeatureChannelSetting(
available: true,
enabledByDefault: true,
),
);
const String kCliAnimationsFeatureName = 'cli-animations';
/// The [Feature] for CLI animations.

View file

@ -44,9 +44,6 @@ class FlutterFeatureFlags implements FeatureFlags {
@override
bool get areCustomDevicesEnabled => isEnabled(flutterCustomDevicesFeature);
@override
bool get isFlutterWebWasmEnabled => isEnabled(flutterWebWasm);
@override
bool get isCliAnimationEnabled {
if (_platform.environment['TERM'] == 'dumb') {

View file

@ -81,12 +81,6 @@ void main() {
expect(featureFlags.isWebEnabled, true);
});
testWithoutContext('Flutter web wasm only enable on master', () {
expect(flutterWebWasm.getSettingForChannel('master').enabledByDefault, isTrue);
expect(flutterWebWasm.getSettingForChannel('beta').enabledByDefault, isTrue);
expect(flutterWebWasm.getSettingForChannel('stable').enabledByDefault, isFalse);
});
testWithoutContext('Flutter web help string', () {
expect(flutterWebFeature.generateHelpMessage(),
'Enable or disable Flutter for web.');

View file

@ -6,7 +6,6 @@ import 'dart:io';
import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/features.dart';
import '../src/common.dart';
import 'test_utils.dart';
@ -42,9 +41,6 @@ void main() {
'--wasm',
],
workingDirectory: exampleAppDir.path,
environment: <String, String>{
flutterWebWasm.environmentOverride!: 'true'
},
);
expect(result, const ProcessResultMatcher());

View file

@ -469,7 +469,6 @@ class TestFeatureFlags implements FeatureFlags {
this.isIOSEnabled = true,
this.isFuchsiaEnabled = false,
this.areCustomDevicesEnabled = false,
this.isFlutterWebWasmEnabled = false,
this.isCliAnimationEnabled = true,
this.isNativeAssetsEnabled = false,
this.isPreviewDeviceEnabled = false,
@ -499,9 +498,6 @@ class TestFeatureFlags implements FeatureFlags {
@override
final bool areCustomDevicesEnabled;
@override
final bool isFlutterWebWasmEnabled;
@override
final bool isCliAnimationEnabled;