@@ -1231,7 +1231,6 @@ protected int doRun() throws IOException {
1231
1231
compiler .printConfig (System .err );
1232
1232
}
1233
1233
1234
-
1235
1234
String saveAfterChecksFilename = config .getSaveAfterChecksFileName ();
1236
1235
String continueSavedCompilationFilename = config .getContinueSavedCompilationFileName ();
1237
1236
if (config .skipNormalOutputs ) {
@@ -2040,27 +2039,32 @@ private void outputManifestOrBundle(List<String> outputFiles, boolean isManifest
2040
2039
}
2041
2040
2042
2041
if (shouldGenerateOutputPerModule (output )) {
2043
- // Generate per-module manifests or bundles
2042
+ // Generate per-module manifests or bundles.
2044
2043
Iterable <JSModule > modules = compiler .getModuleGraph ().getAllModules ();
2045
2044
for (JSModule module : modules ) {
2046
2045
try (Writer out = fileNameToOutputWriter2 (expandCommandLinePath (output , module ))) {
2047
2046
if (isManifest ) {
2048
- printManifestTo (module . getInputs () , out );
2047
+ printManifestTo (module , out );
2049
2048
} else {
2050
- printBundleTo (module . getInputs () , out );
2049
+ printBundleTo (module , out );
2051
2050
}
2052
2051
}
2053
2052
}
2054
2053
} else {
2055
2054
// Generate a single file manifest or bundle.
2056
2055
try (Writer out = fileNameToOutputWriter2 (expandCommandLinePath (output , null ))) {
2057
2056
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 );
2058
2061
if (isManifest ) {
2059
- printManifestTo (compiler . getInputsInOrder () , out );
2062
+ printManifestTo (module , out );
2060
2063
} else {
2061
- printBundleTo (compiler . getInputsInOrder () , out );
2064
+ printBundleTo (module , out );
2062
2065
}
2063
2066
} else {
2067
+ // For a multi-module compilation, generate a single manifest file with module headers.
2064
2068
printModuleGraphManifestOrBundleTo (compiler .getModuleGraph (), out , isManifest );
2065
2069
}
2066
2070
}
@@ -2094,6 +2098,11 @@ void printModuleGraphManifestOrBundleTo(JSModuleGraph graph, Appendable out, boo
2094
2098
Joiner commas = Joiner .on ("," );
2095
2099
boolean requiresNewline = false ;
2096
2100
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
+
2097
2106
if (requiresNewline ) {
2098
2107
out .append ("\n " );
2099
2108
}
@@ -2106,9 +2115,9 @@ void printModuleGraphManifestOrBundleTo(JSModuleGraph graph, Appendable out, boo
2106
2115
String .format ("{%s%s}\n " ,
2107
2116
module .getName (),
2108
2117
dependencies .isEmpty () ? "" : ":" + dependencies ));
2109
- printManifestTo (module . getInputs () , out );
2118
+ printManifestTo (module , out );
2110
2119
} else {
2111
- printBundleTo (module . getInputs () , out );
2120
+ printBundleTo (module , out );
2112
2121
}
2113
2122
requiresNewline = true ;
2114
2123
}
@@ -2120,12 +2129,10 @@ void printModuleGraphManifestOrBundleTo(JSModuleGraph graph, Appendable out, boo
2120
2129
*/
2121
2130
@ VisibleForTesting
2122
2131
@ 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 () ) {
2125
2134
String rootRelativePath = rootRelativePathsMap .get (input .getName ());
2126
- String displayName = rootRelativePath != null
2127
- ? rootRelativePath
2128
- : input .getName ();
2135
+ String displayName = rootRelativePath != null ? rootRelativePath : input .getName ();
2129
2136
out .append (displayName );
2130
2137
out .append ("\n " );
2131
2138
}
@@ -2137,7 +2144,8 @@ void printManifestTo(Iterable<CompilerInput> inputs, Appendable out) throws IOEx
2137
2144
*/
2138
2145
@ VisibleForTesting
2139
2146
@ 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 ();
2141
2149
// Prebuild ASTs before they're needed in getLoadFlags, for performance and because
2142
2150
// StackOverflowErrors can be hit if not prebuilt.
2143
2151
if (compiler .getOptions ().numParallelThreads > 1 ) {
@@ -2158,11 +2166,6 @@ void printBundleTo(Iterable<CompilerInput> inputs, Appendable out) throws IOExce
2158
2166
String name = input .getName ();
2159
2167
String code = input .getSourceFile ().getCode ();
2160
2168
2161
- // Ignore weak files.
2162
- if (input .getSourceFile ().isWeak ()) {
2163
- continue ;
2164
- }
2165
-
2166
2169
// Ignore empty fill files created by the compiler to facilitate cross-module code motion.
2167
2170
// Note that non-empty fill files (ones whose code has actually been moved into) are still
2168
2171
// emitted. In particular, this ensures that if there are no (real) inputs the bundle will be
0 commit comments