[tool,web] Include more info URI on Wasm init failure (#125312)

This commit is contained in:
Kevin Moore
2023-04-24 11:33:21 -07:00
committed by GitHub
parent 9e2e64c7c0
commit 034adb66cc
4 changed files with 12 additions and 4 deletions

View File

@@ -14,6 +14,7 @@ import '../runner/flutter_command.dart'
show DevelopmentArtifact, FlutterCommandResult, FlutterOptions;
import '../web/compile.dart';
import '../web/file_generators/flutter_service_worker_js.dart';
import '../web/web_constants.dart';
import 'build.dart';
class BuildWebCommand extends BuildSubCommand {
@@ -91,7 +92,7 @@ class BuildWebCommand extends BuildSubCommand {
}
argParser.addFlag(
FlutterOptions.kWebWasmFlag,
help: 'Compile to WebAssembly rather than JavaScript.\nSee $kWasmPreviewUri for more information.',
help: 'Compile to WebAssembly rather than JavaScript.\n$kWasmMoreInfo',
negatable: false,
hide: !featureFlags.isFlutterWebWasmEnabled,
);

View File

@@ -24,6 +24,7 @@ import '../version.dart';
import 'compiler_config.dart';
import 'file_generators/flutter_service_worker_js.dart';
import 'migrations/scrub_generated_plugin_registrant.dart';
import 'web_constants.dart';
export 'compiler_config.dart';
@@ -63,7 +64,7 @@ class WebBuilder {
title: 'Experimental feature',
'''
WebAssembly compilation is experimental.
See $kWasmPreviewUri for more information.''',
$kWasmMoreInfo''',
);
}
@@ -224,8 +225,6 @@ const Map<WebRendererMode, Map<NullSafetyMode, HostArtifact>> kDartSdkJsMapArtif
},
};
const String kWasmPreviewUri = 'https://flutter.dev/wasm';
String _buildEventAnalyticsSettings({
required WebCompilerConfig config,
required BuildInfo buildInfo,

View File

@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import '../web_constants.dart';
String generateWasmBootstrapFile(bool isSkwasm) {
return '''
// Copyright 2014 The Flutter Authors. All rights reserved.
@@ -18,6 +20,7 @@ String generateWasmBootstrapFile(bool isSkwasm) {
moduleInstance = await dart2wasm_runtime.instantiate(dartModulePromise, imports);
} catch (exception) {
console.error(`Failed to fetch and instantiate wasm module: \${exception}`);
console.error('$kWasmMoreInfo');
}
if (moduleInstance) {

View File

@@ -0,0 +1,5 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
const String kWasmMoreInfo = 'See https://flutter.dev/wasm for more information.';