103 Commits

Author SHA1 Message Date
Filipe Silva
b668cacd45 refactor: use BUILD.bazel instead of BUILD
Using an extension gives editors a chance to figure out the correct language syntax to use.
2020-04-07 09:07:19 -07:00
Filipe Silva
456bbffee5 build: add module_name to @angular-devkit/build-optimizer Bazel rule 2020-04-07 09:07:19 -07:00
Charles Lyding
6e33f447a6 refactor(@angular-devkit/build-optimizer): remove casts from tslib helper check 2020-04-06 09:55:58 -07:00
Charles Lyding
4509d3c112 fix(@angular-devkit/build-optimizer): use TypeScript 3.6
Fixes: #17320
2020-04-06 09:55:58 -07:00
Renovate Bot
de68dab2c6 build: update loader-utils to version 2.0.0 2020-03-19 09:47:50 -07:00
Renovate Bot
b5a475d3d4 build: update typescript to version 3.8.3 2020-03-03 13:37:35 -08:00
Charles Lyding
0db3a699d4 refactor(@angular-devkit/build-optimizer): update to use TypeScript 3.8 2020-03-02 14:05:31 -08:00
Renovate Bot
d54ad29023 build: update tslib to version 1.11.1 2020-02-28 12:27:36 -08:00
Renovate Bot
816b37a14c build: update tslib to version 1.11.0 2020-02-25 10:11:11 -08:00
Renovate Bot
78cf0c7c32 build: update loader-utils to version 1.4.0 2020-02-24 12:37:15 -08:00
Alan Agius
f635479cef build: update nodejs rules to 1.0+ 2020-01-27 11:03:51 -08:00
Alan Agius
049fc792a5 revert: "fix(@angular-devkit/build-optimizer): wrap classes which contain empty statements (#16538)"
This reverts commit 4cde9228df5118a6c743467c668b6b7c5fe73013.
2020-01-17 08:13:16 -08:00
Filipe Silva
8716adff38 fix(@angular-devkit/build-optimizer): revert to using TS 3.6
Workaround for https://github.com/microsoft/TypeScript/issues/36098.

