Inlined tslib helpers can be suffixed with `$` and a number when having multiple helpers in the same file.
With this change we will replace all tslib inline helpers to imports from `tslib`
Followup to https://github.com/angular/angular-cli/pull/15239, fixes a 6kb size regression in new apps, potentially more in larger apps.
Local declarations inside `@angular/core` files should also be considered metadata and scrubbed.
We used to keep a specifier list of known specifiers to identify the `@angular/core` FESM. But it doesn't work for non-FESM bundles, and we already pass that information on anyway.
At the moment the `wrap-enums` transfomers is being run prior to `scrub-file` and this is resulting classes which all static properties have been dropped to be wrapped in IIFE.
With this change we stop recursive lookup when the current node is not a BlockLike.
This change should also, improve the BO overall speed as it's reduces a lot of recursive lookups.
Fixes#15145
Most of the logic that can find class statements to wrap can be used to wrap Enums, with the exception of TS 2.3+ enums which is slightly different.
This PR combines the enums and classes lookup logic and also simplifies the TS 2.3+ enum lookup logic
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`