fix(angular): throw when polyfills is provided with an array for webpack-browser and angular 14 (#14742)

This commit is contained in:
Leosvel Pérez Espinosa 2023-02-01 17:34:39 +01:00 committed by GitHub
parent 0602b84140
commit f02d0e4d1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 5 deletions

View File

@ -75,7 +75,7 @@
"oneOf": [
{
"type": "array",
"description": "A list of polyfills to include in the build. Can be a full path for a file, relative to the current workspace or module specifier. Example: 'zone.js'.",
"description": "A list of polyfills to include in the build. Can be a full path for a file, relative to the current workspace or module specifier. Example: 'zone.js'. _Note: supported in Angular versions >= 15.0.0_.",
"items": { "type": "string", "uniqueItems": true },
"default": []
},

View File

@ -41,7 +41,7 @@
"oneOf": [
{
"type": "array",
"description": "A list of polyfills to include in the build. Can be a full path for a file, relative to the current workspace or module specifier. Example: 'zone.js'.",
"description": "A list of polyfills to include in the build. Can be a full path for a file, relative to the current workspace or module specifier. Example: 'zone.js'. _Note: supported in Angular versions >= 15.0.0_.",
"items": {
"type": "string",
"uniqueItems": true

View File

@ -1,12 +1,13 @@
import { joinPathFragments } from '@nrwl/devkit';
import { joinPathFragments, stripIndents } from '@nrwl/devkit';
import { existsSync } from 'fs';
import { from, Observable } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import { getInstalledAngularVersionInfo } from '../../executors/utilities/angular-version-utils';
import { createTmpTsConfigForBuildableLibs } from '../utilities/buildable-libs';
import {
mergeCustomWebpackConfig,
resolveIndexHtmlTransformer,
} from '../utilities/webpack';
import { createTmpTsConfigForBuildableLibs } from '../utilities/buildable-libs';
import { switchMap } from 'rxjs/operators';
export type BrowserBuilderSchema =
import('@angular-devkit/build-angular/src/builders/browser/schema').Schema & {
@ -108,10 +109,19 @@ function buildAppWithCustomWebpackConfiguration(
);
}
function validateOptions(options: BrowserBuilderSchema): void {
const { major, version } = getInstalledAngularVersionInfo();
if (major < 15 && Array.isArray(options.polyfills)) {
throw new Error(stripIndents`The array syntax for the "polyfills" option is supported from Angular >= 15.0.0. You are currently using ${version}.
You can resolve this error by removing the "polyfills" option, setting it to a string value or migrating to Angular 15.0.0.`);
}
}
export function executeWebpackBrowserBuilder(
options: BrowserBuilderSchema,
context: import('@angular-devkit/architect').BuilderContext
): Observable<import('@angular-devkit/architect').BuilderOutput> {
validateOptions(options);
options.buildLibsFromSource ??= true;
if (!options.buildLibsFromSource) {