Should go back to 3.7 once it is fixed.
2020-01-09 13:43:49 -08:00
Filipe Silva
86d4385440 build: use TypeScript 3.7 2020-01-09 13:43:49 -08:00
Charles Lyding
a1dede16ee fix(@angular-devkit/build-optimizer): improve quality of sourcemaps 2020-01-09 12:02:32 -08:00
Alan Agius
4cde9228df fix(@angular-devkit/build-optimizer): wrap classes which contain empty statements (#16538)
NGCC currently produces empty statments which breaks class wrapping.

Closes #16509
2020-01-04 11:15:39 -08:00
Filipe Silva
c3a4c454be fix(@angular-devkit/build-optimizer): update ɵsetClassMetadata call format
It's in a IIFE after https://github.com/angular/angular/pull/33337 lands.
2019-11-20 17:31:19 -08:00
Filipe Silva
7502b73b3c fix(@angular-devkit/build-optimizer): don't remove ɵɵsetNgModuleScope calls
These will be automatically removed after https://github.com/angular/angular/pull/33671 lands because they are in a side-effect free IIFE.
2019-11-20 17:31:19 -08:00
Alan Agius
e31d5d89b7 build: update bazel packages 2019-10-24 12:05:25 -07:00
Filipe Silva
7612d3e200 build: use TS 3.6.4 2019-10-16 10:00:49 -07:00
Alan Agius
f943d3a8dc refactor(@angular-devkit/build-angular): rename ngModuleDef to ɵmod 2019-10-16 05:56:23 -07:00
Filipe Silva
07bfd1eeb3 fix(@angular-devkit/build-optimizer): remove deprecated testImportTslib 2019-10-03 14:42:04 -07:00
Filipe Silva
c2b13a7683 feat(@angular-devkit/build-optimizer): don't use getImportTslibTransformer
This transformer can cause size regressions when it introduces `tslib` imports across independent chunks.

It should be deprecated because tslib adoption has become more ubiquitous.

Should also speed up Build Optimizer processing time because there's one less thing to do.

Closes https://github.com/angular/angular-cli/issues/15401 without adding the warning, because some libraries like zone.js should inline the helpers.
2019-10-03 14:42:04 -07:00
Alan Agius
ae36fbcd8e fix(@angular-devkit/build-optimizer): fix error when __decorate has no __metadata
When a `__decorator` expression has no `__metadata` call, example:

```js
__decorate([
    ContentChild('heading', { read: ElementRef, static: true })
], FooBarComponent.prototype, "buttons", void 0);
```

A `Cannot read property 'kind' of undefined` error will be thrown.

Closes: #15703
2019-10-01 11:23:54 -07:00
Filipe Silva
5564ce6ea1 feat(@angular-devkit/build-optimizer): scrub ɵsetClassMetadata and ɵɵsetNgModuleScope calls 2019-09-25 09:43:21 -07:00
Filipe Silva
b1f7537342 refactor(@angular-devkit/build-optimizer): refactor assignment expression identification 2019-09-25 09:43:21 -07:00
Filipe Silva
016977c9ff fix(@angular-devkit/build-optimizer): remove unecessary scrub file checks 2019-09-25 09:43:21 -07:00
Alan Agius
4df025f5f1 fix(@angular-devkit/build-optimizer): don't mark tslib helpers which are suffixed with $ and a number as pure (#15451)
Closes #15392
2019-08-27 10:26:03 -07:00
Alan Agius
59d80f52be fix(@angular-devkit/build-optimizer): replace multiple tslib helpers (#15400)
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`
2019-08-23 11:35:42 -07:00
Alan Agius
e2bb482b44 fix(@angular-devkit/build-optimizer): don't add pure comments to tslib helpers (#15303)
Closes #15301
2019-08-12 11:07:24 -07:00
Filipe Silva
4826378706 fix(@angular-devkit/build-angular): consider local decl in angular core files to be metadata too
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.
2019-08-08 08:28:20 -07:00
Renovate Bot
44f9141a56 build: update webpack-sources to version 1.4.3 2019-08-08 08:26:45 -07:00
Charles Lyding
74536d0df0 refactor(@angular-devkit/build-optimizer): update to use latest source-map version (0.7.3)
The latest version provides significant performance improvements.
2019-08-08 08:26:15 -07:00
Filipe Silva
804c11de8d fix(@angular-devkit/build-optimizer): scrub all metadata form @angular/core
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.
2019-08-02 13:35:39 -07:00
Filipe Silva
fefa2ef15c fix(@angular-devkit/build-optimizer): scrub previously whitelisted angular classes
This whitelist a leftover from older Angular versions and isn't necessary anymore.

Fix #15194
2019-08-02 13:35:39 -07:00
Renovate Bot
bf47da3065 build: update webpack-sources to version 1.4.1 2019-07-31 13:27:14 -07:00
Alan Agius
20b16a247a fix(@angular-devkit/build-optimizer): don't wrap classes which static properties have been removed
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.
2019-07-30 14:25:06 -07:00
Alan Agius
ab80209c92 fix(@angular-devkit/build-optimizer): don't wrap enum like nodes which are inside of methods.
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
2019-07-29 10:47:28 -07:00
Filipe Silva
e8dff5718f build: update to TS 3.5 2019-07-29 10:15:23 -07:00
Alan Agius
15ef15e94a style: remove redundant max-line-length disables and fix other lint issues 2019-07-24 19:06:21 -07:00
Alan
2676c2d86a refactor(@angular-devkit/build-optimizer): refactor wrap enums
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
2019-07-11 19:11:51 -07:00
Filipe Silva
9d9d46bab3 refactor: use buildOptimizerLoaderPath 2019-07-11 01:18:26 +08:00
Filipe Silva
7d9ead4261 feat(@angular-devkit/build-optimizer): add BuildOptimizerWebpackPlugin
Using this webpack allows determining in advance if files from a package should be skipped by the Build Optimizer loader.
2019-07-11 01:18:26 +08:00
Charles Lyding
8752f21abd fix(@angular-devkit/build-optimizer): wrap classes with a let variable
Classes can technically be re-assigned.  By using a let variable this behavior will be retained and prevent potential runtime errors.

Fixes #14930
2019-07-10 04:14:07 +08:00
Alan
70a4cbe306 style: enable no-debugger and no-console tslint rules 2019-06-27 09:28:35 -07:00
Alan
3bb67d81fb fix(@angular-devkit/build-optimizer): incorrectly augmented ES2015 default class exports
Fixes #14769
2019-06-18 18:27:52 -07:00
Alan Agius
c9535a53c2 fix(@angular-devkit/build-optimizer): wrap TypeScript string enums in IIFE
Fixes #14786
2019-06-18 18:27:13 -07:00
Alan Agius
8d479c93d2 test: add test to verify that the new es2015 class wrapping logic handles wrapping of tslib and tsickle classes
Related to https://github.com/ngrx/platform/issues/1905 and https://github.com/ng-packagr/ng-packagr/issues/1307

Fixes #14613
2019-06-06 14:15:30 -07:00
Alan Agius
8104fce690 fix(@angular-devkit/build-optimizer): wrap ClassDeclarations in an IIFE for better treeshaking
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
2019-06-06 14:15:30 -07:00
Alan Agius
f5200775f9 fix(@angular-devkit/build-optimizer): wrap es2015 class expressions for better tree-shaking
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/14610

Fixes #14577
2019-06-06 14:15:30 -07:00