I am trying to create a typescript package that includes Angular 2 decorators. This package's intent is to export a NgModule to be imported into a larger project after it is installed by npm.
When I attempt to run tests through jasmine I get the error message:
/Users/don286/Dev/Angular2Modules/viewengine/node_modules/@angular/core/src/util/decorators.js:173
throw 'reflect-metadata shim is required when using class decorators';
I have these packages in my package.json:
"devDependencies": {
"@angular/core": "^2.0.0-rc.5",
"@types/es6-shim": "0.0.30",
"@types/node": "^6.0.37",
"jasmine": "^2.4.1",
"reflect-metadata": "0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.17"
}
I've tried to import reflect-metadata into the project, and it doesn't not work... I am able to successfully run all the tests. The problem here is when I try to import the module and use the exported components. I am left with this problem:
views:169 Error: Error: XHR error (404 Not Found) loading http://localhost:5555/node_modules/crypto/package.json(…)
If I try to just use the module without adding the import then it doesn't recognize any of the Angular directive properties and shoots out an error for every aspect in the html. Example error for this looks like:
zone.js?1472162416591:461 Unhandled Promise rejection: Template parse errors: Can't bind to 'ngClass' since it isn't a known property of 'div'.
Here's the index file to see how the export is being handled:
import { NgModule } from '@angular/core';
import { Component } from './lib/component/Component.component';
export const DIRECTIVES: any[] = [
Component
];
@NgModule({
exports: DIRECTIVES,
declarations: DIRECTIVES
})
export class Module { }
I've been looking around at other projects and how they do this, and I can't find anything specifically different... I am not sure what I am missing or don't understand to get these Angular Decorators to build externally from a root project.