From 63a2dbb8b42c6c62e37b27c42238860f7e57b87f Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Fri, 12 Mar 2021 13:01:24 +0100 Subject: [PATCH] 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+ --- .../angular_devkit/build_angular/src/babel/webpack-loader.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/angular_devkit/build_angular/src/babel/webpack-loader.ts b/packages/angular_devkit/build_angular/src/babel/webpack-loader.ts index d514fc628b50..899a43be1706 100644 --- a/packages/angular_devkit/build_angular/src/babel/webpack-loader.ts +++ b/packages/angular_devkit/build_angular/src/babel/webpack-loader.ts @@ -98,7 +98,7 @@ export default custom(() => { // 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; }