Open olivermuc opened 7 years ago
Have you tried this @olivermuc? https://github.com/rollup/rollup-plugin-commonjs#custom-named-exports
Thx @langley-agm - will give it a shot shortly.
I also have this problem and tried the rollup commonjs workaround, but now encounter this error: Error parsing /....../node_modules/angular2-logger/app/core/level.ts: Unexpected token (9:7) in /....../node_modules/angular2-logger/app/core/level.ts
For some reason rollup is trying to parse a Typescript file from the core.js require. I don't know what to do about this.
I must be doing something wrong, it's not working despite @olivermuc solution. Seems like it completely ignores 'namedExports'. Running 'rollup-plugin-commonjs' version '^8.0.0'. Anybody any clues?
'use strict';
import commonjs from 'rollup-plugin-commonjs';
import nodeResolve from 'rollup-plugin-node-resolve'
import uglify from 'rollup-plugin-uglify'
import chalk from 'chalk';
const seen = new Set();
if (!process.stderr.isTTY) {
chalk.enabled = false;
}
const warnSymbol = process.stderr.isTTY ? `Warning: ` : `Warning: `;
const stderr = console.error.bind(console);
const handleWarning = warning => {
const str = warning.toString();
if (seen.has(str)) {
return;
}
seen.add(str);
stderr(`${warnSymbol}${chalk.bold(warning.message)}`);
if (warning.url) {
stderr(chalk.cyan(warning.url));
}
if (warning.loc) {
stderr(`${warning.loc.file} (${warning.loc.line}:${warning.loc.column})`);
}
if (warning.frame) {
stderr(chalk.dim(warning.frame));
}
stderr('');
};
const warnFilter = /The 'this' keyword is equivalent to 'undefined'/;
export default {
entry: './dist/out-tsc/src/main-aot.js',
dest: 'aot/dist/build.min.js', // output a single application bundle
sourceMap: true,
sourceMapFile: 'aot/dist/build.min.js.map',
treeshake: true,
format: 'iife',
onwarn: warning => { // overwite the default warning function
const str = warning.toString();
if (warnFilter.test(str)) {
return;
}
handleWarning(warning);
},
plugins: [
nodeResolve({jsnext: true, module: true}),
commonjs({
include: [
'node_modules/rxjs/**',
],
namedExports: {
'node_modules/angular2-logger/core.js': ['Logger', 'Options']
}
}),
uglify()
]
}
Following the install instructions & getting this with ionic 2: