Skip to content

Can't offline compile components with reference to material components #832

@thelgevold

Description

@thelgevold

Bug:

From what I can tell, it's not possible to offline compile my components if there are references to MD components.

I have the following CLI generated component:

import { Component } from '@angular/core';
import { MdButton } from '@angular2-material/button'; 

@Component({
  moduleId: module.id,
  selector: 'app-root',
  templateUrl: 'app.component.html',
  styleUrls: ['app.component.css'],
  directives: [MdButton] // This throws an error when offline compiling
})
export class AppComponent {
  title = 'app works!';
}

In my sample component I am importing and registering MdButton, but when running ./node_modules/.bin/ngc -p ./src I get the error:

Error: No Directive annotation found on MdButton
    at new BaseException (/Users/tor/temp-repo/material/node_modules/@angular/compiler/src/facade/exceptions.js:27:23)
    at DirectiveResolver.resolve (/Users/tor/temp-repo/material/node_modules/@angular/compiler/src/directive_resolver.js:34:15)
    at CompileMetadataResolver.getDirectiveMetadata (/Users/tor/temp-repo/material/node_modules/@angular/compiler/src/metadata_resolver.js:108:51)
    at /Users/tor/temp-repo/material/node_modules/@angular/compiler/src/metadata_resolver.js:230:62
    at Array.map (native)
    at CompileMetadataResolver.getViewDirectivesMetadata (/Users/tor/temp-repo/material/node_modules/@angular/compiler/src/metadata_resolver.js:230:27)
    at normalize (/Users/tor/temp-repo/material/node_modules/@angular/compiler-cli/src/codegen.js:37:45)
    at Array.map (native)
    at CodeGenerator.generateSource (/Users/tor/temp-repo/material/node_modules/@angular/compiler-cli/src/codegen.js:44:38)
    at /Users/tor/temp-repo/material/node_modules/@angular/compiler-cli/src/codegen.js:99:30

What is the expected behavior?

I would expect offline compilation to work with Md components

What is the current behavior?

What are the steps to reproduce?

Offline compile a component with a reference to an MD component.

What is the use-case or motivation for changing an existing behavior?

Which versions of Angular, Material, OS, browsers are affected?

OSX, all browsers

Is there anything else we should know?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions