@angular-devkit/build-angular 0.800.3 → 0.800.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -6
- package/src/angular-cli-files/models/build-options.d.ts +3 -2
- package/src/angular-cli-files/plugins/karma.js +3 -3
- package/src/angular-cli-files/utilities/index-file/write-index-html.js +1 -1
- package/src/angular-cli-files/utilities/read-tsconfig.d.ts +9 -2
- package/src/angular-cli-files/utilities/read-tsconfig.js +25 -8
- package/src/angular-cli-files/utilities/service-worker/index.js +1 -1
- package/src/browser/index.js +12 -4
- package/src/extract-i18n/index.js +8 -0
- package/src/karma/index.js +1 -1
- package/src/utils/webpack-browser-config.js +11 -3
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "0.800.
|
|
3
|
+
"version": "0.800.4",
|
|
4
4
|
"description": "Angular Webpack Build Facade",
|
|
5
5
|
"experimental": true,
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"typings": "src/index.d.ts",
|
|
8
8
|
"builders": "builders.json",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@angular-devkit/architect": "0.800.
|
|
11
|
-
"@angular-devkit/build-optimizer": "0.800.
|
|
12
|
-
"@angular-devkit/build-webpack": "0.800.
|
|
13
|
-
"@angular-devkit/core": "8.0.
|
|
14
|
-
"@ngtools/webpack": "8.0.
|
|
10
|
+
"@angular-devkit/architect": "0.800.4",
|
|
11
|
+
"@angular-devkit/build-optimizer": "0.800.4",
|
|
12
|
+
"@angular-devkit/build-webpack": "0.800.4",
|
|
13
|
+
"@angular-devkit/core": "8.0.4",
|
|
14
|
+
"@ngtools/webpack": "8.0.4",
|
|
15
15
|
"ajv": "6.10.0",
|
|
16
16
|
"autoprefixer": "9.5.1",
|
|
17
17
|
"browserslist": "4.5.5",
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"worker-plugin": "3.1.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
+
"@angular/compiler-cli": ">=8.0.0-beta.0 < 9.0.0",
|
|
61
62
|
"typescript": ">=3.1 < 3.5"
|
|
62
63
|
},
|
|
63
64
|
"keywords": [
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import { logging } from '@angular-devkit/core';
|
|
9
|
-
import {
|
|
9
|
+
import { ParsedConfiguration } from '@angular/compiler-cli';
|
|
10
|
+
import { ScriptTarget } from 'typescript';
|
|
10
11
|
import { AssetPatternClass, Budget, ExtraEntryPoint, OptimizationClass, SourceMapClass } from '../../browser/schema';
|
|
11
12
|
import { NormalizedFileReplacement } from '../../utils/normalize-file-replacements';
|
|
12
13
|
export interface BuildOptions {
|
|
@@ -78,7 +79,7 @@ export interface WebpackConfigOptions<T = BuildOptions> {
|
|
|
78
79
|
projectRoot: string;
|
|
79
80
|
sourceRoot?: string;
|
|
80
81
|
buildOptions: T;
|
|
81
|
-
tsConfig:
|
|
82
|
+
tsConfig: ParsedConfiguration;
|
|
82
83
|
tsConfigPath: string;
|
|
83
84
|
supportES2015: boolean;
|
|
84
85
|
}
|
|
@@ -60,15 +60,14 @@ const init = (config, emitter, customFileHandlers) => {
|
|
|
60
60
|
const logger = config.buildWebpack.logger || node_1.createConsoleLogger();
|
|
61
61
|
successCb = config.buildWebpack.successCb;
|
|
62
62
|
failureCb = config.buildWebpack.failureCb;
|
|
63
|
-
config.reporters.unshift('@angular-devkit/build-angular--event-reporter');
|
|
64
63
|
// When using code-coverage, auto-add coverage-istanbul.
|
|
65
64
|
config.reporters = config.reporters || [];
|
|
66
65
|
if (options.codeCoverage && config.reporters.indexOf('coverage-istanbul') === -1) {
|
|
67
|
-
config.reporters.
|
|
66
|
+
config.reporters.push('coverage-istanbul');
|
|
68
67
|
}
|
|
69
68
|
// Add a reporter that fixes sourcemap urls.
|
|
70
69
|
if (index_1.normalizeSourceMaps(options.sourceMap).scripts) {
|
|
71
|
-
config.reporters.
|
|
70
|
+
config.reporters.push('@angular-devkit/build-angular--sourcemap-reporter');
|
|
72
71
|
// Code taken from https://github.com/tschaub/karma-source-map-support.
|
|
73
72
|
// We can't use it directly because we need to add it conditionally in this file, and karma
|
|
74
73
|
// frameworks cannot be added dynamically.
|
|
@@ -79,6 +78,7 @@ const init = (config, emitter, customFileHandlers) => {
|
|
|
79
78
|
{ pattern: path.join(ksmsPath, 'client.js'), watched: false }
|
|
80
79
|
], true);
|
|
81
80
|
}
|
|
81
|
+
config.reporters.push('@angular-devkit/build-angular--event-reporter');
|
|
82
82
|
// Add webpack config.
|
|
83
83
|
const webpackConfig = config.buildWebpack.webpackConfig;
|
|
84
84
|
const webpackMiddlewareConfig = {
|
|
@@ -21,7 +21,7 @@ function writeIndexHtml({ host, outputPath, indexPath, ES5BuildFiles, ES2015Buil
|
|
|
21
21
|
deployUrl,
|
|
22
22
|
sri,
|
|
23
23
|
entrypoints: package_chunk_sort_1.generateEntryPoints({ scripts, styles }),
|
|
24
|
-
files: filterAndMapBuildFiles(
|
|
24
|
+
files: filterAndMapBuildFiles(ES2015BuildFiles, '.css'),
|
|
25
25
|
noModuleFiles: filterAndMapBuildFiles(ES5BuildFiles, '.js'),
|
|
26
26
|
moduleFiles: filterAndMapBuildFiles(ES2015BuildFiles, '.js'),
|
|
27
27
|
loadOutputFile: async (filePath) => {
|
|
@@ -5,5 +5,12 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
9
|
-
|
|
8
|
+
import { ParsedConfiguration } from '@angular/compiler-cli';
|
|
9
|
+
/**
|
|
10
|
+
* Reads and parses a given TsConfig file.
|
|
11
|
+
*
|
|
12
|
+
* @param tsconfigPath - An absolute or relative path from 'workspaceRoot' of the tsconfig file.
|
|
13
|
+
* @param workspaceRoot - workspaceRoot root location when provided
|
|
14
|
+
* it will resolve 'tsconfigPath' from this path.
|
|
15
|
+
*/
|
|
16
|
+
export declare function readTsconfig(tsconfigPath: string, workspaceRoot?: string): ParsedConfiguration;
|
|
@@ -1,14 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google Inc. All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
const path = require("path");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Reads and parses a given TsConfig file.
|
|
13
|
+
*
|
|
14
|
+
* @param tsconfigPath - An absolute or relative path from 'workspaceRoot' of the tsconfig file.
|
|
15
|
+
* @param workspaceRoot - workspaceRoot root location when provided
|
|
16
|
+
* it will resolve 'tsconfigPath' from this path.
|
|
17
|
+
*/
|
|
18
|
+
function readTsconfig(tsconfigPath, workspaceRoot) {
|
|
19
|
+
const tsConfigFullPath = workspaceRoot
|
|
20
|
+
? path.resolve(workspaceRoot, tsconfigPath)
|
|
21
|
+
: tsconfigPath;
|
|
22
|
+
// We use 'ng' instead of 'ts' here because 'ts' is not aware of 'angularCompilerOptions'
|
|
23
|
+
// and will not merged them if they are at un upper level tsconfig file when using `extends`.
|
|
24
|
+
const ng = require('@angular/compiler-cli');
|
|
25
|
+
const configResult = ng.readConfiguration(tsConfigFullPath);
|
|
26
|
+
if (configResult.errors && configResult.errors.length) {
|
|
27
|
+
throw new Error(ng.formatDiagnostics(configResult.errors));
|
|
11
28
|
}
|
|
12
|
-
return
|
|
29
|
+
return configResult;
|
|
13
30
|
}
|
|
14
31
|
exports.readTsconfig = readTsconfig;
|
|
@@ -68,7 +68,7 @@ async function augmentAppWithServiceWorker(host, projectRoot, appRoot, outputPat
|
|
|
68
68
|
if (!configExists) {
|
|
69
69
|
throw new Error(core_1.tags.oneLine `
|
|
70
70
|
Error: Expected to find an ngsw-config.json configuration
|
|
71
|
-
file in the ${appRoot} folder. Either provide one or disable Service Worker
|
|
71
|
+
file in the ${core_1.getSystemPath(appRoot)} folder. Either provide one or disable Service Worker
|
|
72
72
|
in your angular.json configuration file.
|
|
73
73
|
`);
|
|
74
74
|
}
|
package/src/browser/index.js
CHANGED
|
@@ -106,8 +106,7 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
106
106
|
throw new Error('Must either have a target from the context or a default project.');
|
|
107
107
|
}
|
|
108
108
|
const projectRoot = core_1.resolve(workspace.root, core_1.normalize(workspace.getProject(projectName).root));
|
|
109
|
-
const
|
|
110
|
-
const tsConfig = read_tsconfig_1.readTsconfig(tsConfigPath);
|
|
109
|
+
const tsConfig = read_tsconfig_1.readTsconfig(options.tsConfig, context.workspaceRoot);
|
|
111
110
|
const target = tsConfig.options.target || typescript_1.ScriptTarget.ES5;
|
|
112
111
|
const buildBrowserFeatures = new utils_1.BuildBrowserFeatures(core_1.getSystemPath(projectRoot), target);
|
|
113
112
|
if (target > typescript_1.ScriptTarget.ES2015 && buildBrowserFeatures.isDifferentialLoadingNeeded()) {
|
|
@@ -145,14 +144,14 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
145
144
|
scripts: options.scripts,
|
|
146
145
|
styles: options.styles,
|
|
147
146
|
})
|
|
148
|
-
.pipe(operators_1.map(() => ({ success: true })), operators_1.catchError(
|
|
147
|
+
.pipe(operators_1.map(() => ({ success: true })), operators_1.catchError(error => rxjs_1.of({ success: false, error: mapErrorToMessage(error) })));
|
|
149
148
|
}
|
|
150
149
|
else {
|
|
151
150
|
return rxjs_1.of({ success });
|
|
152
151
|
}
|
|
153
152
|
}), operators_1.concatMap(buildEvent => {
|
|
154
153
|
if (buildEvent.success && !options.watch && options.serviceWorker) {
|
|
155
|
-
return rxjs_1.from(service_worker_1.augmentAppWithServiceWorker(host, root, projectRoot, core_1.resolve(root, core_1.normalize(options.outputPath)), options.baseHref || '/', options.ngswConfigPath).then(() => ({ success: true }),
|
|
154
|
+
return rxjs_1.from(service_worker_1.augmentAppWithServiceWorker(host, root, projectRoot, core_1.resolve(root, core_1.normalize(options.outputPath)), options.baseHref || '/', options.ngswConfigPath).then(() => ({ success: true }), error => ({ success: false, error: mapErrorToMessage(error) })));
|
|
156
155
|
}
|
|
157
156
|
else {
|
|
158
157
|
return rxjs_1.of(buildEvent);
|
|
@@ -165,4 +164,13 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
165
164
|
}));
|
|
166
165
|
}
|
|
167
166
|
exports.buildWebpackBrowser = buildWebpackBrowser;
|
|
167
|
+
function mapErrorToMessage(error) {
|
|
168
|
+
if (error instanceof Error) {
|
|
169
|
+
return error.message;
|
|
170
|
+
}
|
|
171
|
+
if (typeof error === 'string') {
|
|
172
|
+
return error;
|
|
173
|
+
}
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
168
176
|
exports.default = architect_1.createBuilder(buildWebpackBrowser);
|
|
@@ -12,6 +12,7 @@ const build_webpack_1 = require("@angular-devkit/build-webpack");
|
|
|
12
12
|
const path = require("path");
|
|
13
13
|
const webpack = require("webpack");
|
|
14
14
|
const webpack_configs_1 = require("../angular-cli-files/models/webpack-configs");
|
|
15
|
+
const read_tsconfig_1 = require("../angular-cli-files/utilities/read-tsconfig");
|
|
15
16
|
const stats_1 = require("../angular-cli-files/utilities/stats");
|
|
16
17
|
const version_1 = require("../utils/version");
|
|
17
18
|
const webpack_browser_config_1 = require("../utils/webpack-browser-config");
|
|
@@ -40,6 +41,13 @@ async function execute(options, context) {
|
|
|
40
41
|
version_1.Version.assertCompatibleAngularVersion(context.workspaceRoot);
|
|
41
42
|
const browserTarget = architect_1.targetFromTargetString(options.browserTarget);
|
|
42
43
|
const browserOptions = await context.validateOptions(await context.getTargetOptions(browserTarget), await context.getBuilderNameForTarget(browserTarget));
|
|
44
|
+
// FIXME: i18n is not yet implemented in Ivy
|
|
45
|
+
// We should display a warning and exit gracefully.
|
|
46
|
+
const { options: compilerOptions } = read_tsconfig_1.readTsconfig(browserOptions.tsConfig, context.workspaceRoot);
|
|
47
|
+
if (compilerOptions.enableIvy) {
|
|
48
|
+
context.logger.warn('We are sorry but i18n is not yet implemented in Ivy.');
|
|
49
|
+
return { success: true };
|
|
50
|
+
}
|
|
43
51
|
// We need to determine the outFile name so that AngularCompiler can retrieve it.
|
|
44
52
|
let outFile = options.outFile || getI18nOutfile(options.i18nFormat);
|
|
45
53
|
if (options.outputPath) {
|
package/src/karma/index.js
CHANGED
|
@@ -81,7 +81,7 @@ function execute(options, context, transforms = {}) {
|
|
|
81
81
|
return karmaStart.then(() => karmaServerWithStop.stop());
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
|
-
})));
|
|
84
|
+
})), operators_1.defaultIfEmpty({ success: false }));
|
|
85
85
|
}
|
|
86
86
|
exports.execute = execute;
|
|
87
87
|
exports.default = architect_1.createBuilder(execute);
|
|
@@ -32,18 +32,26 @@ async function generateWebpackConfig(context, workspaceRoot, projectRoot, source
|
|
|
32
32
|
// For differential loading, we can have several targets
|
|
33
33
|
return scriptTargets.map(scriptTarget => {
|
|
34
34
|
let buildOptions = { ...options };
|
|
35
|
+
const supportES2015 = scriptTarget !== ts.ScriptTarget.ES3 && scriptTarget !== ts.ScriptTarget.ES5;
|
|
35
36
|
if (differentialLoading) {
|
|
36
|
-
// For differential loading, the builder needs to created the index.html by itself
|
|
37
|
-
// without using a webpack plugin.
|
|
38
37
|
buildOptions = {
|
|
39
38
|
...options,
|
|
39
|
+
...(
|
|
40
|
+
// FIXME: we do create better webpack config composition to achieve the below
|
|
41
|
+
// When DL is enabled and supportES2015 is true it means that we are on the second build
|
|
42
|
+
// This also means that we don't need to include styles and assets multiple times
|
|
43
|
+
supportES2015
|
|
44
|
+
? {}
|
|
45
|
+
: {
|
|
46
|
+
styles: options.extractCss ? [] : options.styles,
|
|
47
|
+
assets: [],
|
|
48
|
+
}),
|
|
40
49
|
es5BrowserSupport: undefined,
|
|
41
50
|
index: '',
|
|
42
51
|
esVersionInFileName: true,
|
|
43
52
|
scriptTargetOverride: scriptTarget,
|
|
44
53
|
};
|
|
45
54
|
}
|
|
46
|
-
const supportES2015 = scriptTarget !== ts.ScriptTarget.ES3 && scriptTarget !== ts.ScriptTarget.ES5;
|
|
47
55
|
const wco = {
|
|
48
56
|
root: workspaceRoot,
|
|
49
57
|
logger: logger.createChild('webpackConfigOptions'),
|