in frontend_server_common/lib/src/devfs.dart [63:141]
Future<UpdateFSReport> update({
String mainPath,
AssetBundle bundle,
String dillOutputPath,
@required ResidentCompiler generator,
List<Uri> invalidatedFiles,
}) async {
assert(generator != null);
var outputDirectoryPath = fileSystem.file(mainPath).parent.path;
var entryPoint = mainPath;
assetServer.writeFile(
'/main.dart.js',
generateBootstrapScript(
requireUrl: _filePathToUriFragment(requireJS.path),
mapperUrl: _filePathToUriFragment(stackTraceMapper.path),
entrypoint: entryPoint,
),
);
assetServer.writeFile(
'/main_module.bootstrap.js',
generateMainModule(
entrypoint: entryPoint,
),
);
assetServer.writeFile('/main_module.digests', '{}');
assetServer.writeFile('/dart_sdk.js', dartSdk.readAsStringSync());
assetServer.writeFile(
'/dart_sdk.js.map', dartSdkSourcemap.readAsStringSync());
// TODO(jonahwilliams): refactor the asset code in this and the regular devfs to
// be shared.
if (bundle != null) {
await writeBundle(
fileSystem.directory(p.joinAll(['build', 'assets'])),
bundle.entries,
);
}
generator.reset();
var compilerOutput = await generator.recompile(
'org-dartlang-app:///$mainPath',
invalidatedFiles,
outputPath: p.join(dillOutputPath, 'app.dill'),
packagesFilePath: packagesFilePath,
);
if (compilerOutput == null || compilerOutput.errorCount > 0) {
return UpdateFSReport(success: false);
}
// list of sources that needs to be monitored are in [compilerOutput.sources]
sources = compilerOutput.sources;
File codeFile;
File manifestFile;
File sourcemapFile;
File metadataFile;
List<String> modules;
try {
var parentDirectory = fileSystem.directory(outputDirectoryPath);
codeFile =
parentDirectory.childFile('${compilerOutput.outputFilename}.sources');
manifestFile =
parentDirectory.childFile('${compilerOutput.outputFilename}.json');
sourcemapFile =
parentDirectory.childFile('${compilerOutput.outputFilename}.map');
metadataFile = parentDirectory
.childFile('${compilerOutput.outputFilename}.metadata');
modules = assetServer.write(
codeFile, manifestFile, sourcemapFile, metadataFile);
} on FileSystemException catch (err) {
throw Exception('Failed to load recompiled sources:\n$err');
}
return UpdateFSReport(
success: true,
syncedBytes: codeFile.lengthSync(),
invalidatedSourcesCount: invalidatedFiles.length,
)..invalidatedModules = modules;
}