I created this example
module.js
import moment from "moment";
export function square(x) {
return x * x;
}
export function cube(x) {
return moment.format(x * x * x);
}
main.js
import {square} from "./module";
console.log(square(1));
I noticed that it also includes moment library in my bundle although I don't use it in square function.. If I remove the moment import from module.js tree shaking works fine and i only see square in my bundle.
Is this how tree shaking suppose to work? is there a workaround except than splitting my code in different files if I want to use an external library in my module.js file?