Skip to content

Commit 7e726eb

Browse files
committedSep 6, 2023
refactor(@angular-devkit/build-angular): update polyfills option in application and jest builder to be only an array.
This commit updates the polyfills options in application and jest builder to support only an array of string as value.
1 parent d44527b commit 7e726eb

File tree

5 files changed

+24
-41
lines changed

5 files changed

+24
-41
lines changed
 

‎packages/angular_devkit/build_angular/src/builders/application/schema.json

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,13 @@
2121
"description": "The full path for the server entry point to the application, relative to the current workspace."
2222
},
2323
"polyfills": {
24-
"description": "Polyfills to be included in the build.",
25-
"oneOf": [
26-
{
27-
"type": "array",
28-
"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'.",
29-
"items": {
30-
"type": "string",
31-
"uniqueItems": true
32-
},
33-
"default": []
34-
},
35-
{
36-
"type": "string",
37-
"description": "The full path for the polyfills file, relative to the current workspace or a module specifier. Example: 'zone.js'."
38-
}
39-
]
24+
"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'.",
25+
"type": "array",
26+
"items": {
27+
"type": "string",
28+
"uniqueItems": true
29+
},
30+
"default": []
4031
},
4132
"tsConfig": {
4233
"type": "string",

‎packages/angular_devkit/build_angular/src/builders/application/tests/options/output-hashing_spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
2424
harness.useTarget('build', {
2525
...BASE_OPTIONS,
2626
styles: ['src/styles.css'],
27-
polyfills: 'src/polyfills.ts',
27+
polyfills: ['src/polyfills.ts'],
2828
outputHashing: OutputHashing.All,
2929
});
3030

@@ -42,7 +42,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
4242

4343
harness.useTarget('build', {
4444
...BASE_OPTIONS,
45-
polyfills: 'src/polyfills.ts',
45+
polyfills: ['src/polyfills.ts'],
4646
styles: ['src/styles.css'],
4747
});
4848

@@ -61,7 +61,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
6161
harness.useTarget('build', {
6262
...BASE_OPTIONS,
6363
styles: ['src/styles.css'],
64-
polyfills: 'src/polyfills.ts',
64+
polyfills: ['src/polyfills.ts'],
6565
outputHashing: OutputHashing.None,
6666
});
6767

@@ -80,7 +80,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
8080
harness.useTarget('build', {
8181
...BASE_OPTIONS,
8282
styles: ['src/styles.css'],
83-
polyfills: 'src/polyfills.ts',
83+
polyfills: ['src/polyfills.ts'],
8484
outputHashing: OutputHashing.Media,
8585
});
8686

@@ -99,7 +99,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
9999
harness.useTarget('build', {
100100
...BASE_OPTIONS,
101101
styles: ['src/styles.css'],
102-
polyfills: 'src/polyfills.ts',
102+
polyfills: ['src/polyfills.ts'],
103103
outputHashing: OutputHashing.Bundles,
104104
});
105105

‎packages/angular_devkit/build_angular/src/builders/application/tests/options/polyfills_spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
1414
it('uses a provided TypeScript file', async () => {
1515
harness.useTarget('build', {
1616
...BASE_OPTIONS,
17-
polyfills: 'src/polyfills.ts',
17+
polyfills: ['src/polyfills.ts'],
1818
});
1919

2020
const { result } = await harness.executeOnce();
@@ -29,7 +29,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
2929

3030
harness.useTarget('build', {
3131
...BASE_OPTIONS,
32-
polyfills: 'src/polyfills.js',
32+
polyfills: ['src/polyfills.js'],
3333
});
3434

3535
const { result } = await harness.executeOnce();
@@ -42,7 +42,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
4242
it('fails and shows an error when file does not exist', async () => {
4343
harness.useTarget('build', {
4444
...BASE_OPTIONS,
45-
polyfills: 'src/missing.ts',
45+
polyfills: ['src/missing.ts'],
4646
});
4747

4848
const { result, logs } = await harness.executeOnce({ outputLogsOnFailure: false });

‎packages/angular_devkit/build_angular/src/builders/browser-esbuild/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ export function buildEsbuildBrowser(
4141
}
4242

4343
function normalizeOptions(options: BrowserBuilderOptions): ApplicationBuilderOptions {
44-
const { main: browser, ngswConfigPath, serviceWorker, ...otherOptions } = options;
44+
const { main: browser, ngswConfigPath, serviceWorker, polyfills, ...otherOptions } = options;
4545

4646
return {
4747
browser,
4848
serviceWorker: serviceWorker ? ngswConfigPath : false,
49+
polyfills: typeof polyfills === 'string' ? [polyfills] : polyfills,
4950
...otherOptions,
5051
};
5152
}

‎packages/angular_devkit/build_angular/src/builders/jest/schema.json

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,13 @@
2525
"description": "The name of the TypeScript configuration file."
2626
},
2727
"polyfills": {
28-
"description": "Polyfills to be included in the build.",
29-
"oneOf": [
30-
{
31-
"type": "array",
32-
"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'.",
33-
"items": {
34-
"type": "string",
35-
"uniqueItems": true
36-
},
37-
"default": []
38-
},
39-
{
40-
"type": "string",
41-
"description": "The full path for the polyfills file, relative to the current workspace or a module specifier. Example: 'zone.js'."
42-
}
43-
]
28+
"type": "array",
29+
"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'.",
30+
"items": {
31+
"type": "string",
32+
"uniqueItems": true
33+
},
34+
"default": []
4435
}
4536
},
4637
"additionalProperties": false,

0 commit comments

Comments
 (0)
Please sign in to comment.