Project

General

Profile

Actions

Bug #28863

closed

webpack tree-shaking removes necessary code from the bundle

Added by Avi Sharvit about 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
JavaScript stack
Target version:
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

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.

Actions #1

Updated by The Foreman Bot about 4 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/7393 added
Actions #2

Updated by The Foreman Bot about 4 years ago

  • Fixed in Releases 2.0.0 added
Actions #3

Updated by Avi Sharvit about 4 years ago

  • Status changed from Ready For Testing to Closed
Actions

Also available in: Atom PDF