angular-cn/packages/bazel
Alan 4f37487b1c fix(bazel): disable treeshaking when generating FESM and UMD bundles (#32069)
There has been a regression where enabling rollup treeshaking causes errors during runtime because it will drop const access which will always evaluate to true or false. However, such `const` in `@angular/core` cannot be dropped because their value is changed when NGCC is run on `@angular/core`

VE
```
const SWITCH_IVY_ENABLED__POST_R3__ = true;
const SWITCH_IVY_ENABLED__PRE_R3__ = false;
const ivyEnabled = SWITCH_IVY_ENABLED__PRE_R3__;
```

Ivy (After NGCC)
```
const SWITCH_IVY_ENABLED__POST_R3__ = true;
const SWITCH_IVY_ENABLED__PRE_R3__ = false;
const ivyEnabled = SWITCH_IVY_ENABLED__POST_R3__;
```

FESM2015
```
load(path) {
	/** @type {?} */
	const legacyOfflineMode = this._compiler instanceof Compiler;
	return legacyOfflineMode ? this.loadFactory(path) : this.loadAndCompile(path);
}
```

ESM2015
```
 load(path) {
	/** @type {?} */
	const legacyOfflineMode = !ivyEnabled && this._compiler instanceof Compiler;
	return legacyOfflineMode ? this.loadFactory(path) : this.loadAndCompile(path);
}
```

From the above we can see that `ivyEnabled ` is being treeshaken away when generating the FESM bundle which is causing runtime errors such as `Cannot find module './lazy/lazy.module.ngfactory'` since in Ivy we will always load the factories.

PR Close #32069
2019-08-09 14:15:25 -07:00
..
docs build: rules_nodejs 0.26.0 & use @npm instead of @ngdeps now that downstream angular build uses angular bundles (#28871) 2019-02-28 12:06:36 -08:00
src fix(bazel): disable treeshaking when generating FESM and UMD bundles (#32069) 2019-08-09 14:15:25 -07:00
test fix(bazel): disable treeshaking when generating FESM and UMD bundles (#32069) 2019-08-09 14:15:25 -07:00
third_party/github.com/bazelbuild/bazel/src/main/protobuf build: Add .bzl/BUILD files to @angular/bazel package (#28769) 2019-02-19 17:55:57 -08:00
BUILD.bazel refactor(bazel): Remove bazel-workspace schematics (#29148) 2019-03-07 13:04:09 -08:00
index.bzl fix(bazel): use //:tsconfig.json as the default for ng_module (#29670) 2019-04-02 15:57:11 -07:00
package.bzl build: update to nodejs rules 0.34.0 and bazel 0.28.1 (#31824) 2019-07-26 15:01:25 -07:00
package.json build: TypeScript 3.5 upgrade (#31615) 2019-07-25 17:05:23 -07:00
protractor-utils.js build: idiomatic install of @angular/bazel npm package (#26258) (#26488) 2018-10-19 20:59:29 -07:00