From cfdd3ab9eea7d1f2cff9a5bf4440d82a9d78e315 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Sat, 20 Nov 2021 18:31:34 -0300 Subject: [PATCH 1/3] feat(webpack): support NG 13 and zone async/await --- .../webpack5/src/configuration/angular.ts | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/packages/webpack5/src/configuration/angular.ts b/packages/webpack5/src/configuration/angular.ts index c507542440..7031614c1c 100644 --- a/packages/webpack5/src/configuration/angular.ts +++ b/packages/webpack5/src/configuration/angular.ts @@ -1,5 +1,6 @@ import { extname, resolve } from 'path'; import { merge } from 'webpack-merge'; +import { ScriptTarget } from 'typescript'; import Config from 'webpack-chain'; import { existsSync } from 'fs'; @@ -12,7 +13,10 @@ import { } from '../helpers/platform'; import base from './base'; -export default function (config: Config, env: IWebpackEnv = _env): Config { +export default async function ( + config: Config, + env: IWebpackEnv = _env +): Promise { base(config, env); const platform = getPlatformName(); @@ -167,6 +171,27 @@ export default function (config: Config, env: IWebpackEnv = _env): Config { .use('angular-hot-loader') .loader('angular-hot-loader'); }); + // zone + async/await + config.module + .rule('angular-webpack-loader') + .test(/\.[cm]?[tj]sx?$/) + .exclude.add( + /[/\\](?:core-js|@babel|tslib|web-animations-js|web-streams-polyfill)[/\\]/ + ) + .end() + .resolve.set('fullySpecified', false) + .end() + .before('angular') + .use('webpack-loader') + .loader( + require.resolve( + '@angular-devkit/build-angular/src/babel/webpack-loader' + ) + ) + .options({ + scriptTarget: ScriptTarget.ESNext, + aot: true, + }); } // look for platform specific polyfills first From d644d23a118c3dc6d8203e0edea81dde23afd819 Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Tue, 30 Nov 2021 16:42:01 +0100 Subject: [PATCH 2/3] chore: cleanup --- packages/webpack5/src/configuration/angular.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/webpack5/src/configuration/angular.ts b/packages/webpack5/src/configuration/angular.ts index 7031614c1c..d4d46566bf 100644 --- a/packages/webpack5/src/configuration/angular.ts +++ b/packages/webpack5/src/configuration/angular.ts @@ -1,6 +1,5 @@ -import { extname, resolve } from 'path'; -import { merge } from 'webpack-merge'; import { ScriptTarget } from 'typescript'; +import { extname, resolve } from 'path'; import Config from 'webpack-chain'; import { existsSync } from 'fs'; @@ -13,10 +12,7 @@ import { } from '../helpers/platform'; import base from './base'; -export default async function ( - config: Config, - env: IWebpackEnv = _env -): Promise { +export default function (config: Config, env: IWebpackEnv = _env): Config { base(config, env); const platform = getPlatformName(); From 31c97b199a94f838d8a871dade43825fb69fbae9 Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Tue, 30 Nov 2021 16:50:40 +0100 Subject: [PATCH 3/3] chore: remove require.resolve and update snapshots --- .../__snapshots__/angular.spec.ts.snap | 40 +++++++++++++++++++ .../webpack5/src/configuration/angular.ts | 6 +-- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/packages/webpack5/__tests__/configuration/__snapshots__/angular.spec.ts.snap b/packages/webpack5/__tests__/configuration/__snapshots__/angular.spec.ts.snap index c888c2aad2..6ceffde13d 100644 --- a/packages/webpack5/__tests__/configuration/__snapshots__/angular.spec.ts.snap +++ b/packages/webpack5/__tests__/configuration/__snapshots__/angular.spec.ts.snap @@ -185,6 +185,26 @@ exports[`angular configuration for android 1`] = ` } ] }, + /* config.module.rule('angular-webpack-loader') */ + { + test: /\\\\.[cm]?[tj]sx?$/, + exclude: [ + /[/\\\\\\\\](?:core-js|@babel|tslib|web-animations-js|web-streams-polyfill)[/\\\\\\\\]/ + ], + use: [ + /* config.module.rule('angular-webpack-loader').use('webpack-loader') */ + { + loader: '@angular-devkit/build-angular/src/babel/webpack-loader', + options: { + scriptTarget: 99, + aot: true + } + } + ], + resolve: { + fullySpecified: false + } + }, /* config.module.rule('angular') */ { test: /(?:\\\\.ngfactory.js|\\\\.ngstyle\\\\.js|\\\\.ts)$/, @@ -573,6 +593,26 @@ exports[`angular configuration for ios 1`] = ` } ] }, + /* config.module.rule('angular-webpack-loader') */ + { + test: /\\\\.[cm]?[tj]sx?$/, + exclude: [ + /[/\\\\\\\\](?:core-js|@babel|tslib|web-animations-js|web-streams-polyfill)[/\\\\\\\\]/ + ], + use: [ + /* config.module.rule('angular-webpack-loader').use('webpack-loader') */ + { + loader: '@angular-devkit/build-angular/src/babel/webpack-loader', + options: { + scriptTarget: 99, + aot: true + } + } + ], + resolve: { + fullySpecified: false + } + }, /* config.module.rule('angular') */ { test: /(?:\\\\.ngfactory.js|\\\\.ngstyle\\\\.js|\\\\.ts)$/, diff --git a/packages/webpack5/src/configuration/angular.ts b/packages/webpack5/src/configuration/angular.ts index d4d46566bf..629efdaaa9 100644 --- a/packages/webpack5/src/configuration/angular.ts +++ b/packages/webpack5/src/configuration/angular.ts @@ -179,11 +179,7 @@ export default function (config: Config, env: IWebpackEnv = _env): Config { .end() .before('angular') .use('webpack-loader') - .loader( - require.resolve( - '@angular-devkit/build-angular/src/babel/webpack-loader' - ) - ) + .loader('@angular-devkit/build-angular/src/babel/webpack-loader') .options({ scriptTarget: ScriptTarget.ESNext, aot: true,