Unverified Commit bc1c1b2f authored by Anna Gringauze's avatar Anna Gringauze Committed by GitHub

Add flag to enable expression evaluation for web (#55003)

* Add flag to enable expression evaluation for web

Added flag --web-enable-expression-evaluation to flutter run commmand
that enables expression evaluation from IDEs for web target. Disabled
by default.

Helps https://github.com/flutter/flutter/issues/54520

* Update packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart
Co-Authored-By: 's avatarJonah Williams <jonahwilliams@google.com>
Co-authored-by: 's avatarJonah Williams <jonahwilliams@google.com>
parent b69b2a8c
......@@ -418,6 +418,11 @@ class _ResidentWebRunner extends ResidentWebRunner {
directory: globals.fs.path.join(Cache.flutterRoot, 'packages', 'flutter_tools')
);
final ExpressionCompiler expressionCompiler =
debuggingOptions.webEnableExpressionEvaluation
? WebExpressionCompiler(device.generator)
: null;
device.devFS = WebDevFS(
hostname: effectiveHostname,
port: hostPort,
......@@ -427,7 +432,7 @@ class _ResidentWebRunner extends ResidentWebRunner {
buildMode: debuggingOptions.buildInfo.mode,
enableDwds: _enableDwds,
entrypoint: globals.fs.file(target).uri,
expressionCompiler: WebExpressionCompiler(device.generator),
expressionCompiler: expressionCompiler,
);
final Uri url = await device.devFS.create();
if (debuggingOptions.buildInfo.isDebug) {
......
......@@ -382,6 +382,7 @@ class RunCommand extends RunCommandBase {
webEnableExposeUrl: featureFlags.isWebEnabled && boolArg('web-allow-expose-url'),
webRunHeadless: featureFlags.isWebEnabled && boolArg('web-run-headless'),
webBrowserDebugPort: browserDebugPort,
webEnableExpressionEvaluation: featureFlags.isWebEnabled && boolArg('web-enable-expression-evaluation'),
vmserviceOutFile: stringArg('vmservice-out-file'),
// Allow forcing fast-start to off to prevent doing more work on devices that
// don't support it.
......
......@@ -610,6 +610,7 @@ class DebuggingOptions {
this.webUseSseForDebugProxy = true,
this.webRunHeadless = false,
this.webBrowserDebugPort,
this.webEnableExpressionEvaluation = false,
this.vmserviceOutFile,
this.fastStart = false,
}) : debuggingEnabled = true;
......@@ -639,7 +640,8 @@ class DebuggingOptions {
hostVmServicePort = null,
deviceVmServicePort = null,
vmserviceOutFile = null,
fastStart = false;
fastStart = false,
webEnableExpressionEvaluation = false;
final bool debuggingEnabled;
......@@ -676,6 +678,9 @@ class DebuggingOptions {
/// The port the browser should use for its debugging protocol.
final int webBrowserDebugPort;
/// Enable expression evaluation for web target
final bool webEnableExpressionEvaluation;
/// A file where the vmservice URL should be written after the application is started.
final String vmserviceOutFile;
final bool fastStart;
......
......@@ -199,6 +199,11 @@ abstract class FlutterCommand extends Command<void> {
'(https://chromedevtools.github.io/devtools-protocol/).',
hide: true,
);
argParser.addFlag('web-enable-expression-evaluation',
defaultsTo: false,
help: 'Enables expression evaluation in the debugger.',
hide: hide,
);
}
void usesTargetOption() {
......
......@@ -448,7 +448,7 @@ class FlutterRunTestDriver extends FlutterTestDriver {
'--machine',
'-d',
if (chrome)
...<String>['chrome', '--web-run-headless']
...<String>['chrome', '--web-run-headless', '--web-enable-expression-evaluation']
else
'flutter-tester',
],
......
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