Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@angular-devkit/build-angular): babel adjust enum plugin incorrec…
…tly transforming loose enums With Angular Package Format v13, we will be using a more recent version of rollup. Rollup always suffixed exports to avoid collisions, but with the most recent version, the order has changed slightly changed. e.g. previously for `@angular/core`, there were two instances of the `ViewEncapsulation` enum part of the `fesm` bundle. The second instance of the enum orginated from the compiler <--> core facade and it got renamed to avoid conflicts with the actual declaration of `ViewEncapsulation`. Now this has changed, and the first export is being renamed instead. This now breaks at runtime because the first export is being incorrectly transformed by the adjust enum plugin of `build-angular`. The plugin always had this problem of incorrectly transforming the enums, but it never surfaced because only the face enum has been transformed (which is not used at runtime). e.g. consider the following input in `core.mjs`: ``` var ViewEncapsulation$1; (function (ViewEncapsulation) { ViewEncapsulation[ViewEncapsulation["Emulated"] = 0] = "Emulated"; })(ViewEncapsulation$1 || (ViewEncapsulation$1 = {})); ``` this is transformed into: ``` var ViewEncapsulation$1 = /*#__PURE__*/(() => { ViewEncapsulation$1 = ViewEncapsulation$1 || {}; ViewEncapsulation[ViewEncapsulation["Emulated"] = 0] = "Emulated"; }()); ``` Note how the enum assignment for `Emulated` incorrectly still uses the non-suffixed identifier that previously was part of the callee wrapper function.
- Loading branch information