Skip to content

Commit 8d181b6

Browse files
alan-agius4Keen Yee Liau
authored and
Keen Yee Liau
committed
fix(@angular-devkit/build-angular): add notice when using bundleDependencies: none with Ivy
Related to: https://github.com/angular/universal/issues/1354
1 parent 770de94 commit 8d181b6

File tree

1 file changed

+22
-10
lines changed
  • packages/angular_devkit/build_angular/src/server

1 file changed

+22
-10
lines changed

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

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
import { BuilderContext, BuilderOutput, createBuilder } from '@angular-devkit/architect';
99
import { runWebpack } from '@angular-devkit/build-webpack';
10-
import { json } from '@angular-devkit/core';
10+
import { json, tags } from '@angular-devkit/core';
1111
import * as path from 'path';
1212
import { Observable, from } from 'rxjs';
1313
import { concatMap, map } from 'rxjs/operators';
@@ -59,6 +59,27 @@ export function execute(
5959
const baseOutputPath = path.resolve(root, options.outputPath);
6060
let outputPaths: undefined | Map<string, string>;
6161

62+
if (typeof options.bundleDependencies === 'string') {
63+
options.bundleDependencies = options.bundleDependencies === 'all';
64+
context.logger.warn(`Option 'bundleDependencies' string value is deprecated since version 9. Use a boolean value instead.`);
65+
}
66+
67+
if (!options.bundleDependencies && tsConfig.options.enableIvy) {
68+
// tslint:disable-next-line: no-implicit-dependencies
69+
const { __processed_by_ivy_ngcc__, main = '' } = require('@angular/core/package.json');
70+
if (
71+
!__processed_by_ivy_ngcc__ ||
72+
!__processed_by_ivy_ngcc__.main ||
73+
(main as string).includes('__ivy_ngcc__')
74+
) {
75+
context.logger.warn(tags.stripIndent`
76+
WARNING: Turning off 'bundleDependencies' with Ivy may result in undefined behaviour
77+
unless 'node_modules' are transformed using the standalone Angular compatibility compiler (NGCC).
78+
See: http://v9.angular.io/guide/ivy#ivy-and-universal-app-shell
79+
`);
80+
}
81+
}
82+
6283
return from(initialize(options, context, transforms.webpackConfiguration)).pipe(
6384
concatMap(({ config, i18n }) => {
6485
return runWebpack(config, context, {
@@ -120,19 +141,10 @@ async function initialize(
120141
config: webpack.Configuration;
121142
i18n: I18nOptions;
122143
}> {
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-
131144
const originalOutputPath = options.outputPath;
132145
const { config, i18n } = await generateI18nBrowserWebpackConfigFromContext(
133146
{
134147
...options,
135-
bundleDependencies,
136148
buildOptimizer: false,
137149
aot: true,
138150
platform: 'server',

0 commit comments

Comments
 (0)