0

これは私のHelloWorldModuleUMDです:

    (function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/router')) :
    typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@angular/router'], factory) :
    (factory((global['hello-world-app'] = {}),global.vendor._angular_core,global.vendor._angular_router));
}(this, (function (exports,_angular_core,_angular_router) { 'use strict';

function __decorate(decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
}

function __metadata(k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
}

var HelloWorldComponent = (function () {
    function HelloWorldComponent() {
    }
    HelloWorldComponent = __decorate([
        _angular_core.Component({
            template: "<h1>Hello, world!</h1>\n<p>You have reached the hello world component</p>"
        }), 
        __metadata('design:paramtypes', [])
    ], HelloWorldComponent);
    return HelloWorldComponent;
}());

//export const HelloWorldRoutes = [{ path: '', component: HelloWorldComponent }]
var HelloWorldModule = (function () {
    function HelloWorldModule() {
    }
    HelloWorldModule = __decorate([
        _angular_core.NgModule({
            declarations: [
                HelloWorldComponent
            ],
            imports: [
                _angular_router.RouterModule.forChild([{ path: '', component: HelloWorldComponent }])
            ],
            exports: [_angular_router.RouterModule]
        }), 
        __metadata('design:paramtypes', [])
    ], HelloWorldModule);
    return HelloWorldModule;
}());

exports.HelloWorldModule = HelloWorldModule;
exports.HelloWorldComponent = HelloWorldComponent;

Object.defineProperty(exports, '__esModule', { value: true });

})));
//# sourceMappingURL=hello-world-app.umd.js.map

それを Angular アプリ プロジェクトにインポートして実行するng buildと、次のエラーが発生します。

ERROR in HelloWorldModule is not an NgModule

私のangularアプリの依存関係は次のとおりです。

  "dependencies": {
    "@angular/common": "4.3.4",
    "@angular/core": "4.3.4",
    "@angular/forms": "4.3.4",
    "@angular/http": "4.3.4",
    "@angular/platform-browser": "4.3.4",
    "@angular/platform-browser-dynamic": "4.3.4",
    "@angular/router": "4.3.4",
    "core-js": "^2.4.1",
    "hello-world-app-npm": "file:../hello-world-app-npm/hello-world-app-npm-1.0.0.tgz",
    "rxjs": "^5.1.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/cli": "^1.3.1",
    "@angular/compiler": "4.3.4",
    "@angular/compiler-cli": "4.3.4",
    "@types/jasmine": "2.5.38",
    "@types/node": "~6.0.60",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.0",
    "ts-node": "~2.0.0",
    "tslint": "~4.5.0",
    "typescript": "~2.4.0"
  }

アプリまたは UMD に何か問題がありますか? どうすればこれを修正できますか?

4

0 に答える 0