build method

  1. @override
Future build(
  1. BuildStep buildStep
)

Generates the outputs for a given BuildStep.

Implementation

@override
Future build(BuildStep buildStep) async {
  var module = Module.fromJson(
      json.decode(await buildStep.readAsString(buildStep.inputId))
          as Map<String, dynamic>);
  // Entrypoints always have a `.module` file for ease of looking them up,
  // but they might not be the primary source.
  if (module.primarySource.changeExtension(moduleExtension(platform)) !=
      buildStep.inputId) {
    return;
  }

  Future<void> handleError(Object e) async {
    await buildStep.writeAsString(
        module.primarySource.changeExtension(jsModuleErrorsExtension), '$e');
    log.severe('$e');
  }

  try {
    await _createDevCompilerModule(
        module,
        buildStep,
        useIncrementalCompiler,
        generateFullDill,
        emitDebugSymbols,
        canaryFeatures,
        trackUnusedInputs,
        platformSdk,
        sdkKernelPath,
        librariesPath,
        environment);
  } on DartDevcCompilationException catch (e) {
    await handleError(e);
  } on MissingModulesException catch (e) {
    await handleError(e);
  }
}