diff --git a/packages/bazel/src/ng_package/ng_package.bzl b/packages/bazel/src/ng_package/ng_package.bzl index c2f77e13c494a..99b557f764445 100644 --- a/packages/bazel/src/ng_package/ng_package.bzl +++ b/packages/bazel/src/ng_package/ng_package.bzl @@ -112,11 +112,13 @@ def _rollup(ctx, bundle_name, rollup_config, entry_point, inputs, js_output, for args.add("--amd.id", package_name) # After updating to build_bazel_rules_nodejs 0.27.0+, rollup has been updated to v1.3.1 - # which tree shakes @__PURE__ annotations by default. We turn this feature off - # for ng_package as Angular bundles contain these annotations and there are - # test failures if they are removed. See comments in - # https://github.com/angular/angular/pull/29210 for more information. - args.add("--no-treeshake.annotations") + # which tree shakes @__PURE__ annotations and const variables which are later ammended by NGCC. + # We turn this feature off for ng_package as Angular bundles contain these and there are + # test failures if they are removed. + # See comments in: + # https://github.com/angular/angular/pull/29210 + # https://github.com/angular/angular/pull/32069 + args.add("--no-treeshake") # Note: if the input has external source maps then we need to also install and use # `rollup-plugin-sourcemaps`, which will require us to use rollup.config.js file instead diff --git a/packages/bazel/test/ng_package/core_package.spec.ts b/packages/bazel/test/ng_package/core_package.spec.ts index 934ad3682cf80..81f68ce93e41d 100644 --- a/packages/bazel/test/ng_package/core_package.spec.ts +++ b/packages/bazel/test/ng_package/core_package.spec.ts @@ -133,6 +133,10 @@ describe('@angular/core ng_package', () => { } else { it('should have decorators', () => { expect(shx.cat('fesm5/core.js')).toContain('__decorate'); }); + + // See: https://github.com/angular/angular/pull/32069 + it('should retain access to const', + () => { expect(shx.cat('fesm5/core.js')).toContain('!ivyEnabled'); }); } it('should load tslib from external bundle', () => {