Unverified Commit f3e8ae7d authored by Kevin Moore's avatar Kevin Moore Committed by GitHub

flutter tool: add experimental output during wasm build (#124166)

parent 667220c9
...@@ -11,7 +11,7 @@ import '../globals.dart' as globals; ...@@ -11,7 +11,7 @@ import '../globals.dart' as globals;
import '../html_utils.dart'; import '../html_utils.dart';
import '../project.dart'; import '../project.dart';
import '../runner/flutter_command.dart' import '../runner/flutter_command.dart'
show DevelopmentArtifact, FlutterCommandResult; show DevelopmentArtifact, FlutterCommandResult, FlutterOptions;
import '../web/compile.dart'; import '../web/compile.dart';
import 'build.dart'; import 'build.dart';
...@@ -98,14 +98,14 @@ class BuildWebCommand extends BuildSubCommand { ...@@ -98,14 +98,14 @@ class BuildWebCommand extends BuildSubCommand {
if (featureFlags.isFlutterWebWasmEnabled) { if (featureFlags.isFlutterWebWasmEnabled) {
argParser.addSeparator('Experimental options'); argParser.addSeparator('Experimental options');
argParser.addFlag( argParser.addFlag(
'wasm', FlutterOptions.kWebWasmFlag,
help: 'Compile to WebAssembly rather than JavaScript.', help: 'Compile to WebAssembly rather than JavaScript.\nSee $kWasmPreviewUri for more information.',
negatable: false, negatable: false,
); );
} else { } else {
// Add the flag as hidden. Will give a helpful error message in [runCommand] below. // Add the flag as hidden. Will give a helpful error message in [runCommand] below.
argParser.addFlag( argParser.addFlag(
'wasm', FlutterOptions.kWebWasmFlag,
hide: true, hide: true,
); );
} }
...@@ -134,7 +134,7 @@ class BuildWebCommand extends BuildSubCommand { ...@@ -134,7 +134,7 @@ class BuildWebCommand extends BuildSubCommand {
throwToolExit('"build web" is not currently supported. To enable, run "flutter config --enable-web".'); throwToolExit('"build web" is not currently supported. To enable, run "flutter config --enable-web".');
} }
final bool wasmRequested = boolArg('wasm'); final bool wasmRequested = boolArg(FlutterOptions.kWebWasmFlag);
if (wasmRequested && !featureFlags.isFlutterWebWasmEnabled) { if (wasmRequested && !featureFlags.isFlutterWebWasmEnabled) {
throwToolExit('Compiling to WebAssembly (wasm) is only available on the master channel.'); throwToolExit('Compiling to WebAssembly (wasm) is only available on the master channel.');
} }
......
...@@ -126,6 +126,7 @@ class FlutterOptions { ...@@ -126,6 +126,7 @@ class FlutterOptions {
static const String kWebBrowserFlag = 'web-browser-flag'; static const String kWebBrowserFlag = 'web-browser-flag';
static const String kWebRendererFlag = 'web-renderer'; static const String kWebRendererFlag = 'web-renderer';
static const String kWebResourcesCdnFlag = 'web-resources-cdn'; static const String kWebResourcesCdnFlag = 'web-resources-cdn';
static const String kWebWasmFlag = 'wasm';
} }
/// flutter command categories for usage. /// flutter command categories for usage.
......
...@@ -56,6 +56,15 @@ class WebBuilder { ...@@ -56,6 +56,15 @@ class WebBuilder {
bool noFrequencyBasedMinification = false, bool noFrequencyBasedMinification = false,
String? outputDirectoryPath, String? outputDirectoryPath,
}) async { }) async {
if (isWasm) {
globals.logger.printBox(
title: 'Experimental feature',
'''
WebAssembly compilation is experimental.
See $kWasmPreviewUri for more information.''',
);
}
final bool hasWebPlugins = final bool hasWebPlugins =
(await findPlugins(flutterProject)).any((Plugin p) => p.platforms.containsKey(WebPlugin.kConfigKey)); (await findPlugins(flutterProject)).any((Plugin p) => p.platforms.containsKey(WebPlugin.kConfigKey));
final Directory outputDirectory = outputDirectoryPath == null final Directory outputDirectory = outputDirectoryPath == null
...@@ -165,3 +174,5 @@ const Map<WebRendererMode, Map<NullSafetyMode, HostArtifact>> kDartSdkJsMapArtif ...@@ -165,3 +174,5 @@ const Map<WebRendererMode, Map<NullSafetyMode, HostArtifact>> kDartSdkJsMapArtif
NullSafetyMode.unsound: HostArtifact.webPrecompiledSdkSourcemaps, NullSafetyMode.unsound: HostArtifact.webPrecompiledSdkSourcemaps,
}, },
}; };
const String kWasmPreviewUri = 'https://flutter.dev/wasm';
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment