76 Commits

Author SHA1 Message Date
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
Charles Lyding
7d6b502387 fix(@angular-devkit/build-optimizer): remove deprecated test functions from public API 2019-05-13 15:55:52 -07:00
Renovate Bot
da1f3386d0 build: update typescript to version 3.4.5 (#14258) 2019-05-07 12:30:53 -06:00
Alan
ccbac7cd21 fix(@angular-devkit/build-optimizer): don't add pure comments in call expressions
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
2019-04-24 07:17:26 -10:00
Alex Eagle
a197615549 build: update jasmine_node_test rules to come from npm 2019-04-22 08:38:00 -07:00
Alex Eagle
ee619c9a34 build: run Bazel format/lint fix 2019-04-22 08:38:00 -07:00
Renovate Bot
217afe5def build: update typescript to version 3.4.4 2019-04-19 10:53:37 -07:00
Filipe Silva
b6b00ebc98 build: update typescript to version 3.4.3 2019-04-13 10:23:02 -07:00
Renovate Bot
4782b1b3a4 build: update typescript to version 3.3.4000 2019-03-22 15:32:04 -07:00
Filipe Silva
6e3d2e0c4d feat(@ngtools/webpack): support Angular 8
This requires updating projects to TypeScript 3.3
2019-03-20 12:29:01 -07:00
Hans Larsen
08e91a94ab build: refactor QoL on monorepo.json
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.
2019-03-13 13:51:01 -07:00
Alan
b32ad328cf fix(@angular-devkit/build-optimizer): don't add pure comments inside arrow functions
Fixes #13768
2019-03-11 13:45:00 -07:00
Alex Eagle
4e262f966f build: Update to latest bazel rules 2019-03-06 11:27:48 -08:00
Filipe Silva
733efe71e3 fix(@angular-devkit/build-optimizer): prefix renamed extended classes (#13613)
Fix #11796
2019-02-07 08:28:19 -08:00
Alan Agius
e12adf4dcb refactor: create helper functions for pure comments 2019-01-23 10:09:47 -08:00
Alan
7d868947e2 feat(@angular-devkit/build-optimizer): add support for es2015 enums emitted by tsickle
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
2019-01-22 09:39:07 -08:00
Filipe Silva
35b0594f91 feat(@angular-devkit/build-optimizer): also fold ES2015 classes
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
2019-01-22 09:38:48 -08:00
Filipe Silva
6f8c336346 fix(@angular-devkit/build-optimizer): identify relative imports in angular core
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.
2019-01-18 12:01:37 -08:00
Filipe Silva
07ceb05985 fix(@angular-devkit/build-optimizer): prefix renamed classes
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.
2019-01-18 12:01:37 -08:00
Alan Agius
a6102b2d50 build: pin typescript and webpack
Pin these two dependencies so that Renovate can succesfully update all these within the monorepo at once without the need of any manual interventation
2019-01-18 11:56:33 -08:00
Filipe Silva
f7c6719f73 fix(@angular-devkit/build-optimizer): support windows paths in rollup plugin 2019-01-11 14:08:21 -08:00
Renovate Bot
881966bbc8 build: update loader-utils to version 1.2.3 2019-01-08 13:41:41 -08:00
Renovate Bot
3e8c461670 build: update loader-utils to version 1.2.1 2018-12-26 11:33:24 -08:00
Alan Agius
b071d1cd1d build: update several dependencies
This is so that renovate won't trigger for these dependencies
2018-12-21 09:31:20 -08:00
Alan Agius
5111d15ff2 build: update to TypeScript 3.2 and Angular 7.2 RC 2018-12-19 10:55:05 -08:00
Alan Agius
717b02f533 ci: add ts api guardian (#12010)
* 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`
2018-11-30 11:53:54 -08:00
Alan Agius
53118c6224 build: update typescript to 3.1.6 (#12849)
* fix(@angular-devkit/build-optimizer): update typescript to 3.1.6

* build: update typescript to 3.1.6
2018-11-06 22:46:37 -08:00
Keen Yee Liau
db78228fc4 build: add external block for tsconfig in test targets (#12879) 2018-11-06 11:12:21 -08:00