Skip to content

Commit 009b783

Browse files
alan-agius4Keen Yee Liau
authored and
Keen Yee Liau
committed
fix(@angular-devkit/build-angular): allow bundleDependencies to be a boolean
1 parent 03e5153 commit 009b783

File tree

8 files changed

+40
-18
lines changed

8 files changed

+40
-18
lines changed

packages/angular/cli/lib/config/schema.json

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,12 +1874,19 @@
18741874
"default": true
18751875
},
18761876
"bundleDependencies": {
1877-
"type": "string",
1878-
"description": "Available on server platform only. Which external dependencies to bundle into the module. By default, all of node_modules will be kept as requires.",
1879-
"default": "none",
1880-
"enum": [
1881-
"none",
1882-
"all"
1877+
"description": "Available on server platform only. Which external dependencies to bundle into the module. By default, all of node_modules will be bundled.",
1878+
"default": true,
1879+
"oneOf": [
1880+
{
1881+
"type": "boolean"
1882+
},
1883+
{
1884+
"type": "string",
1885+
"enum": [
1886+
"none",
1887+
"all"
1888+
]
1889+
}
18831890
]
18841891
},
18851892
"statsJson": {

packages/angular_devkit/build_angular/src/angular-cli-files/models/build-options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export interface BuildOptions {
4848
localize?: Localize;
4949
i18nMissingTranslation?: I18NMissingTranslation;
5050
extractCss?: boolean;
51-
bundleDependencies?: 'none' | 'all';
51+
bundleDependencies?: boolean;
5252
watch?: boolean;
5353
outputHashing?: string;
5454
poll?: number;

packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function getServerConfig(wco: WebpackConfigOptions): Configuration {
3939
node: false,
4040
};
4141

42-
if (wco.buildOptions.bundleDependencies == 'none') {
42+
if (!wco.buildOptions.bundleDependencies) {
4343
config.externals = [
4444
/^@angular/,
4545
(context: string, request: string, callback: (error?: null, result?: string) => void) => {

packages/angular_devkit/build_angular/src/server/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,19 @@ async function initialize(
120120
config: webpack.Configuration;
121121
i18n: I18nOptions;
122122
}> {
123+
let bundleDependencies: boolean | undefined;
124+
if (typeof options.bundleDependencies === 'string') {
125+
bundleDependencies = options.bundleDependencies === 'all';
126+
context.logger.warn(`Option 'bundleDependencies' string value is deprecated since version 9. Use a boolean value instead.`);
127+
} else {
128+
bundleDependencies = options.bundleDependencies;
129+
}
130+
123131
const originalOutputPath = options.outputPath;
124132
const { config, i18n } = await generateI18nBrowserWebpackConfigFromContext(
125133
{
126134
...options,
135+
bundleDependencies,
127136
buildOptimizer: false,
128137
aot: true,
129138
platform: 'server',

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,19 @@
218218
"x-deprecated": "Since version 9. This option has no effect on server platform."
219219
},
220220
"bundleDependencies": {
221-
"type": "string",
222221
"description": "Available on server platform only. Which external dependencies to bundle into the module. By default, all of node_modules will be bundled.",
223-
"default": "all",
224-
"enum": [
225-
"none",
226-
"all"
222+
"default": true,
223+
"oneOf": [
224+
{
225+
"type": "boolean"
226+
},
227+
{
228+
"type": "string",
229+
"enum": [
230+
"none",
231+
"all"
232+
]
233+
}
227234
]
228235
},
229236
"statsJson": {

packages/angular_devkit/build_angular/test/server/base_spec_large.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { Architect } from '@angular-devkit/architect';
1010
import { getSystemPath, join, normalize, virtualFs } from '@angular-devkit/core';
1111
import { take, tap } from 'rxjs/operators';
1212
import { ServerBuilderOutput } from '../../src';
13-
import { BundleDependencies } from '../../src/server/schema';
1413
import { createArchitect, host, veEnabled } from '../utils';
1514

1615

@@ -86,7 +85,7 @@ describe('Server Builder', () => {
8685
});
8786

8887
const run = await architect.scheduleTarget(target, {
89-
bundleDependencies: BundleDependencies.None,
88+
bundleDependencies: false,
9089
sourceMap: {
9190
styles: false,
9291
scripts: true,
@@ -108,7 +107,7 @@ describe('Server Builder', () => {
108107

109108
it('supports component styles sourcemaps', async () => {
110109
const overrides = {
111-
bundleDependencies: BundleDependencies.None,
110+
bundleDependencies: false,
112111
sourceMap: {
113112
styles: true,
114113
scripts: true,

tests/legacy-cli/e2e/tests/build/platform-server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export default async function () {
7070
);
7171

7272
// works with optimization and bundleDependencies enabled
73-
await ng('run', 'test-project:server:production', '--optimization', '--bundleDependencies', 'all');
73+
await ng('run', 'test-project:server:production', '--optimization', '--bundleDependencies');
7474
await exec(normalize('node'), 'dist/test-project/server/main.js');
7575
await expectFileToMatch(
7676
'dist/test-project/server/index.html',

tests/legacy-cli/e2e/tests/misc/universal-bundle-dependencies.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default async function() {
1515
appArchitect['server'] = {
1616
builder: '@angular-devkit/build-angular:server',
1717
options: {
18-
bundleDependencies: 'none',
18+
bundleDependencies: false,
1919
outputPath: 'dist/test-project-server',
2020
main: 'src/main.server.ts',
2121
tsConfig: 'tsconfig.server.json',

0 commit comments

Comments
 (0)