Don't generate plugin registry in ResidentWebRunner (#91281)
* Don't generate plugin registry in ResidentWebRunner generateDartPluginRegistry was being set to true unconditionally in ResidentRunner, bypassing the primary check in DartPluginRegistrantTarget, and the targetPlatform was not set in that codepath, bypassing the second after the changes in https://github.com/flutter/flutter/pull/87991. This caused web hot restarts to be slower due to doing unnecessary work. This ensures that generateDartPluginRegistry is false in the ResidentWebRunner to skip that unnecessary step. Fixes https://github.com/flutter/flutter/issues/91262 * Formatting Co-authored-by: Zachary Anderson <zanderso@users.noreply.github.com> Co-authored-by: Zachary Anderson <zanderso@users.noreply.github.com>
This commit is contained in:
@@ -941,6 +941,47 @@ void main() {
|
||||
ProcessManager: () => processManager,
|
||||
});
|
||||
|
||||
// While this file should be ignored on web, generating it here will cause a
|
||||
// perf regression in hot restart.
|
||||
testUsingContext('Does not generate generated_main.dart', () async {
|
||||
// Create necessary files for [DartPluginRegistrantTarget]
|
||||
final File packageConfig = globals.fs.directory('.dart_tool')
|
||||
.childFile('package_config.json');
|
||||
packageConfig.createSync(recursive: true);
|
||||
packageConfig.writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
{
|
||||
"name": "path_provider_linux",
|
||||
"rootUri": "../../../path_provider_linux",
|
||||
"packageUri": "lib/",
|
||||
"languageVersion": "2.12"
|
||||
}
|
||||
]
|
||||
}
|
||||
''');
|
||||
// Start with a generated_main.dart file.
|
||||
globals.fs.directory('.dart_tool')
|
||||
.childDirectory('flutter_build')
|
||||
.childFile('generated_main.dart')
|
||||
.createSync(recursive: true);
|
||||
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory);
|
||||
|
||||
final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice);
|
||||
await residentWebRunner.runSourceGenerators();
|
||||
|
||||
// generated_main.dart should be untouched, indicating that its
|
||||
// generation didn't run. If it had run, the file would have been removed as
|
||||
// there are no plugins in the project.
|
||||
expect(project.dartPluginRegistrant.existsSync(), true);
|
||||
expect(project.dartPluginRegistrant.readAsStringSync(), '');
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
});
|
||||
|
||||
testUsingContext('Successfully turns WebSocketException into ToolExit', () async {
|
||||
final BufferLogger logger = BufferLogger.test();
|
||||
final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice, logger: logger);
|
||||
|
||||
Reference in New Issue
Block a user