--create_source_map throws exception on windows when using input source maps and chunks
Closure throws an exception when I try to build source maps for chunks:
java.io.FileNotFoundException: .\\dist\\closure\\common.js.map (The system cannot find the path specified)
It seems like there's a race condition issue if the source map of a depending module is built before the dependency. It seems to work properly if I run the build without `--create_source_map`, and then run it again _with_ `--create_source_map`.

Reproducer is available here: https://github.com/DerGernTod/ts-esbuild-closure-reproducer/blob/main/index.js

The used flags:
--chunk common:2
--chunk_wrapper common:(function(){%s})()
--source_map_input dist/esbuild/chunk-7THFJKJQ.js|dist/esbuild/chunk-7THFJKJQ.js.map
--js dist/esbuild/chunk-7THFJKJQ.js
--source_map_input dist/esbuild/filecommon.js|dist/esbuild/filecommon.js.map
--js dist/esbuild/filecommon.js
--chunk filea:1:common
--chunk_wrapper filea:(function(){%s})()
--source_map_input dist/esbuild/filea.js|dist/esbuild/filea.js.map
--js dist/esbuild/filea.js
--chunk fileb:1:common
--chunk_wrapper fileb:(function(){%s})()
--source_map_input dist/esbuild/fileb.js|dist/esbuild/fileb.js.map
--js dist/esbuild/fileb.js
--language_in ECMASCRIPT_2017
--language_out ECMASCRIPT_2017
--chunk_output_path_prefix ./dist/closure/
--rename_prefix_namespace myNamespace
--compilation_level ADVANCED_OPTIMIZATIONS
--create_source_map %outname%.map

I also tried `--source_map_include_content`, but that doesn't seem to work either (even if you build it once without source maps to prevent the error mentioned above, and then build it with source maps). The source is not embedded at all.


diff --git a/src/com/google/javascript/jscomp/AbstractCommandLineRunner.java b/src/com/google/javascript/jscomp/AbstractCommandLineRunner.java
index e27089744..ad4fdaff2 100644
--- a/src/com/google/javascript/jscomp/AbstractCommandLineRunner.java
+++ b/src/com/google/javascript/jscomp/AbstractCommandLineRunner.java
@@ -1139,12 +1139,9 @@ public abstract class AbstractCommandLineRunner<A extends Compiler, B extends Co
   @GwtIncompatible("Unnecessary")
   private static void maybeCreateDirsForPath(String pathPrefix) {
     if (!Strings.isNullOrEmpty(pathPrefix)) {
-      String dirName =
-          pathPrefix.charAt(pathPrefix.length() - 1) == File.separatorChar
-              ? pathPrefix.substring(0, pathPrefix.length() - 1)
-              : new File(pathPrefix).getParent();
-      if (dirName != null) {
-        new File(dirName).mkdirs();
+      File parent = new File(pathPrefix).getParentFile();
+      if (parent != null) {
+        parent.mkdirs();
       }
     }
   }
@@ -1769,7 +1766,8 @@ public abstract class AbstractCommandLineRunner<A extends Compiler, B extends Co
       throws IOException {
     parsedModuleWrappers = parseModuleWrappers(config.moduleWrapper, modules);
     if (!isOutputInJson()) {
-      maybeCreateDirsForPath(config.moduleOutputPathPrefix);
+      // make sure the method generates all dirs up to the latest /
+      maybeCreateDirsForPath(config.moduleOutputPathPrefix + "dummy");
     }
 
     // If the source map path is in fact a pattern for each
['src/com/google/javascript/jscomp/AbstractCommandLineRunner.java']