compileAsync static method
Invoke a dart2js compile with the given sourceFile
as input.
Implementation
static Future compileAsync(File sourceFile,
{Directory? outDir,
File? outFile,
bool minify = false,
bool csp = false,
bool enableExperimentalMirrors = false,
String? categories,
List<String> extraArgs = const []}) {
if (outFile == null) {
outDir ??= sourceFile.parent;
outFile = joinFile(outDir, ['${fileName(sourceFile)}.js']);
} else {
outDir = outFile.parent;
}
if (!outDir.existsSync()) outDir.createSync(recursive: true);
return runlib
.runAsync(sdkBin('dart'),
arguments: _buildArgs(
minify: minify,
csp: csp,
enableExperimentalMirrors: enableExperimentalMirrors,
categories: categories,
extraArgs: extraArgs,
outFile: outFile,
sourceFile: sourceFile))
.then((_) => null);
}