56 Commits

Author SHA1 Message Date
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
Filipe Silva
db784ec1f4 fix(@angular-devkit/build-optimizer): update typescript to 3.1.5
Fix #12773
2018-11-01 07:49:11 -07:00
cexbrayat
8bc8eca027 docs: remove UglifyJS mention
Now that https://github.com/angular/angular-cli/pull/11996 landed, the CLI uses Terser instead of UglifyJS.
2018-10-31 21:06:25 -07:00
Keen Yee Liau
a3b05a0283 build: Use fine-grained node_module deps
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`
2018-10-31 20:56:27 -07:00
Alan Agius
abf99b5b5e fix(@angular-devkit/build-optimizer): add tslib replacement at top of file
Fixes #12568
2018-10-23 11:52:34 -07:00
Alan Agius
915994da69 fix(@angular-devkit/build-optimizer): update to typescript 3.1.3
This fixes issues related to Microsoft/TypeScript#27341
2018-10-16 11:29:19 -07:00
Alan Agius
91e5fc0bfa build: update to TypeScript 3.1 2018-10-01 07:39:59 -07:00
Charles Lyding
5890759a9f fix(@angular-devkit/build-optimizer): deprecate transform test functions
These were not intended to be part of the public API and will eventually be removed completely.
2018-09-19 11:34:02 -07:00
Charles Lyding
a8a60a7faf refactor(@angular-devkit/build-optimizer): minor type cleanup 2018-09-19 11:34:02 -07:00
Charles Lyding
95f29fbb82 refactor(@angular-devkit/build-optimizer): remove unused import purifier 2018-09-19 11:34:02 -07:00
Charles Lyding
f5314531f5 refactor(@angular-devkit/build-optimizer): correct implicit returns 2018-09-19 11:32:39 -07:00
Alan Agius
b8b36ba339 refactor: pin down all direct dependencies
This is so that CLI users get the same direct dependency versions that were tested on the CI.
2018-09-07 11:01:50 -07:00
Charles Lyding
87db956cab refactor(@angular-devkit/build-optimizer): remove unused helper function 2018-09-07 10:45:46 -07:00
Charles Lyding
74bc8e886b fix(@angular-devkit/build-optimizer): remove deprecated wrap enums check 2018-09-07 10:45:46 -07:00
Charles Lyding
a1ea3a05d4 fix(@angular-devkit/build-optimizer): remove deprecated purify plugin 2018-09-07 10:45:46 -07:00
Alan Agius
a723310e94 feat(@angular-devkit/build-optimizer): update typescript dependency to 3.0.x 2018-09-06 08:28:16 -07:00
Filipe Silva
7c5178c698 feat(@angular-devkit/build-optimizer): correctly identify renamed enums 2018-09-06 08:18:41 -07:00
Filipe Silva
6076e16ebc feat(@angular-devkit/build-optimizer): remove constructor __param 2018-09-06 08:18:41 -07:00
Filipe Silva
2962ede3e3 test(@angular-devkit/build-optimizer): also check method metadata 2018-09-06 08:18:41 -07:00
Filipe Silva
2393ab9aba build: simplify bazel dependencies 2018-08-22 16:36:10 -07:00
Filipe Silva
c03516a81e test(@angular-devkit/build-optimizer): add bazel tests 2018-08-22 16:36:10 -07:00