Bug #28863
closedwebpack tree-shaking removes necessary code from the bundle
Description
The default handling of js modules changed from transpiling them to commonjs in babel 6 to keeping them as es6 modules in babel 7.
Webpack 3 knows how to tree-shake (i.e. remove unused code) es6 modules, but not commonjs modules.
The unfortunate outcome for us here is that all functions that weren’t used by core got removed from the core bundle when foreman gets built. This includes, in this case, propsToSnakeCase which was only used by katello and not in core. However, when katello gets built, these functions don’t get tree-shaken out, resulting in katello js code expecting the function to be available in the core bundle (using a very descriptive name such as W.e). However, since the missing function was removed, the uglification resulted in a different function being assigned to W.e, meaning that when katello tries to call it, it actually triggers a different function, in this case translateObject, which obviously fails as it is used for something completely different.
Updated by The Foreman Bot over 4 years ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/7393 added
Updated by Avi Sharvit over 4 years ago
- Status changed from Ready For Testing to Closed
Applied in changeset 250825845c80525d479f6f95a4546d92b605ad07.