With this change we wrap ClassDeclarations inside an IIFE, also we move some code from the class fold into the wrap-enums.
This changes the below code:
```js
export class Foo {
method() {
}
}
Foo.bar = 'barValue';
__decorate([
methodDecorator
], Foo.prototype, "method", null);
```
to
```js
export const Foo = /*@__PURE__*/ (() => {
class Foo {
method() {
}
}
Foo.bar = 'barValue';
__decorate([
methodDecorator
], Foo.prototype, "method", null);
return Foo;
})();
```
Fixes#14610
ClassExpressions such as the below are not treeshakable unless we wrap them in an IIFE
```js
let AggregateColumnDirective = class AggregateColumnDirective {
constructor(viewContainerRef) { }
};
AggregateColumnDirective = __decorate([
Directive({}),
__metadata("design:paramtypes", [ViewContainerRef])
], AggregateColumnDirective);
```
With this change we wrap the above in an IIFE and mark it as a PURE function.
```js
const AggregateColumnDirective = /*@__PURE__*/ (() => {
let AggregateColumnDirective = class AggregateColumnDirective {
constructor(viewContainerRef) { }
};
AggregateColumnDirective = __decorate([
Directive({}),
__metadata("design:paramtypes", [ViewContainerRef])
], AggregateColumnDirective);
return AggregateColumnDirective;
})();
```
With this pattern if the class is unused it will be dropped.
Note: In future we should rename `wrap-enums` to something more generic, and combine class-fold with this transformer especially considering the future fix that needs to be done for https://github.com/angular/angular-cli/issues/14610Fixes#14577
When we removed tsickle from the library compilation pipeline the emitted JS changes for Classes.
With tsc a class can be of kind CallExpression because of this syntax
```
let Foo = class Foo {
constructor() {
this.isExpandedChange = new EventEmitter();
}
set isExpanded(value) {
this.isExpandedChange.emit(value);
}
};
```
In such case we shall not add `/*@__PURE__*/` inside this class
Fixes#14084
This should make it easier to manage and diff. This takes 2 things into account:
1. we have either stable or experimental versions and each are kept in monorepo.
2. we dont keep hash and update only changed packages.
This commit also removed the hash to make sure this does not happen.
tsickle emits es2015 enums with an object literal followed by an export declaration
Example:
```
const RendererStyleFlags3 = {
Important: 1,
DashCase: 2,
};
export { RendererStyleFlags3 };
RendererStyleFlags3[RendererStyleFlags3.Important] = 'Important';
RendererStyleFlags3[RendererStyleFlags3.DashCase] = 'DashCase';
```
This PR adds support for the enums to be optimized by wrapping them in an iife and marks them as pure.
Fixes#13488
Although ES5 classes had their static properties folded in, ES2015 ones did not.
This PR adds that new functionality.
It should also make this particular transform a bit faster since it will stop early.
Fix https://github.com/angular/angular-cli/issues/13487
Build optimizer was broken for non-FESM files inside @angular/core because it couldn't identify relative imports were still inside core.
This change adds a known list of angular core files as a default, and also allows passing in a override.
Module concatenation may rename classes with the same name. The renaming logic is specific to the bundler so we can't really foresee it.
But the fact remains that the inner function declaration doesn't need to have the same name as the outer one.
* refactor: fix `import` and `export` paths to work with classic resolution
`ts-api-guardian` only support classic module resolution which means that we need to specify `index` so that the resolution works.
* build: add `npm_package` to packages
* build: add ts-api-guardian to repo
* test: add api golden files
* refactor: use proper namespace instead of alias export
* refactor: use proper namspace einstead of alias export
* build: add `_golden_api` files
At the moment ts api guardian doesn't support aliased symbols as namespaces, this is a workaround to still have namespaced symbols in the final golden file.
* build: update angular archive for workspace
* test: fix reference to `TestHost` to use namespace
* refactor: create `fs` namespace instead of aliased export
* test: update api golden file for `@angular-devkit/core/node`
This commit updates the BUILD files to specify fine-grained node_module deps
by replacing "@typings" comments with actual @npm node module.
Moved tools/bazel.rc -> .bazelrc
Removed "jasmine" typings from base tsconfig.json
Added @bazel/karma to devDependencies, needed for `ts_web_test`