Skip to content

Commit f3e8ae7

Browse files
authored
flutter tool: add experimental output during wasm build (#124166)
1 parent 667220c commit f3e8ae7

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

packages/flutter_tools/lib/src/commands/build_web.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import '../globals.dart' as globals;
1111
import '../html_utils.dart';
1212
import '../project.dart';
1313
import '../runner/flutter_command.dart'
14-
show DevelopmentArtifact, FlutterCommandResult;
14+
show DevelopmentArtifact, FlutterCommandResult, FlutterOptions;
1515
import '../web/compile.dart';
1616
import 'build.dart';
1717

@@ -98,14 +98,14 @@ class BuildWebCommand extends BuildSubCommand {
9898
if (featureFlags.isFlutterWebWasmEnabled) {
9999
argParser.addSeparator('Experimental options');
100100
argParser.addFlag(
101-
'wasm',
102-
help: 'Compile to WebAssembly rather than JavaScript.',
101+
FlutterOptions.kWebWasmFlag,
102+
help: 'Compile to WebAssembly rather than JavaScript.\nSee $kWasmPreviewUri for more information.',
103103
negatable: false,
104104
);
105105
} else {
106106
// Add the flag as hidden. Will give a helpful error message in [runCommand] below.
107107
argParser.addFlag(
108-
'wasm',
108+
FlutterOptions.kWebWasmFlag,
109109
hide: true,
110110
);
111111
}
@@ -134,7 +134,7 @@ class BuildWebCommand extends BuildSubCommand {
134134
throwToolExit('"build web" is not currently supported. To enable, run "flutter config --enable-web".');
135135
}
136136

137-
final bool wasmRequested = boolArg('wasm');
137+
final bool wasmRequested = boolArg(FlutterOptions.kWebWasmFlag);
138138
if (wasmRequested && !featureFlags.isFlutterWebWasmEnabled) {
139139
throwToolExit('Compiling to WebAssembly (wasm) is only available on the master channel.');
140140
}

packages/flutter_tools/lib/src/runner/flutter_command.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ class FlutterOptions {
126126
static const String kWebBrowserFlag = 'web-browser-flag';
127127
static const String kWebRendererFlag = 'web-renderer';
128128
static const String kWebResourcesCdnFlag = 'web-resources-cdn';
129+
static const String kWebWasmFlag = 'wasm';
129130
}
130131

131132
/// flutter command categories for usage.

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ class WebBuilder {
5656
bool noFrequencyBasedMinification = false,
5757
String? outputDirectoryPath,
5858
}) async {
59+
if (isWasm) {
60+
globals.logger.printBox(
61+
title: 'Experimental feature',
62+
'''
63+
WebAssembly compilation is experimental.
64+
See $kWasmPreviewUri for more information.''',
65+
);
66+
}
67+
5968
final bool hasWebPlugins =
6069
(await findPlugins(flutterProject)).any((Plugin p) => p.platforms.containsKey(WebPlugin.kConfigKey));
6170
final Directory outputDirectory = outputDirectoryPath == null
@@ -165,3 +174,5 @@ const Map<WebRendererMode, Map<NullSafetyMode, HostArtifact>> kDartSdkJsMapArtif
165174
NullSafetyMode.unsound: HostArtifact.webPrecompiledSdkSourcemaps,
166175
},
167176
};
177+
178+
const String kWasmPreviewUri = 'https://flutter.dev/wasm';

0 commit comments

Comments
 (0)