Commit dc084b90 authored by Jonah Williams's avatar Jonah Williams Committed by Flutter GitHub Bot

[flutter_tools] handle plugins for entrypoints outside of main (#49459)

parent f9908f54
...@@ -83,7 +83,8 @@ class WebEntrypointTarget extends Target { ...@@ -83,7 +83,8 @@ class WebEntrypointTarget extends Target {
.childDirectory('lib') .childDirectory('lib')
.childFile('generated_plugin_registrant.dart') .childFile('generated_plugin_registrant.dart')
.absolute.path; .absolute.path;
final Uri generatedImport = packageUriMapper.map(generatedPath); final String generatedImport = packageUriMapper.map(generatedPath)?.toString()
?? globals.fs.file(generatedPath).absolute.uri.toString();
contents = ''' contents = '''
import 'dart:ui' as ui; import 'dart:ui' as ui;
......
...@@ -117,6 +117,18 @@ void main() { ...@@ -117,6 +117,18 @@ void main() {
expect(generated, contains("import 'file:///other/lib/main.dart' as entrypoint;")); expect(generated, contains("import 'file:///other/lib/main.dart' as entrypoint;"));
})); }));
test('WebEntrypointTarget generates a plugin registrant for a file outside of main', () => testbed.run(() async {
environment.defines[kTargetFile] = globals.fs.path.join('other', 'lib', 'main.dart');
environment.defines[kHasWebPlugins] = 'true';
await const WebEntrypointTarget().build(environment);
final String generated = environment.buildDir.childFile('main.dart').readAsStringSync();
// Import.
expect(generated, contains("import 'file:///other/lib/main.dart' as entrypoint;"));
expect(generated, contains("import 'file:///foo/lib/generated_plugin_registrant.dart';"));
}));
test('WebEntrypointTarget generates an entrypoint with plugins and init platform on windows', () => testbed.run(() async { test('WebEntrypointTarget generates an entrypoint with plugins and init platform on windows', () => testbed.run(() async {
environment.defines[kHasWebPlugins] = 'true'; environment.defines[kHasWebPlugins] = 'true';
......
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