在汇总以生成捆绑文件

时间:2017-01-03 08:04:35

标签: angular dependencies

我正在以角度2进行应用程序,当执行Angular Documentation https://angular.io/docs/ts/latest/cookbook/aot-compiler.html步骤中提到的AOT编译时,我收到以下错误:

  

错误:' DataTableModule'不是由node_modules / angular2-datatable / index.js

导出的

这是我的代码:

main.ts

import { platformBrowser }    from '@angular/platform-browser';
import { AppModuleNgFactory } from '../aot/app/app.module.ngfactory';
platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);

app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { DataTableModule } from "angular2-datatable";
import { FormsModule, ReactiveFormsModule, FormBuilder } from     '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule }   from '@angular/router';
import { IndexComponent } from './index.component';
import { RegisterationFormComponent } from "./registration/registeration-form.component";
import { StaffListingComponent } from './company/staff-listing.component';
import {TranslateModule} from 'ng2-translate';

@NgModule({

imports:      [ BrowserModule,DataTableModule, FormsModule, HttpModule, TranslateModule.forRoot(),
        RouterModule.forRoot([
        { path: '', component: IndexComponent},
        { path: 'my-staff', component: StaffListingComponent},

  ], { useHash: true })],
  declarations: [ AppComponent, IndexComponent, StaffListingComponent,   DataFilterPipe ],
  providers: [AuthenticationService],
  bootstrap:    [ AppComponent ]
 })

 export class AppModule { }

systemjs.config.js

(function (global) {
   System.config({
   paths: {
  'npm:': 'node_modules/'
},
map: {
  // our app is within the app folder
  app: 'app',

  // angular bundles 
  // other libraries
  'rxjs':                      'npm:rxjs',
  'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
  'ng2-translate':'npm:ng2-translate',
   'lodash': 'npm:lodash/lodash.js',
   'angular2-datatable': 'npm:angular2-datatable',
   'angular2-infinite-scroll':'npm:angular2-infinite-scroll',
  },
packages: {
  app: {
    main: './main.js',
    defaultExtension: 'js'
  },
  rxjs: {
    defaultExtension: 'js'
  },
  'ng2-translate': {
      main:'./bundles/ng2-translate.umd.js', 
      defaultExtension: 'js'
  },
  'lodash': {
    defaultExtension: 'js'
  },
  'angular2-datatable': {
    main: './index.js',
    defaultExtension: 'js'
  },
  'angular2-infinite-scroll': {
      main:'./angular2-infinite-scroll.js', 
      defaultExtension: 'js'
  }
}
});

汇总-config.js

import rollup      from 'rollup'
import nodeResolve from 'rollup-plugin-node-resolve'
import commonjs    from 'rollup-plugin-commonjs';
import uglify      from 'rollup-plugin-uglify'

export default {
 entry: 'app/main.js',
 dest: 'dist/build.js', // output a single application bundle
 sourceMap: false,
 format: 'iife',
plugins: [
  nodeResolve({jsnext: true, module: true}),
  commonjs({
    include: 'node_modules/rxjs/**',
  }),
  uglify()
 ]
}

angular2-database依赖在没有AOT编译的情况下工作正常。但是在汇总时给出错误。任何人都可以帮我解决这个问题。

1 个答案:

答案 0 :(得分:0)

我通过在rollup-config.js文件中进行以下更改来解决此问题

汇总-config.js

<!-- Only permit app to be used on handsets, prevent tablets -->
    <compatible-screens>
        <!-- all small size screens -->
        <screen android:screenDensity="ldpi" android:screenSize="small" />
        <screen android:screenDensity="mdpi" android:screenSize="small" />
        <screen android:screenDensity="hdpi" android:screenSize="small" />
        <screen android:screenDensity="xhdpi" android:screenSize="small" />
        <screen android:screenDensity="480" android:screenSize="small" />
        <!-- all normal size screens -->
        <screen android:screenDensity="ldpi" android:screenSize="normal" />
        <screen android:screenDensity="mdpi" android:screenSize="normal" />
        <screen android:screenDensity="hdpi" android:screenSize="normal" />
        <screen android:screenDensity="xhdpi" android:screenSize="normal" />
        <screen android:screenDensity="480" android:screenSize="normal" />
        <!-- LG G3 QHD Resolution -->
        <screen android:screenDensity="640" android:screenSize="small" />
        <screen android:screenDensity="640" android:screenSize="normal" />
        <screen android:screenDensity="640" android:screenSize="large" />
        <screen android:screenDensity="640" android:screenSize="xlarge" />
        <!--- Nexus 6P -->
        <screen android:screenDensity="560" android:screenSize="small" />
        <screen android:screenDensity="560" android:screenSize="normal" />
        <screen android:screenDensity="560" android:screenSize="large" />
        <screen android:screenDensity="560" android:screenSize="xlarge" />
    </compatible-screens>