I’m new here, so I hope I’m doing everything right. If not, I’ll take criticism gladly!
When developing a web application I use three.js. I have included the npm module “three” in my package.json as prescribed. Everything works fine so far.
While analyzing the bundle with the webpack-bundle-analyzer for webpack I noticed that the three.js and the three.module.js become part of my bundle:
- three.js: ~140KB
- three.module.js: ~136KB
To be able to use three in all my classes, I use the ProvidePlugin with which I make the module available globally - this replaces the constant import.
Now the question: Do both files really have to be part of my bundle? I manually manipulated the /node_modules/three/package.json and entered only the three.module.js under “main”, as well as removed the three.js in all places. So only the three.module.js are loaded and this approach reduces my bundle size considerably - without (so far noticeable) loss of functionality. But can a loss of functionality occur in the future?
Should only one of the two files become part of the bundle during the normal import of three.js, or am I perhaps doing something wrong with the ProvidePlugin?
Thanks in advance!