[dartdevc] fix kernel backend summary to module mapping
The front_end code was sorting the summary URI list, which caused DDC to
find the wrong JS module import for a given summary (Components do not
store the URI they were loaded from, so DDC has to track that.)
Change-Id: Ief29c790d7303c8f290c6c669af2e1b34bc5bffb
Reviewed-on: https://dart-review.googlesource.com/c/84581
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Auto-Submit: Jenny Messerly <jmesserly@google.com>
diff --git a/pkg/dev_compiler/lib/src/kernel/command.dart b/pkg/dev_compiler/lib/src/kernel/command.dart
index 0d0dfa9..11958a0 100644
--- a/pkg/dev_compiler/lib/src/kernel/command.dart
+++ b/pkg/dev_compiler/lib/src/kernel/command.dart
@@ -217,8 +217,9 @@
var target = compilerState.options.target as DevCompilerTarget;
var compiler =
ProgramCompiler(component, target.hierarchy, options, declaredVariables);
- var jsModule =
- compiler.emitModule(component, result.inputSummaries, summaryModules);
+
+ var jsModule = compiler.emitModule(component, result.inputSummaries,
+ compilerState.options.inputSummaries, summaryModules);
// TODO(jmesserly): support for multiple output formats?
//
diff --git a/pkg/dev_compiler/lib/src/kernel/compiler.dart b/pkg/dev_compiler/lib/src/kernel/compiler.dart
index 3dbe8bd..6351180 100644
--- a/pkg/dev_compiler/lib/src/kernel/compiler.dart
+++ b/pkg/dev_compiler/lib/src/kernel/compiler.dart
@@ -235,16 +235,15 @@
bool get emitMetadata => options.emitMetadata;
JS.Program emitModule(Component component, List<Component> summaries,
- Map<Uri, String> summaryModules) {
+ List<Uri> summaryUris, Map<Uri, String> moduleImportForSummary) {
if (moduleItems.isNotEmpty) {
throw StateError('Can only call emitModule once.');
}
_component = component;
- var moduleImports = summaryModules.values.toList();
for (var i = 0; i < summaries.length; i++) {
var summary = summaries[i];
- var moduleImport = moduleImports[i];
+ var moduleImport = moduleImportForSummary[summaryUris[i]];
for (var l in summary.libraries) {
assert(!_importToSummary.containsKey(l));
_importToSummary[l] = summary;
diff --git a/pkg/dev_compiler/tool/kernel_sdk.dart b/pkg/dev_compiler/tool/kernel_sdk.dart
index bd401c2..feacbc7 100755
--- a/pkg/dev_compiler/tool/kernel_sdk.dart
+++ b/pkg/dev_compiler/tool/kernel_sdk.dart
@@ -56,7 +56,7 @@
component,
target.hierarchy,
SharedCompilerOptions(moduleName: 'dart_sdk'),
- {}).emitModule(component, [], {});
+ {}).emitModule(component, [], [], {});
var moduleFormats = {
'amd': ModuleFormat.amd,
'common': ModuleFormat.common,