[ddc] Don't let null sources invalidate the dart size

Null sources appear to come from files that contain only external
declarations. These sources can simply be ignored in the summation
of the sizes of dart files that make up a module.

Change-Id: I38864c7f4a3e208b19e26d5a887445fdf4622479
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184901
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
diff --git a/pkg/dev_compiler/lib/src/kernel/command.dart b/pkg/dev_compiler/lib/src/kernel/command.dart
index 550c6e1..4a7f62a 100644
--- a/pkg/dev_compiler/lib/src/kernel/command.dart
+++ b/pkg/dev_compiler/lib/src/kernel/command.dart
@@ -579,9 +579,7 @@
   return CompilerResult(0);
 }
 
-// Compute code size to embed in the generated JavaScript
-// for this module.  Return `null` to indicate when size could not be properly
-// computed for this module.
+/// Compute code size to embed in the generated JavaScript for this module.
 int _computeDartSize(Component component) {
   var dartSize = 0;
   var uriToSource = component.uriToSource;
@@ -589,7 +587,11 @@
     var libUri = lib.fileUri;
     var importUri = lib.importUri;
     var source = uriToSource[libUri];
-    if (source == null) return null;
+    if (source == null) {
+      // Sources that only contain external declarations have nothing to add to
+      // the sum.
+      continue;
+    }
     dartSize += source.source.length;
     for (var part in lib.parts) {
       var partUri = part.partUri;
@@ -599,7 +601,11 @@
       }
       var fileUri = libUri.resolve(partUri);
       var partSource = uriToSource[fileUri];
-      if (partSource == null) return null;
+      if (partSource == null) {
+        // Sources that only contain external declarations have nothing to add
+        // to the sum.
+        continue;
+      }
       dartSize += partSource.source.length;
     }
   }