Skip to content

Commit a4581b1

Browse files
fix(bundle): Rollup: Do not warn on THIS_IS_UNDEFINED
1 parent c028447 commit a4581b1

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

rollup.config.js

+15-6
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,31 @@ import progress from 'rollup-plugin-progress';
44
import sourcemaps from 'rollup-plugin-sourcemaps';
55
import visualizer from 'rollup-plugin-visualizer';
66

7-
var MINIFY = process.env.MINIFY;
7+
const MINIFY = process.env.MINIFY;
88

9-
var pkg = require('./package.json');
10-
var banner =
9+
const pkg = require('./package.json');
10+
const banner =
1111
`/**
1212
* ${pkg.description}
1313
* @version v${pkg.version}
1414
* @link ${pkg.homepage}
1515
* @license MIT License, http://www.opensource.org/licenses/MIT
1616
*/`;
1717

18-
var uglifyOpts = { output: {} };
18+
const uglifyOpts = { output: {} };
1919
// retain multiline comment with @license
2020
uglifyOpts.output.comments = (node, comment) =>
2121
comment.type === 'comment2' && /@license/i.test(comment.value);
2222

23-
var plugins = [
23+
const onwarn = (warning) => {
24+
// Suppress this error message... https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined
25+
const ignores = ['THIS_IS_UNDEFINED'];
26+
if (!ignores.some(code => code === warning.code)) {
27+
console.error(warning.message);
28+
}
29+
};
30+
31+
const plugins = [
2432
nodeResolve({jsnext: true}),
2533
progress({ clearLine: false }),
2634
sourcemaps(),
@@ -29,7 +37,7 @@ var plugins = [
2937

3038
if (MINIFY) plugins.push(uglify(uglifyOpts));
3139

32-
var extension = MINIFY ? ".min.js" : ".js";
40+
const extension = MINIFY ? ".min.js" : ".js";
3341

3442
const CONFIG = {
3543
moduleName: '@uirouter/core',
@@ -41,6 +49,7 @@ const CONFIG = {
4149
exports: 'named',
4250
plugins: plugins,
4351
banner: banner,
52+
onwarn: onwarn,
4453
};
4554

4655
export default CONFIG;

0 commit comments

Comments
 (0)