Skip to content

Commit 656f8d7

Browse files
alan-agius4josephperrott
authored andcommitted
fix(@angular-devkit/build-angular): change several builder options defaults
BREAKING CHANGE: A number of browser and server builder options have had their default values changed. The aim of these changes is to reduce the configuration complexity and support the new "production builds by default" initiative. **Browser builder** | Option | Previous default value | New default value | |----------------------------------------|---------------------------|-------------------| | optimization | false | true | | aot | false | true | | buildOptimizer | false | true | | sourceMap | true | false | | extractLicenses | false | true | | namedChunks | true | false | | vendorChunk | true | false | **Server builder** | Option | Previous default value | New default value | |---------------|------------------------|-------------------| | optimization | false | true | | sourceMap | true | false | (cherry picked from commit 0a74d0d)
1 parent 5197f42 commit 656f8d7

File tree

18 files changed

+160
-56
lines changed

18 files changed

+160
-56
lines changed

packages/angular_devkit/build_angular/src/browser/schema.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"optimization": {
7070
"description": "Enables optimization of the build output. Including minification of scripts and styles, tree-shaking, dead-code elimination, inlining of critical CSS and fonts inlining. For more information, see https://angular.io/guide/workspace-config#optimization-configuration.",
7171
"x-user-analytics": 16,
72-
"default": false,
72+
"default": true,
7373
"oneOf": [
7474
{
7575
"type": "object",
@@ -153,11 +153,11 @@
153153
"type": "boolean",
154154
"description": "Build using Ahead of Time compilation.",
155155
"x-user-analytics": 13,
156-
"default": false
156+
"default": true
157157
},
158158
"sourceMap": {
159159
"description": "Output source maps for scripts and styles. For more information, see https://angular.io/guide/workspace-config#source-map-configuration.",
160-
"default": true,
160+
"default": false,
161161
"oneOf": [
162162
{
163163
"type": "object",
@@ -193,7 +193,7 @@
193193
"vendorChunk": {
194194
"type": "boolean",
195195
"description": "Generate a seperate bundle containing only vendor libraries. This option should only used for development.",
196-
"default": true
196+
"default": false
197197
},
198198
"commonChunk": {
199199
"type": "boolean",
@@ -280,7 +280,7 @@
280280
"extractLicenses": {
281281
"type": "boolean",
282282
"description": "Extract all licenses in a separate file.",
283-
"default": false
283+
"default": true
284284
},
285285
"showCircularDependencies": {
286286
"type": "boolean",
@@ -291,12 +291,12 @@
291291
"buildOptimizer": {
292292
"type": "boolean",
293293
"description": "Enables '@angular-devkit/build-optimizer' optimizations when using the 'aot' option.",
294-
"default": false
294+
"default": true
295295
},
296296
"namedChunks": {
297297
"type": "boolean",
298298
"description": "Use file name for lazy loaded chunks.",
299-
"default": true
299+
"default": false
300300
},
301301
"subresourceIntegrity": {
302302
"type": "boolean",

packages/angular_devkit/build_angular/src/browser/specs/works_spec.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
2424
polyfills: 'src/polyfills.ts',
2525
tsConfig: 'src/tsconfig.app.json',
2626
progress: false,
27+
vendorChunk: true,
2728
assets: ['src/favicon.ico', 'src/assets'],
2829
styles: ['src/styles.css'],
2930
scripts: [],
@@ -33,13 +34,13 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
3334
await harness.executeOnce();
3435

3536
// Default files should be in outputPath.
36-
expect(harness.hasFile('dist/runtime.js')).toBe(true);
37-
expect(harness.hasFile('dist/main.js')).toBe(true);
38-
expect(harness.hasFile('dist/polyfills.js')).toBe(true);
39-
expect(harness.hasFile('dist/vendor.js')).toBe(true);
40-
expect(harness.hasFile('dist/favicon.ico')).toBe(true);
41-
expect(harness.hasFile('dist/styles.css')).toBe(true);
42-
expect(harness.hasFile('dist/index.html')).toBe(true);
37+
expect(harness.hasFile('dist/runtime.js')).toBeTrue();
38+
expect(harness.hasFile('dist/main.js')).toBeTrue();
39+
expect(harness.hasFile('dist/polyfills.js')).toBeTrue();
40+
expect(harness.hasFile('dist/vendor.js')).toBeTrue();
41+
expect(harness.hasFile('dist/favicon.ico')).toBeTrue();
42+
expect(harness.hasFile('dist/styles.css')).toBeTrue();
43+
expect(harness.hasFile('dist/index.html')).toBeTrue();
4344
});
4445
});
4546
});

packages/angular_devkit/build_angular/src/browser/tests/behavior/rebuild-errors_spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
281281
harness.useTarget('build', {
282282
...BASE_OPTIONS,
283283
watch: true,
284+
aot: false,
284285
});
285286

286287
const buildCount = await harness

packages/angular_devkit/build_angular/src/browser/tests/behavior/typescript-target_spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
3939

4040
harness.useTarget('build', {
4141
...BASE_OPTIONS,
42+
vendorChunk: true,
4243
});
4344

4445
const { result, logs } = await harness.executeOnce();
@@ -87,6 +88,7 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
8788

8889
harness.useTarget('build', {
8990
...BASE_OPTIONS,
91+
vendorChunk: true,
9092
sourceMap: {
9193
scripts: true,
9294
},
@@ -119,6 +121,7 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
119121

120122
harness.useTarget('build', {
121123
...BASE_OPTIONS,
124+
vendorChunk: true,
122125
});
123126

124127
const { result, logs } = await harness.executeOnce();

packages/angular_devkit/build_angular/src/browser/tests/options/extract-licenses_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
3232
harness.expectFile('dist/3rdpartylicenses.txt').toNotExist();
3333
});
3434

35-
it(`should not generate '3rdpartylicenses.txt' when 'extractLicenses' is not set`, async () => {
35+
it(`should generate '3rdpartylicenses.txt' when 'extractLicenses' is not set`, async () => {
3636
harness.useTarget('build', {
3737
...BASE_OPTIONS,
3838
});
3939

4040
const { result } = await harness.executeOnce();
4141
expect(result?.success).toBe(true);
42-
harness.expectFile('dist/3rdpartylicenses.txt').toNotExist();
42+
harness.expectFile('dist/3rdpartylicenses.txt').content.toContain('MIT');
4343
});
4444
});
4545
});

