When using React, for example, and defining defaultProps will not allow rollup to tree-shake the class from the outputted bundle.
The rollup/repl can be found here.
main.js
import { IncludeMe } from './maths.js';
IncludeMe();
maths.js
class AnUnusedClass {
}
AnUnusedClass.defaultProps = {}
function IncludeMe() {
console.log('bla');
}
export { AnUnusedClass };
export { IncludeMe }
output:
(function () {
'use strict';
class AnUnusedClass {
}
AnUnusedClass.defaultProps = {};
function IncludeMe() {
console.log('bla');
}
IncludeMe();
}());
When using React, for example, and defining defaultProps will not allow rollup to tree-shake the class from the outputted bundle.
The rollup/repl can be found here.
main.js
maths.js
output: