flutter tool: add experimental output during wasm build (#124166)
This commit is contained in:
@@ -11,7 +11,7 @@ import '../globals.dart' as globals;
|
||||
import '../html_utils.dart';
|
||||
import '../project.dart';
|
||||
import '../runner/flutter_command.dart'
|
||||
show DevelopmentArtifact, FlutterCommandResult;
|
||||
show DevelopmentArtifact, FlutterCommandResult, FlutterOptions;
|
||||
import '../web/compile.dart';
|
||||
import 'build.dart';
|
||||
|
||||
@@ -98,14 +98,14 @@ class BuildWebCommand extends BuildSubCommand {
|
||||
if (featureFlags.isFlutterWebWasmEnabled) {
|
||||
argParser.addSeparator('Experimental options');
|
||||
argParser.addFlag(
|
||||
'wasm',
|
||||
help: 'Compile to WebAssembly rather than JavaScript.',
|
||||
FlutterOptions.kWebWasmFlag,
|
||||
help: 'Compile to WebAssembly rather than JavaScript.\nSee $kWasmPreviewUri for more information.',
|
||||
negatable: false,
|
||||
);
|
||||
} else {
|
||||
// Add the flag as hidden. Will give a helpful error message in [runCommand] below.
|
||||
argParser.addFlag(
|
||||
'wasm',
|
||||
FlutterOptions.kWebWasmFlag,
|
||||
hide: true,
|
||||
);
|
||||
}
|
||||
@@ -134,7 +134,7 @@ class BuildWebCommand extends BuildSubCommand {
|
||||
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) {
|
||||
throwToolExit('Compiling to WebAssembly (wasm) is only available on the master channel.');
|
||||
}
|
||||
|
||||
@@ -126,6 +126,7 @@ class FlutterOptions {
|
||||
static const String kWebBrowserFlag = 'web-browser-flag';
|
||||
static const String kWebRendererFlag = 'web-renderer';
|
||||
static const String kWebResourcesCdnFlag = 'web-resources-cdn';
|
||||
static const String kWebWasmFlag = 'wasm';
|
||||
}
|
||||
|
||||
/// flutter command categories for usage.
|
||||
|
||||
@@ -56,6 +56,15 @@ class WebBuilder {
|
||||
bool noFrequencyBasedMinification = false,
|
||||
String? outputDirectoryPath,
|
||||
}) async {
|
||||
if (isWasm) {
|
||||
globals.logger.printBox(
|
||||
title: 'Experimental feature',
|
||||
'''
|
||||
WebAssembly compilation is experimental.
|
||||
See $kWasmPreviewUri for more information.''',
|
||||
);
|
||||
}
|
||||
|
||||
final bool hasWebPlugins =
|
||||
(await findPlugins(flutterProject)).any((Plugin p) => p.platforms.containsKey(WebPlugin.kConfigKey));
|
||||
final Directory outputDirectory = outputDirectoryPath == null
|
||||
@@ -165,3 +174,5 @@ const Map<WebRendererMode, Map<NullSafetyMode, HostArtifact>> kDartSdkJsMapArtif
|
||||
NullSafetyMode.unsound: HostArtifact.webPrecompiledSdkSourcemaps,
|
||||
},
|
||||
};
|
||||
|
||||
const String kWasmPreviewUri = 'https://flutter.dev/wasm';
|
||||
|
||||
Reference in New Issue
Block a user