I have some issues with tree shaking in my webpack 3 configuration (maybe) because I use a lot of re-exports. I'd like to keep the reexports but avoid the unnecessary increase in my bundle size. (Plus I'd also like to avoid unnecessary code in my dev build) So I was wondering if there is a way to like "follow" the imports through the files and replace them with a direct path to the module.
Code 1:
index.js:
import {x} from './Folder1';
Folder1/index.js:
export {x} from './Folder2';
export {y} from './SomeOtherFolder';
Folder1/Folder2/index.js:
export {x} from './x.js';
So (without tree shaking and sometimes with webpack's somehow broken tree shaking) x
and y
would be included in my bundle, which wouldn't happen if I had the following import statement:
Code 2
index.js:
import {x} from './Folder1/Folder2/x.js';
Well... is it possible to get from Code 1 to Code 2 during the build process with webpack (or any other tool)?