Unverified Commit e6fa5717 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

fix release web builds where the target file is not under lib (#46179)

parent e3005e69
...@@ -68,11 +68,10 @@ class WebEntrypointTarget extends Target { ...@@ -68,11 +68,10 @@ class WebEntrypointTarget extends Target {
); );
// By construction, this will only be null if the .packages file does not // By construction, this will only be null if the .packages file does not
// have an entry for the user's application. // have an entry for the user's application or if the main file is
final Uri mainImport = packageUriMapper.map(importPath); // outside of the lib/ directory.
if (mainImport == null) { final String mainImport = packageUriMapper.map(importPath)?.toString()
throw Exception('Missing package definition for $mainImport'); ?? fs.file(importPath).absolute.uri.toString();
}
String contents; String contents;
if (hasPlugins) { if (hasPlugins) {
......
...@@ -76,6 +76,17 @@ void main() { ...@@ -76,6 +76,17 @@ void main() {
expect(generated, contains("import 'package:foo/main.dart' as entrypoint;")); expect(generated, contains("import 'package:foo/main.dart' as entrypoint;"));
})); }));
test('WebEntrypointTarget generates an entrypoint for a file outside of main', () => testbed.run(() async {
environment.defines[kTargetFile] = fs.path.join('other', 'lib', 'main.dart');
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;"));
}));
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';
environment.defines[kInitializePlatform] = 'true'; environment.defines[kInitializePlatform] = '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