@@ -1231,7 +1231,6 @@ protected int doRun() throws IOException {
12311231 compiler .printConfig (System .err );
12321232 }
12331233
1234-
12351234 String saveAfterChecksFilename = config .getSaveAfterChecksFileName ();
12361235 String continueSavedCompilationFilename = config .getContinueSavedCompilationFileName ();
12371236 if (config .skipNormalOutputs ) {
@@ -2040,27 +2039,32 @@ private void outputManifestOrBundle(List<String> outputFiles, boolean isManifest
20402039 }
20412040
20422041 if (shouldGenerateOutputPerModule (output )) {
2043- // Generate per-module manifests or bundles
2042+ // Generate per-module manifests or bundles.
20442043 Iterable <JSModule > modules = compiler .getModuleGraph ().getAllModules ();
20452044 for (JSModule module : modules ) {
20462045 try (Writer out = fileNameToOutputWriter2 (expandCommandLinePath (output , module ))) {
20472046 if (isManifest ) {
2048- printManifestTo (module . getInputs () , out );
2047+ printManifestTo (module , out );
20492048 } else {
2050- printBundleTo (module . getInputs () , out );
2049+ printBundleTo (module , out );
20512050 }
20522051 }
20532052 }
20542053 } else {
20552054 // Generate a single file manifest or bundle.
20562055 try (Writer out = fileNameToOutputWriter2 (expandCommandLinePath (output , null ))) {
20572056 if (config .module .isEmpty ()) {
2057+ // For a single-module compilation, generate a single headerless manifest or bundle
2058+ // containing only the strong files.
2059+ JSModule module =
2060+ compiler .getModuleGraph ().getModuleByName (JSModule .STRONG_MODULE_NAME );
20582061 if (isManifest ) {
2059- printManifestTo (compiler . getInputsInOrder () , out );
2062+ printManifestTo (module , out );
20602063 } else {
2061- printBundleTo (compiler . getInputsInOrder () , out );
2064+ printBundleTo (module , out );
20622065 }
20632066 } else {
2067+ // For a multi-module compilation, generate a single manifest file with module headers.
20642068 printModuleGraphManifestOrBundleTo (compiler .getModuleGraph (), out , isManifest );
20652069 }
20662070 }
@@ -2094,6 +2098,11 @@ void printModuleGraphManifestOrBundleTo(JSModuleGraph graph, Appendable out, boo
20942098 Joiner commas = Joiner .on ("," );
20952099 boolean requiresNewline = false ;
20962100 for (JSModule module : graph .getAllModules ()) {
2101+ if (!isManifest && module .isWeak ()) {
2102+ // Skip the weak module on a multi-module bundle, but not a multi-module manifest.
2103+ continue ;
2104+ }
2105+
20972106 if (requiresNewline ) {
20982107 out .append ("\n " );
20992108 }
@@ -2106,9 +2115,9 @@ void printModuleGraphManifestOrBundleTo(JSModuleGraph graph, Appendable out, boo
21062115 String .format ("{%s%s}\n " ,
21072116 module .getName (),
21082117 dependencies .isEmpty () ? "" : ":" + dependencies ));
2109- printManifestTo (module . getInputs () , out );
2118+ printManifestTo (module , out );
21102119 } else {
2111- printBundleTo (module . getInputs () , out );
2120+ printBundleTo (module , out );
21122121 }
21132122 requiresNewline = true ;
21142123 }
@@ -2120,12 +2129,10 @@ void printModuleGraphManifestOrBundleTo(JSModuleGraph graph, Appendable out, boo
21202129 */
21212130 @ VisibleForTesting
21222131 @ GwtIncompatible ("Unnecessary" )
2123- void printManifestTo (Iterable < CompilerInput > inputs , Appendable out ) throws IOException {
2124- for (CompilerInput input : inputs ) {
2132+ void printManifestTo (JSModule module , Appendable out ) throws IOException {
2133+ for (CompilerInput input : module . getInputs () ) {
21252134 String rootRelativePath = rootRelativePathsMap .get (input .getName ());
2126- String displayName = rootRelativePath != null
2127- ? rootRelativePath
2128- : input .getName ();
2135+ String displayName = rootRelativePath != null ? rootRelativePath : input .getName ();
21292136 out .append (displayName );
21302137 out .append ("\n " );
21312138 }
@@ -2137,7 +2144,8 @@ void printManifestTo(Iterable<CompilerInput> inputs, Appendable out) throws IOEx
21372144 */
21382145 @ VisibleForTesting
21392146 @ GwtIncompatible ("Unnecessary" )
2140- void printBundleTo (Iterable <CompilerInput > inputs , Appendable out ) throws IOException {
2147+ void printBundleTo (JSModule module , Appendable out ) throws IOException {
2148+ Iterable <CompilerInput > inputs = module .getInputs ();
21412149 // Prebuild ASTs before they're needed in getLoadFlags, for performance and because
21422150 // StackOverflowErrors can be hit if not prebuilt.
21432151 if (compiler .getOptions ().numParallelThreads > 1 ) {
@@ -2158,11 +2166,6 @@ void printBundleTo(Iterable<CompilerInput> inputs, Appendable out) throws IOExce
21582166 String name = input .getName ();
21592167 String code = input .getSourceFile ().getCode ();
21602168
2161- // Ignore weak files.
2162- if (input .getSourceFile ().isWeak ()) {
2163- continue ;
2164- }
2165-
21662169 // Ignore empty fill files created by the compiler to facilitate cross-module code motion.
21672170 // Note that non-empty fill files (ones whose code has actually been moved into) are still
21682171 // emitted. In particular, this ensures that if there are no (real) inputs the bundle will be
0 commit comments