-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(angular): sync missing schema changes in builders (#15600)
- Loading branch information
1 parent
5b8a663
commit 6c9a0e3
Showing
11 changed files
with
125 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Schema } from '@angular-devkit/build-angular/src/builders/browser/schema'; | ||
|
||
export type BrowserBuilderSchema = Schema & { | ||
customWebpackConfig?: { | ||
path: string; | ||
}; | ||
indexFileTransformer?: string; | ||
buildLibsFromSource?: boolean; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
packages/angular/src/builders/webpack-browser/validate-options.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { stripIndents } from '@nrwl/devkit'; | ||
import { extname } from 'path'; | ||
import type { VersionInfo } from '../../executors/utilities/angular-version-utils'; | ||
import { getInstalledAngularVersionInfo } from '../../executors/utilities/angular-version-utils'; | ||
import type { BrowserBuilderSchema } from './schema'; | ||
|
||
export function validateOptions(options: BrowserBuilderSchema): void { | ||
const angularVersionInfo = getInstalledAngularVersionInfo(); | ||
validatePolyfills(options, angularVersionInfo); | ||
validateStyles(options, angularVersionInfo); | ||
} | ||
|
||
function validatePolyfills( | ||
options: BrowserBuilderSchema, | ||
{ major, version }: VersionInfo | ||
): void { | ||
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.`); | ||
} | ||
} | ||
|
||
function validateStyles( | ||
options: BrowserBuilderSchema, | ||
{ major, version }: VersionInfo | ||
): void { | ||
if (!options.styles || !options.styles.length) { | ||
return; | ||
} | ||
|
||
if (major < 15) { | ||
return; | ||
} | ||
|
||
const stylusFiles = []; | ||
options.styles.forEach((style) => { | ||
const styleFile = typeof style === 'string' ? style : style.input; | ||
if (extname(styleFile) === '.styl') { | ||
stylusFiles.push(styleFile); | ||
} | ||
}); | ||
|
||
if (stylusFiles.length) { | ||
throw new Error(stripIndents`Stylus is not supported since Angular v15. You're currently using "${version}". | ||
You have the "styles" option with the following file(s) using the ".styl" extension: ${stylusFiles | ||
.map((x) => `"${x}"`) | ||
.join(', ')}. | ||
Make sure to convert them to a supported extension (".css", ".scss", ".sass", ".less").`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
packages/angular/src/builders/webpack-server/validate-options.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { stripIndents } from '@nrwl/devkit'; | ||
import { lt } from 'semver'; | ||
import type { VersionInfo } from '../../executors/utilities/angular-version-utils'; | ||
import { getInstalledAngularVersionInfo } from '../../executors/utilities/angular-version-utils'; | ||
import type { Schema } from './schema'; | ||
|
||
export function validateOptions(options: Schema): void { | ||
const angularVersionInfo = getInstalledAngularVersionInfo(); | ||
validateAssets(options, angularVersionInfo); | ||
validateBundleDependencies(options, angularVersionInfo); | ||
validateVendorChunk(options, angularVersionInfo); | ||
} | ||
|
||
function validateAssets(options: Schema, { version }: VersionInfo): void { | ||
if ( | ||
lt(version, '15.1.0') && | ||
Array.isArray(options.assets) && | ||
options.assets.length > 0 | ||
) { | ||
throw new Error(stripIndents`The "assets" option is supported from Angular >= 15.1.0. You are currently using "${version}". | ||
You can resolve this error by removing the "assets" option or by migrating to Angular 15.1.0.`); | ||
} | ||
} | ||
|
||
function validateBundleDependencies( | ||
options: Schema, | ||
{ major, version }: VersionInfo | ||
): void { | ||
if (major >= 15 && options.bundleDependencies) { | ||
throw new Error(stripIndents`The "bundleDependencies" option was removed in Angular version 15. You are currently using "${version}". | ||
You can resolve this error by removing the "bundleDependencies" option.`); | ||
} | ||
} | ||
|
||
function validateVendorChunk(options: Schema, { version }: VersionInfo): void { | ||
if (lt(version, '15.1.0') && options.vendorChunk) { | ||
throw new Error(stripIndents`The "vendorChunk" option is supported from Angular >= 15.1.0. You are currently using "${version}". | ||
You can resolve this error by removing the "vendorChunk" option or by migrating to Angular 15.1.0.`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/angular/src/executors/utilities/angular-version-utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6c9a0e3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nx-dev – ./
nx.dev
nx-five.vercel.app
nx-dev-nrwl.vercel.app
nx-dev-git-master-nrwl.vercel.app