mariuszfoltak / angular2-datatable

DataTable - Simple table component with sorting and pagination for Angular2
202 stars 182 forks source link

Getting: "Duplicate export 'DataTableModule'" when using rollup #101

Closed n4uoase closed 7 years ago

n4uoase commented 7 years ago

Hi! I am using this module for a project. I am following the Angular Cookbook ( https://angular.io/docs/ts/latest/cookbook/aot-compiler.html ) for AOT-compiling. An error occurs when I'm executing following command: "node_modules/.bin/rollup" -c rollup-config.js Error Message:

Duplicate export 'DataTableModule'
node_modules\angular2-datatable\lib\DataTableModule.js (63:30)
61: var DataTableModule_2 = DataTableModule_1.DataTableModule;
62: export { DataTableModule_2 as DataTableModule };
63: export { DataTableModule_3 as DataTableModule };
                                  ^

Here's my rollup-config.js File:

import rollup      from 'rollup'
  import nodeResolve from 'rollup-plugin-node-resolve'
  import commonjs    from 'rollup-plugin-commonjs';
  import uglify      from 'rollup-plugin-uglify'
  //paths are relative to the execution path
  export default {
    entry: 'src/main.js',
    dest: 'aot/dist/build.js', // output a single application bundle
    sourceMap: true,
    sourceMapFile: 'aot/dist/build.js.map',
    format: 'iife',
    onwarn: function(warning) {
      // Skip certain warnings
      // should intercept ... but doesn't in some rollup versions
      if ( warning.code === 'THIS_IS_UNDEFINED' ) { return; }
      // console.warn everything else
      console.warn( warning.message );
    },
    plugins: [
      nodeResolve({jsnext: true, module: true}),
      commonjs({
        include: [
          'node_modules/rxjs/**',
          'node_modules/ng2-password-strength-bar/index.js',
          'node_modules/ng2-password-strength-bar/lib/passwordStrengthBar.module.js',
          'node_modules/angular2-datatable/lib/DataTableModule.js',
          'node_modules/ng2-bs3-modal/ng2-bs3-modal.js',
          'node_modules/angular2-jwt/angular2-jwt.js',
          'node_modules/angular2-dropzone-wrapper/dist/lib/dropzone.module.js',
          'node_modules/angular2-dropzone-wrapper/dist/lib/dropzone.interfaces.js',
          'node_modules/angular2-dropzone-wrapper/dist/index.js',
          'node_modules/angular-modal-gallery/dist/bundles/angular-modal-gallery.umd.js'
        ],
        namedExports: {
          'node_modules/angular-modal-gallery/dist/bundles/angular-modal-gallery.umd.js': ['ModalGalleryModule'],
          'node_modules/angular2-logger/core.js': ['Logger', 'Options'],
          'node_modules/angular2-dropzone-wrapper/dist/index.js' : ['DropzoneModule'],
          'node_modules/angular2-datatable/lib/DataTableModule.js' : ['DataTableModule']
        }
      }),
      uglify()
    ]
  }

Maybe somebody can help me solve this problem? Thank you in advance!

n4uoase commented 7 years ago

After fiddling around with rollup.js, I've figured that my rollup-configurations were wrong. Here is the working rollup-config.js (remove DataTableModule from namedExports and in include 'node_modules/**'):

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

  //paths are relative to the execution path
  export default {
    entry: 'src/main.js',
    dest: 'aot/dist/build.js', // output a single application bundle
    sourceMap: true,
    sourceMapFile: 'aot/dist/build.js.map',
    format: 'iife',
    onwarn: function(warning) {
      // Skip certain warnings
      // should intercept ... but doesn't in some rollup versions
      if ( warning.code === 'THIS_IS_UNDEFINED' ) { return; }
      // console.warn everything else
      console.warn( warning.message );
    },
    plugins: [
      commonjs({
        include: 'node_modules/**',
        namedExports: {
          'node_modules/angular-modal-gallery/dist/bundles/angular-modal-gallery.umd.js': ['ModalGalleryModule', 'Image'],
          'node_modules/angular2-logger/core.js': ['Logger', 'Options'],
          'node_modules/angular2-dropzone-wrapper/dist/index.js' : ['DropzoneModule'],
          'node_modules/ng2-bs3-modal/ng2-bs3-modal.js' : ['ModalComponent']
        }
    }),
      nodeResolve({jsnext: true, module: true})
      uglify()
    ]
  }