@@ -84,9 +84,13 @@ Future _createDevCompilerModule(
84
84
request.arguments.addAll ([
85
85
'--dart-sdk-summary=$sdkSummary ' ,
86
86
'--modules=amd' ,
87
+ '--no-summarize' ,
87
88
'-o' ,
88
89
jsOutputFile.path,
89
90
]);
91
+ request.inputs.add (Input ()
92
+ ..path = sdkSummary
93
+ ..digest = [0 ]);
90
94
91
95
if (! useKernel) {
92
96
// Add the default analysis_options.
@@ -117,21 +121,35 @@ Future _createDevCompilerModule(
117
121
request.arguments.add ('--no-source-map' );
118
122
}
119
123
120
- // Add all the linked summaries as summary inputs.
124
+ // Add linked summaries as summary inputs.
125
+ //
126
+ // Also request the digests for each and add those to the inputs.
127
+ //
128
+ // This runs synchronously and the digest futures will be awaited later on.
129
+ var digestFutures = < Future > [];
121
130
for (var depModule in transitiveDeps) {
122
131
var summaryId = useKernel
123
132
? depModule.primarySource.changeExtension (ddcKernelExtension)
124
133
: depModule.linkedSummaryId;
125
- var summaryPath = useKernel
126
- ? p.url.relative (scratchSpace.fileFor (summaryId).path,
127
- from: scratchSpace.tempDir.path) +
128
- '=' +
129
- ddcModuleName (
130
- depModule.primarySource.changeExtension (jsModuleExtension))
131
- : scratchSpace.fileFor (summaryId).path;
134
+ var summaryPath = scratchSpace.fileFor (summaryId).path;
135
+
136
+ if (useKernel) {
137
+ var input = Input ()..path = summaryPath;
138
+ request.inputs.add (input);
139
+ digestFutures.add (buildStep.digest (summaryId).then ((digest) {
140
+ input.digest = digest.bytes;
141
+ }));
142
+ var moduleName = ddcModuleName (
143
+ depModule.primarySource.changeExtension (jsModuleExtension));
144
+ summaryPath += '=$moduleName ' ;
145
+ }
146
+
132
147
request.arguments.addAll (['-s' , summaryPath]);
133
148
}
134
149
150
+ // Wait for all the digests to complete.
151
+ await Future .wait (digestFutures);
152
+
135
153
// Add URL mappings for all the package: files to tell DartDevc where to
136
154
// find them.
137
155
//
@@ -154,12 +172,20 @@ Future _createDevCompilerModule(
154
172
var allDeps = < AssetId > []
155
173
..addAll (module.sources)
156
174
..addAll (transitiveSummaryDeps);
157
- packagesFile = await createPackagesFile (allDeps, scratchSpace );
175
+ packagesFile = await createPackagesFile (allDeps);
158
176
request.arguments.addAll ([
159
177
'--packages' ,
160
178
packagesFile.absolute.uri.toString (),
161
179
'--module-name' ,
162
180
ddcModuleName (module.primarySource.changeExtension (jsModuleExtension)),
181
+ '--multi-root-scheme' ,
182
+ multiRootScheme,
183
+ '--multi-root' ,
184
+ '.' ,
185
+ '--reuse-compiler-result' ,
186
+ '--use-incremental-compiler' ,
187
+ '--track-widget-creation' ,
188
+ '--inline-source-map' ,
163
189
]);
164
190
}
165
191
@@ -170,7 +196,9 @@ Future _createDevCompilerModule(
170
196
if (uri.startsWith ('package:' )) {
171
197
return uri;
172
198
}
173
- return useKernel ? id.path : Uri .file ('/${id .path }' ).toString ();
199
+ return useKernel
200
+ ? '$multiRootScheme :///${id .path }'
201
+ : Uri .file ('/${id .path }' ).toString ();
174
202
}));
175
203
176
204
WorkResponse response;
@@ -188,17 +216,36 @@ Future _createDevCompilerModule(
188
216
// TODO(jakemac53): Fix the ddc worker mode so it always sends back a bad
189
217
// status code if something failed. Today we just make sure there is an output
190
218
// JS file to verify it was successful.
191
- if (response.exitCode != EXIT_CODE_OK || ! jsOutputFile.existsSync ()) {
192
- var message =
193
- response.output.replaceAll ('${scratchSpace .tempDir .path }/' , '' );
194
- throw DartDevcCompilationException (jsId, '$message }' );
219
+ var message = response.output
220
+ .replaceAll ('${scratchSpace .tempDir .path }/' , '' )
221
+ .replaceAll ('$multiRootScheme :///' , '' );
222
+ if (response.exitCode != EXIT_CODE_OK ||
223
+ ! jsOutputFile.existsSync () ||
224
+ message.contains ('Error:' )) {
225
+ throw DartDevcCompilationException (jsId, message);
195
226
} else {
227
+ if (message.isNotEmpty) {
228
+ log.info ('\n $message ' );
229
+ }
196
230
// Copy the output back using the buildStep.
197
231
await scratchSpace.copyOutput (jsId, buildStep);
198
232
if (debugMode) {
199
- await scratchSpace.copyOutput (
200
- module.primarySource.changeExtension (jsSourceMapExtension),
201
- buildStep);
233
+ // We need to modify the sources in the sourcemap to remove the custom
234
+ // `multiRootScheme` that we use.
235
+ var sourceMapId =
236
+ module.primarySource.changeExtension (jsSourceMapExtension);
237
+ var file = scratchSpace.fileFor (sourceMapId);
238
+ var content = await file.readAsString ();
239
+ var json = jsonDecode (content);
240
+ json['sources' ] = (json['sources' ] as List ).cast <String >().map ((source) {
241
+ var uri = Uri .parse (source);
242
+ var newSegments = uri.pathSegments.first == 'packages'
243
+ ? uri.pathSegments
244
+ : uri.pathSegments.skip (1 );
245
+ return Uri (path: p.url.joinAll (['/' ].followedBy (newSegments)))
246
+ .toString ();
247
+ }).toList ();
248
+ await buildStep.writeAsString (sourceMapId, jsonEncode (json));
202
249
}
203
250
}
204
251
}
0 commit comments