perf(@angular-devkit/build-angular): skip FESM2015 from async transformation

Skip  `async` transformation when the path matches a FESM2015 entrypoint.  Ng-packagr doesn't allow changing the script target for entry-points which makes this possible https://github.com/ng-packagr/ng-packagr/blob/master/src/lib/ng-package/entry-point/compile-ngc.transform.ts#L48

This is important to reduce greatly the cold build performance overhead when targeting ES2017+
This commit is contained in:
Alan Agius 2021-03-12 13:01:24 +01:00
parent 9714aa92bf
commit 63a2dbb8b4

View File

@ -98,7 +98,7 @@ export default custom<AngularCustomOptions>(() => {
// TypeScript files will have already been downlevelled
customOptions.forceES5 = !/\.tsx?$/.test(this.resourcePath);
} else if (esTarget >= ScriptTarget.ES2017) {
customOptions.forceAsyncTransformation = source.includes('async');
customOptions.forceAsyncTransformation = !/[\\\/]fesm2015[\\\/]/.test(this.resourcePath) && source.includes('async');
}
shouldProcess ||= customOptions.forceAsyncTransformation || customOptions.forceES5;
}