|
7 | 7 | */
|
8 | 8 | import { BuilderContext, BuilderOutput, createBuilder } from '@angular-devkit/architect';
|
9 | 9 | import { runWebpack } from '@angular-devkit/build-webpack';
|
10 |
| -import { json } from '@angular-devkit/core'; |
| 10 | +import { json, tags } from '@angular-devkit/core'; |
11 | 11 | import * as path from 'path';
|
12 | 12 | import { Observable, from } from 'rxjs';
|
13 | 13 | import { concatMap, map } from 'rxjs/operators';
|
@@ -59,6 +59,27 @@ export function execute(
|
59 | 59 | const baseOutputPath = path.resolve(root, options.outputPath);
|
60 | 60 | let outputPaths: undefined | Map<string, string>;
|
61 | 61 |
|
| 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 | + |
62 | 83 | return from(initialize(options, context, transforms.webpackConfiguration)).pipe(
|
63 | 84 | concatMap(({ config, i18n }) => {
|
64 | 85 | return runWebpack(config, context, {
|
@@ -120,19 +141,10 @@ async function initialize(
|
120 | 141 | config: webpack.Configuration;
|
121 | 142 | i18n: I18nOptions;
|
122 | 143 | }> {
|
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 |
| - |
131 | 144 | const originalOutputPath = options.outputPath;
|
132 | 145 | const { config, i18n } = await generateI18nBrowserWebpackConfigFromContext(
|
133 | 146 | {
|
134 | 147 | ...options,
|
135 |
| - bundleDependencies, |
136 | 148 | buildOptimizer: false,
|
137 | 149 | aot: true,
|
138 | 150 | platform: 'server',
|
|
0 commit comments