valor-software / ng2-file-upload

Easy to use Angular components for files upload
http://valor-software.github.io/ng2-file-upload/
MIT License
1.91k stars 662 forks source link

"'FileUploader' is not exported by node_modules/ng2-file-upload/ng2-file-upload.js" #623

Open gomesNazareth opened 7 years ago

gomesNazareth commented 7 years ago

@valorkin I am getting this error with aot and rollup

Error: "FileUploader is not exported by node_modules/ng2-file-upload/ng2-file-upload.js".

I am using the angular seed project by @mgechev. Is this a similar issue like valor-software/ng2-dragula#530 . Is there a way i can fix it.

albpara commented 7 years ago

Any update on this. I am getting the same error

rikup88 commented 7 years ago

I have customized build.bundles.app.rollup.aot file like this and it works:

` import Config from '../../config'; import { writeFile } from 'fs'; import { join } from 'path';

const nodeResolve = require('rollup-plugin-node-resolve-angular'); const commonjs = require('rollup-plugin-commonjs'); const progress = require('rollup-plugin-progress'); const filesize = require('rollup-plugin-filesize'); const replace = require('rollup-plugin-replace'); const includePaths = require('rollup-plugin-includepaths'); const rollup = require('rollup');

const config = { entry: join(Config.TMP_DIR, Config.BOOTSTRAP_FACTORY_PROD_MODULE), sourceMap: true, treeshake: true, moduleName: 'main', plugins: [ progress({ clearLine: false // default: true }), replace({ 'process.env.NODE_ENV': JSON.stringify( 'production' ) }), filesize(), includePaths({ include: {}, paths: [join(Config.TMP_DIR, 'app')], external: [], extensions: ['.js', '.json', '.html', '.ts'] }), nodeResolve({ es2015: true, jsnext: true, main: true, module: true, browser: true }), commonjs({ include: 'node_modules/**', namedExports: { 'node_modules/immutable/dist/immutable.js': [ 'Map', 'Set', 'List'], 'node_modules/ngx-color-picker/dist/index.js': [ 'ColorPickerModule'], 'node_modules/ng2-file-upload/index.js': [ 'FileUploader'] } }) ] };

export = (done: any) => { rollup.rollup(config) .then((bundle: any) => { const result = bundle.generate({ format: 'iife' }); const path = join(Config.TMP_DIR, 'bundle.js'); writeFile(path, result.code, (error: any) => { if (error) { console.error(error); process.exit(0); } done(); }); }) .catch((error: any) => { console.error(error); process.exit(0); }); };`

rikup88 commented 7 years ago

Nice, code formatting didn't work for some reason.. Anyway, problem is with named exports: https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module

albpara commented 7 years ago

Thanks mate, I will try your solution!