packages/angular_devkit/build_angular/src/browser/tests/options/main_spec.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
2222

2323
harness.expectFile('dist/runtime.js').toExist();
2424
harness.expectFile('dist/main.js').toExist();
25-
harness.expectFile('dist/vendor.js').toExist();
2625
harness.expectFile('dist/index.html').toExist();
2726
});
2827

@@ -40,7 +39,6 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
4039

4140
harness.expectFile('dist/runtime.js').toExist();
4241
harness.expectFile('dist/main.js').toExist();
43-
harness.expectFile('dist/vendor.js').toNotExist();
4442
harness.expectFile('dist/index.html').toExist();
4543

4644
harness.expectFile('dist/main.js').content.toContain(`console.log('main')`);
@@ -61,7 +59,6 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
6159

6260
harness.expectFile('dist/runtime.js').toNotExist();
6361
harness.expectFile('dist/main.js').toNotExist();
64-
harness.expectFile('dist/vendor.js').toNotExist();
6562
harness.expectFile('dist/index.html').toNotExist();
6663
});
6764
});

packages/angular_devkit/build_angular/src/browser/tests/options/named-chunks_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
6262
expect(result?.success).toBe(true);
6363

6464
harness.expectFile(MAIN_OUTPUT).toExist();
65-
harness.expectFile(NAMED_LAZY_OUTPUT).toExist();
66-
harness.expectFile(UNNAMED_LAZY_OUTPUT).toNotExist();
65+
harness.expectFile(NAMED_LAZY_OUTPUT).toNotExist();
66+
harness.expectFile(UNNAMED_LAZY_OUTPUT).toExist();
6767
});
6868
});
6969
});

packages/angular_devkit/build_angular/src/browser/tests/options/output-hashing_spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
1616
beforeEach(async () => {
1717
// Application code is not needed for asset tests
1818
await harness.writeFile('src/main.ts', '');
19+
await harness.writeFile('src/polyfills.ts', '');
1920
});
2021

2122
it('hashes all filenames when set to "all"', async () => {
@@ -27,6 +28,7 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
2728
harness.useTarget('build', {
2829
...BASE_OPTIONS,
2930
styles: ['src/styles.css'],
31+
polyfills: 'src/polyfills.ts',
3032
outputHashing: OutputHashing.All,
3133
});
3234

@@ -48,6 +50,7 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
4850

4951
harness.useTarget('build', {
5052
...BASE_OPTIONS,
53+
polyfills: 'src/polyfills.ts',
5154
styles: ['src/styles.css'],
5255
});
5356

@@ -70,6 +73,7 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
7073
harness.useTarget('build', {
7174
...BASE_OPTIONS,
7275
styles: ['src/styles.css'],
76+
polyfills: 'src/polyfills.ts',
7377
outputHashing: OutputHashing.None,
7478
});
7579

@@ -92,6 +96,7 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
9296
harness.useTarget('build', {
9397
...BASE_OPTIONS,
9498
styles: ['src/styles.css'],
99+
polyfills: 'src/polyfills.ts',
95100
outputHashing: OutputHashing.Media,
96101
});
97102

@@ -114,6 +119,7 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
114119
harness.useTarget('build', {
115120
...BASE_OPTIONS,
116121
styles: ['src/styles.css'],
122+
polyfills: 'src/polyfills.ts',
117123
outputHashing: OutputHashing.Bundles,
118124
});
119125

@@ -131,6 +137,7 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
131137
harness.useTarget('build', {
132138
...BASE_OPTIONS,
133139
outputHashing: OutputHashing.All,
140+
sourceMap: true,
134141
styles: [{
135142
input: 'src/styles.css',
136143
inject: false,

packages/angular_devkit/build_angular/src/browser/tests/setup.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,8 @@ export const BASE_OPTIONS = Object.freeze<Schema>({
2424
outputPath: 'dist',
2525
tsConfig: 'src/tsconfig.app.json',
2626
progress: false,
27+
28+
// Disable optimizations
29+
optimization: false,
30+
buildOptimizer: false,
2731
});

packages/angular_devkit/build_angular/src/dev-server/tests/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const DEV_SERVER_BUILDER_INFO = Object.freeze({
2424
});
2525

2626
/**
27-
* Contains all required extract-i18n builder fields.
27+
* Contains all required dev-server builder fields.
2828
* The port is also set to zero to ensure a free port is used for each test which
2929
* supports parallel test execution.
3030
*/

0 commit comments

Comments
 (0)