[dartdevc] fix debugger extension console, take 2

This change fixes the (internal) debugger console test so it passes.

A few of the fixes did not make it into the previous CL
(CL https://dart-review.googlesource.com/c/sdk/+/83140).

Change-Id: I58df9024b96e73a13a5c13b801be237450cfe3cb
Reviewed-on: https://dart-review.googlesource.com/c/83522
Auto-Submit: Jenny Messerly <jmesserly@google.com>
Reviewed-by: Alan Knight <alanknight@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
diff --git a/pkg/dev_compiler/lib/src/compiler/shared_command.dart b/pkg/dev_compiler/lib/src/compiler/shared_command.dart
index a136652..ddb903c 100644
--- a/pkg/dev_compiler/lib/src/compiler/shared_command.dart
+++ b/pkg/dev_compiler/lib/src/compiler/shared_command.dart
@@ -149,9 +149,12 @@
           : (outPaths as List<String>)
               .firstWhere((_) => true, orElse: () => null);
 
+      // TODO(jmesserly): fix the debugger console so it's not passing invalid
+      // options.
+      if (outPath == null) return null;
       if (moduleRoot != null) {
-        // TODO(jmesserly): remove this legacy support after a deprecation period.
-        // (Mainly this is to give time for migrating build rules.)
+        // TODO(jmesserly): remove this legacy support after a deprecation
+        // period. (Mainly this is to give time for migrating build rules.)
         moduleName =
             path.withoutExtension(path.relative(outPath, from: moduleRoot));
       } else {
diff --git a/pkg/dev_compiler/web/web_command.dart b/pkg/dev_compiler/web/web_command.dart
index ac2b54f..2904b5a 100644
--- a/pkg/dev_compiler/web/web_command.dart
+++ b/pkg/dev_compiler/web/web_command.dart
@@ -285,13 +285,13 @@
       }
       resources.newFile(fileName, sourceCode);
 
-      compilerOptions.moduleName = path.toUri(libraryName).toString();
+      var name = path.toUri(libraryName).toString();
+      compilerOptions.moduleName = name;
       JSModuleFile module =
           compileWithAnalyzer(driver, [fileName], options, compilerOptions);
 
       var moduleCode = '';
       if (module.isValid) {
-        var name = compilerOptions.moduleName;
         moduleCode =
             module.getCode(ModuleFormat.legacyConcat, name, name + '.map').code;
       }