Skip to content

Commit 1d766ed

Browse files
biggs0125natebiggs
andauthored
Add experimental hot reload flag support to flutter tools (flutter#162889)
Rather than ask users to pass the complicated and long string `--extra-front-end-options=--dartdevc-canary,--dartdevc-module-format=ddc` we want a simpler flag to enable the new DDC module system/hot reload. Technically this flag enables the new module system, not necessarily hot reload directly. But we only expect people to use the flag to enable hot reload so I've chosen the name based on that. --------- Co-authored-by: Nate Biggs <[email protected]>
1 parent 33a4c95 commit 1d766ed

File tree

6 files changed

+17
-24
lines changed

6 files changed

+17
-24
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ abstract final class FlutterOptions {
151151
static const String kWebBrowserFlag = 'web-browser-flag';
152152
static const String kWebResourcesCdnFlag = 'web-resources-cdn';
153153
static const String kWebWasmFlag = 'wasm';
154+
static const String kWebExperimentalHotReload = 'web-experimental-hot-reload';
154155
}
155156

156157
/// flutter command categories for usage.
@@ -336,6 +337,11 @@ abstract class FlutterCommand extends Command<void> {
336337
help: 'Enables expression evaluation in the debugger.',
337338
hide: !verboseHelp,
338339
);
340+
argParser.addFlag(
341+
FlutterOptions.kWebExperimentalHotReload,
342+
help: 'Enables new module format that supports hot reload.',
343+
hide: !verboseHelp,
344+
);
339345
argParser.addOption(
340346
'web-launch-url',
341347
help:
@@ -1328,6 +1334,12 @@ abstract class FlutterCommand extends Command<void> {
13281334
}
13291335
}
13301336

1337+
// TODO(natebiggs): Delete this when new DDC module system is the default.
1338+
if (argParser.options.containsKey(FlutterOptions.kWebExperimentalHotReload) &&
1339+
boolArg(FlutterOptions.kWebExperimentalHotReload)) {
1340+
extraFrontEndOptions.addAll(<String>['--dartdevc-canary', '--dartdevc-module-format=ddc']);
1341+
}
1342+
13311343
String? codeSizeDirectory;
13321344
if (argParser.options.containsKey(FlutterOptions.kAnalyzeSize) &&
13331345
boolArg(FlutterOptions.kAnalyzeSize)) {

packages/flutter_tools/test/web.shard/hot_reload_web_errors_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ import '../src/common.dart';
1111
void main() {
1212
testAll(
1313
chrome: true,
14-
additionalCommandArgs: <String>[
15-
'--extra-front-end-options=--dartdevc-canary,--dartdevc-module-format=ddc',
16-
],
14+
additionalCommandArgs: <String>['--web-experimental-hot-reload'],
1715
// TODO(srujzs): Remove this custom message once we have the delta inspector emitting the same
1816
// string as the VM.
1917
constClassFieldRemovalErrorMessage: 'Const class cannot remove fields',

packages/flutter_tools/test/web.shard/hot_reload_web_test.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,5 @@ import '../integration.shard/test_data/hot_reload_test_common.dart';
99
import '../src/common.dart';
1010

1111
void main() {
12-
testAll(
13-
chrome: true,
14-
additionalCommandArgs: <String>[
15-
'--extra-front-end-options=--dartdevc-canary,--dartdevc-module-format=ddc',
16-
],
17-
);
12+
testAll(chrome: true, additionalCommandArgs: <String>['--web-experimental-hot-reload']);
1813
}

packages/flutter_tools/test/web.shard/hot_reload_with_asset_web_test.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,5 @@ import '../integration.shard/test_data/hot_reload_with_asset_test_common.dart';
99
import '../src/common.dart';
1010

1111
void main() {
12-
testAll(
13-
chrome: true,
14-
additionalCommandArgs: <String>[
15-
'--extra-front-end-options=--dartdevc-canary,--dartdevc-module-format=ddc',
16-
],
17-
);
12+
testAll(chrome: true, additionalCommandArgs: <String>['--web-experimental-hot-reload']);
1813
}

packages/flutter_tools/test/web.shard/stateless_stateful_hot_reload_web_test.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,5 @@ import '../integration.shard/test_data/stateless_stateful_hot_reload_test_common
99
import '../src/common.dart';
1010

1111
void main() {
12-
testAll(
13-
chrome: true,
14-
additionalCommandArgs: <String>[
15-
'--extra-front-end-options=--dartdevc-canary,--dartdevc-module-format=ddc',
16-
],
17-
);
12+
testAll(chrome: true, additionalCommandArgs: <String>['--web-experimental-hot-reload']);
1813
}

packages/flutter_tools/test/web.shard/test_data/hot_restart_web_test_common.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ Future<void> _testProject(
7373
late FlutterRunTestDriver flutter;
7474

7575
final List<String> additionalCommandArgs =
76-
useDDCLibraryBundleFormat
77-
? <String>['--extra-front-end-options=--dartdevc-canary,--dartdevc-module-format=ddc']
78-
: <String>[];
76+
useDDCLibraryBundleFormat ? <String>['--web-experimental-hot-reload'] : <String>[];
7977
final String testName =
8078
'Hot restart (index.html: $name)'
8179
'${additionalCommandArgs.isEmpty ? '' : ' with args: $additionalCommandArgs'}';

0 commit comments

Comments
 (0)