diff --git a/modules_dart/transform/lib/src/transform/template_compiler/compile_data_creator.dart b/modules_dart/transform/lib/src/transform/template_compiler/compile_data_creator.dart index 4436ba4d10..1452db06ba 100644 --- a/modules_dart/transform/lib/src/transform/template_compiler/compile_data_creator.dart +++ b/modules_dart/transform/lib/src/transform/template_compiler/compile_data_creator.dart @@ -19,6 +19,12 @@ import 'package:barback/barback.dart'; /// /// The returned value wraps the [NgDepsModel] at `assetId` as well as these /// created objects. +/// +/// `platformDirectives` is an optional [List] containing names of [Directive]s +/// which should be available to all [View]s in this app. +/// +/// `platformPipes` is an optional [List] containing names of [Pipe]s which +/// should be available to all [View]s in this app. Future createCompileData( AssetReader reader, AssetId assetId, @@ -65,9 +71,17 @@ class _CompileDataCreator { NgDepsModel get ngDeps => ngMeta.ngDeps; Future createCompileData() async { - if (ngDeps == null || ngDeps.reflectables == null) { - return new CompileDataResults._(ngMeta, const {}); - } + var hasTemplate = ngDeps != null && + ngDeps.reflectables != null && + ngDeps.reflectables.any((reflectable) { + if (ngMeta.types.containsKey(reflectable.name)) { + final metadata = ngMeta.types[reflectable.name]; + return metadata is CompileDirectiveMetadata && + metadata.template != null; + } + return false; + }); + if (!hasTemplate) return new CompileDataResults._(ngMeta, const {}); final compileData = {}; diff --git a/modules_dart/transform/lib/src/transform/template_compiler/generator.dart b/modules_dart/transform/lib/src/transform/template_compiler/generator.dart index 161234abc0..89029e8f9d 100644 --- a/modules_dart/transform/lib/src/transform/template_compiler/generator.dart +++ b/modules_dart/transform/lib/src/transform/template_compiler/generator.dart @@ -22,9 +22,17 @@ import 'reflection/processor.dart' as reg; import 'reflection/reflection_capabilities.dart'; import 'compile_data_creator.dart'; -/// Reads the `.ng_deps.dart` file represented by `assetId` and parses any -/// Angular 2 `View` annotations it declares to generate `getter`s, -/// `setter`s, and `method`s that would otherwise be reflectively accessed. +/// Generates `.ng_deps.dart` files to initialize the Angular2 system. +/// +/// Processes the `.ng_summary.json` file represented by `assetId` +/// `createCompileData`. +/// Uses the resulting `NgMeta` object to generate +/// `getter`s, `setter`s, and `method`s that would otherwise need to be +/// reflectively accessed. +/// Passes the resulting `NormalizedComponentWithViewDirectives` instances +/// to the `TemplateCompiler` to generate compiled template(s). +/// Uses the resulting `NgDeps` object to generate a .ng_deps.dart file which +/// initializes the Angular2 reflective system. /// /// This method assumes a {@link DomAdapter} has been registered. Future processTemplates(AssetReader reader, AssetId assetId,