angular-cn/packages/bazel/test/ng_package
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
..
example build: convert entry_point to label (#30627) 2019-06-11 00:03:11 +00:00
BUILD.bazel build: convert entry_point to label (#30627) 2019-06-11 00:03:11 +00:00
common_package.spec.ts fix(common): add upgrade sub-package to ng_package rule for @angular/common (#30117) 2019-04-25 15:01:17 -07:00
core_package.spec.ts fix(bazel): disable treeshaking when generating FESM and UMD bundles (#32069) 2019-08-09 14:15:25 -07:00
example-custom-entry-point-name.golden build(bazel): use ng_package entry_point_name for umd bundles (#23132) 2018-04-05 14:51:31 -07:00
example_package.golden build: TypeScript 3.5 upgrade (#31615) 2019-07-25 17:05:23 -07:00
example_package.spec.ts test(bazel): re-enable ng_package golden testing on ci (#27829) 2019-01-07 14:46:47 -08:00