@angular-devkit/build-angular 14.0.0-next.9 → 14.0.0-rc.2
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/builders.json +5 -0
- package/package.json +29 -29
- package/src/babel/presets/application.d.ts +3 -2
- package/src/babel/presets/application.js +2 -3
- package/src/babel/webpack-loader.d.ts +1 -0
- package/src/babel/webpack-loader.js +29 -15
- package/src/builders/app-shell/index.js +1 -1
- package/src/builders/browser/index.js +1 -1
- package/src/builders/browser-esbuild/compiler-plugin.d.ts +14 -0
- package/src/builders/browser-esbuild/compiler-plugin.js +338 -0
- package/src/builders/browser-esbuild/esbuild.d.ts +36 -0
- package/src/builders/browser-esbuild/esbuild.js +62 -0
- package/src/builders/browser-esbuild/experimental-warnings.d.ts +10 -0
- package/src/builders/browser-esbuild/experimental-warnings.js +65 -0
- package/src/builders/browser-esbuild/index.d.ts +19 -0
- package/src/builders/browser-esbuild/index.js +262 -0
- package/src/builders/browser-esbuild/options.d.ts +34 -0
- package/src/builders/browser-esbuild/options.js +87 -0
- package/src/builders/browser-esbuild/stylesheets.d.ts +52 -0
- package/src/builders/browser-esbuild/stylesheets.js +119 -0
- package/src/builders/protractor/index.js +50 -52
- package/src/utils/service-worker.d.ts +1 -1
- package/src/utils/service-worker.js +2 -2
- package/src/webpack/configs/common.js +1 -0
- package/src/webpack/configs/styles.d.ts +6 -0
- package/src/webpack/configs/styles.js +2 -1
- package/src/webpack/plugins/css-optimizer-plugin.js +7 -0
- package/src/webpack/plugins/javascript-optimizer-plugin.js +6 -0
- package/src/webpack/plugins/karma/karma.js +7 -27
- package/src/webpack/plugins/typescript.js +5 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC 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
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.bundleStylesheetText = exports.bundleStylesheetFile = void 0;
|
|
34
|
+
const path = __importStar(require("path"));
|
|
35
|
+
const esbuild_1 = require("./esbuild");
|
|
36
|
+
async function bundleStylesheet(entry, options) {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
// Execute esbuild
|
|
39
|
+
const result = await (0, esbuild_1.bundle)({
|
|
40
|
+
...entry,
|
|
41
|
+
absWorkingDir: options.workspaceRoot,
|
|
42
|
+
bundle: true,
|
|
43
|
+
entryNames: (_a = options.outputNames) === null || _a === void 0 ? void 0 : _a.bundles,
|
|
44
|
+
assetNames: (_b = options.outputNames) === null || _b === void 0 ? void 0 : _b.media,
|
|
45
|
+
logLevel: 'silent',
|
|
46
|
+
minify: options.optimization,
|
|
47
|
+
sourcemap: options.sourcemap,
|
|
48
|
+
outdir: esbuild_1.DEFAULT_OUTDIR,
|
|
49
|
+
write: false,
|
|
50
|
+
platform: 'browser',
|
|
51
|
+
preserveSymlinks: options.preserveSymlinks,
|
|
52
|
+
conditions: ['style'],
|
|
53
|
+
mainFields: ['style'],
|
|
54
|
+
plugins: [
|
|
55
|
+
// TODO: preprocessor plugins
|
|
56
|
+
],
|
|
57
|
+
});
|
|
58
|
+
// Extract the result of the bundling from the output files
|
|
59
|
+
let contents = '';
|
|
60
|
+
let map;
|
|
61
|
+
let outputPath;
|
|
62
|
+
const resourceFiles = [];
|
|
63
|
+
if (result.outputFiles) {
|
|
64
|
+
for (const outputFile of result.outputFiles) {
|
|
65
|
+
outputFile.path = path.relative(esbuild_1.DEFAULT_OUTDIR, outputFile.path);
|
|
66
|
+
const filename = path.basename(outputFile.path);
|
|
67
|
+
if (filename.endsWith('.css')) {
|
|
68
|
+
outputPath = outputFile.path;
|
|
69
|
+
contents = outputFile.text;
|
|
70
|
+
}
|
|
71
|
+
else if (filename.endsWith('.css.map')) {
|
|
72
|
+
map = outputFile.text;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
// The output files could also contain resources (images/fonts/etc.) that were referenced
|
|
76
|
+
resourceFiles.push(outputFile);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
errors: result.errors,
|
|
82
|
+
warnings: result.warnings,
|
|
83
|
+
contents,
|
|
84
|
+
map,
|
|
85
|
+
path: outputPath,
|
|
86
|
+
resourceFiles,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Bundle a stylesheet that exists as a file on the filesystem.
|
|
91
|
+
*
|
|
92
|
+
* @param filename The path to the file to bundle.
|
|
93
|
+
* @param options The stylesheet bundling options to use.
|
|
94
|
+
* @returns The bundle result object.
|
|
95
|
+
*/
|
|
96
|
+
async function bundleStylesheetFile(filename, options) {
|
|
97
|
+
return bundleStylesheet({ entryPoints: [filename] }, options);
|
|
98
|
+
}
|
|
99
|
+
exports.bundleStylesheetFile = bundleStylesheetFile;
|
|
100
|
+
/**
|
|
101
|
+
* Bundle stylesheet text data from a string.
|
|
102
|
+
*
|
|
103
|
+
* @param data The string content of a stylesheet to bundle.
|
|
104
|
+
* @param dataOptions The options to use to resolve references and name output of the stylesheet data.
|
|
105
|
+
* @param bundleOptions The stylesheet bundling options to use.
|
|
106
|
+
* @returns The bundle result object.
|
|
107
|
+
*/
|
|
108
|
+
async function bundleStylesheetText(data, dataOptions, bundleOptions) {
|
|
109
|
+
const result = bundleStylesheet({
|
|
110
|
+
stdin: {
|
|
111
|
+
contents: data,
|
|
112
|
+
sourcefile: dataOptions.virtualName,
|
|
113
|
+
resolveDir: dataOptions.resolvePath,
|
|
114
|
+
loader: 'css',
|
|
115
|
+
},
|
|
116
|
+
}, bundleOptions);
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
exports.bundleStylesheetText = bundleStylesheetText;
|
|
@@ -100,67 +100,65 @@ async function execute(options, context) {
|
|
|
100
100
|
}
|
|
101
101
|
let baseUrl = options.baseUrl;
|
|
102
102
|
let server;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
publicHost
|
|
103
|
+
try {
|
|
104
|
+
if (options.devServerTarget) {
|
|
105
|
+
const target = (0, architect_1.targetFromTargetString)(options.devServerTarget);
|
|
106
|
+
const serverOptions = await context.getTargetOptions(target);
|
|
107
|
+
const overrides = {
|
|
108
|
+
watch: false,
|
|
109
|
+
liveReload: false,
|
|
110
|
+
};
|
|
111
|
+
if (options.host !== undefined) {
|
|
112
|
+
overrides.host = options.host;
|
|
113
|
+
}
|
|
114
|
+
else if (typeof serverOptions.host === 'string') {
|
|
115
|
+
options.host = serverOptions.host;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
options.host = overrides.host = 'localhost';
|
|
119
|
+
}
|
|
120
|
+
if (options.port !== undefined) {
|
|
121
|
+
overrides.port = options.port;
|
|
122
|
+
}
|
|
123
|
+
else if (typeof serverOptions.port === 'number') {
|
|
124
|
+
options.port = serverOptions.port;
|
|
125
|
+
}
|
|
126
|
+
server = await context.scheduleTarget(target, overrides);
|
|
127
|
+
const result = await server.result;
|
|
128
|
+
if (!result.success) {
|
|
129
|
+
return { success: false };
|
|
130
|
+
}
|
|
131
|
+
if (typeof serverOptions.publicHost === 'string') {
|
|
132
|
+
let publicHost = serverOptions.publicHost;
|
|
133
|
+
if (!/^\w+:\/\//.test(publicHost)) {
|
|
134
|
+
publicHost = `${serverOptions.ssl ? 'https' : 'http'}://${publicHost}`;
|
|
135
|
+
}
|
|
136
|
+
const clientUrl = url.parse(publicHost);
|
|
137
|
+
baseUrl = url.format(clientUrl);
|
|
138
|
+
}
|
|
139
|
+
else if (typeof result.baseUrl === 'string') {
|
|
140
|
+
baseUrl = result.baseUrl;
|
|
141
|
+
}
|
|
142
|
+
else if (typeof result.port === 'number') {
|
|
143
|
+
baseUrl = url.format({
|
|
144
|
+
protocol: serverOptions.ssl ? 'https' : 'http',
|
|
145
|
+
hostname: options.host,
|
|
146
|
+
port: result.port.toString(),
|
|
147
|
+
});
|
|
134
148
|
}
|
|
135
|
-
const clientUrl = url.parse(publicHost);
|
|
136
|
-
baseUrl = url.format(clientUrl);
|
|
137
|
-
}
|
|
138
|
-
else if (typeof result.baseUrl === 'string') {
|
|
139
|
-
baseUrl = result.baseUrl;
|
|
140
149
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
port: result.port.toString(),
|
|
146
|
-
});
|
|
150
|
+
// Like the baseUrl in protractor config file when using the API we need to add
|
|
151
|
+
// a trailing slash when provide to the baseUrl.
|
|
152
|
+
if (baseUrl && !baseUrl.endsWith('/')) {
|
|
153
|
+
baseUrl += '/';
|
|
147
154
|
}
|
|
148
|
-
}
|
|
149
|
-
// Like the baseUrl in protractor config file when using the API we need to add
|
|
150
|
-
// a trailing slash when provide to the baseUrl.
|
|
151
|
-
if (baseUrl && !baseUrl.endsWith('/')) {
|
|
152
|
-
baseUrl += '/';
|
|
153
|
-
}
|
|
154
|
-
try {
|
|
155
155
|
return await runProtractor(context.workspaceRoot, { ...options, baseUrl });
|
|
156
156
|
}
|
|
157
157
|
catch {
|
|
158
158
|
return { success: false };
|
|
159
159
|
}
|
|
160
160
|
finally {
|
|
161
|
-
|
|
162
|
-
await server.stop();
|
|
163
|
-
}
|
|
161
|
+
await (server === null || server === void 0 ? void 0 : server.stop());
|
|
164
162
|
}
|
|
165
163
|
}
|
|
166
164
|
exports.execute = execute;
|
|
@@ -5,4 +5,4 @@
|
|
|
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
|
-
export declare function augmentAppWithServiceWorker(appRoot: string, outputPath: string, baseHref: string, ngswConfigPath?: string): Promise<void>;
|
|
8
|
+
export declare function augmentAppWithServiceWorker(appRoot: string, workspaceRoot: string, outputPath: string, baseHref: string, ngswConfigPath?: string): Promise<void>;
|
|
@@ -75,10 +75,10 @@ class CliFilesystem {
|
|
|
75
75
|
return items;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
async function augmentAppWithServiceWorker(appRoot, outputPath, baseHref, ngswConfigPath) {
|
|
78
|
+
async function augmentAppWithServiceWorker(appRoot, workspaceRoot, outputPath, baseHref, ngswConfigPath) {
|
|
79
79
|
// Determine the configuration file path
|
|
80
80
|
const configPath = ngswConfigPath
|
|
81
|
-
? path.
|
|
81
|
+
? path.join(workspaceRoot, ngswConfigPath)
|
|
82
82
|
: path.join(appRoot, 'ngsw-config.json');
|
|
83
83
|
// Read the configuration file
|
|
84
84
|
let config;
|
|
@@ -300,6 +300,7 @@ async function getCommonConfig(wco) {
|
|
|
300
300
|
scriptTarget,
|
|
301
301
|
aot: buildOptions.aot,
|
|
302
302
|
optimize: buildOptions.buildOptimizer,
|
|
303
|
+
supportedBrowsers: buildOptions.supportedBrowsers,
|
|
303
304
|
instrumentCode: codeCoverage
|
|
304
305
|
? {
|
|
305
306
|
includedBasePath: sourceRoot,
|
|
@@ -6,5 +6,11 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import { Configuration } from 'webpack';
|
|
9
|
+
import { StyleElement } from '../../builders/browser/schema';
|
|
9
10
|
import { WebpackConfigOptions } from '../../utils/build-options';
|
|
11
|
+
export declare function resolveGlobalStyles(styleEntrypoints: StyleElement[], root: string, preserveSymlinks: boolean): {
|
|
12
|
+
entryPoints: Record<string, string[]>;
|
|
13
|
+
noInjectNames: string[];
|
|
14
|
+
paths: string[];
|
|
15
|
+
};
|
|
10
16
|
export declare function getStylesConfig(wco: WebpackConfigOptions): Configuration;
|
|
@@ -33,7 +33,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
33
33
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
34
|
};
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.getStylesConfig = void 0;
|
|
36
|
+
exports.getStylesConfig = exports.resolveGlobalStyles = void 0;
|
|
37
37
|
const fs = __importStar(require("fs"));
|
|
38
38
|
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
39
39
|
const path = __importStar(require("path"));
|
|
@@ -75,6 +75,7 @@ function resolveGlobalStyles(styleEntrypoints, root, preserveSymlinks) {
|
|
|
75
75
|
}
|
|
76
76
|
return { entryPoints, noInjectNames, paths };
|
|
77
77
|
}
|
|
78
|
+
exports.resolveGlobalStyles = resolveGlobalStyles;
|
|
78
79
|
// eslint-disable-next-line max-lines-per-function
|
|
79
80
|
function getStylesConfig(wco) {
|
|
80
81
|
var _a, _b, _c;
|
|
@@ -30,11 +30,13 @@ class CssOptimizerPlugin {
|
|
|
30
30
|
apply(compiler) {
|
|
31
31
|
const { OriginalSource, SourceMapSource } = compiler.webpack.sources;
|
|
32
32
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
33
|
+
const logger = compilation.getLogger('build-angular.CssOptimizerPlugin');
|
|
33
34
|
compilation.hooks.processAssets.tapPromise({
|
|
34
35
|
name: PLUGIN_NAME,
|
|
35
36
|
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,
|
|
36
37
|
}, async (compilationAssets) => {
|
|
37
38
|
const cache = compilation.options.cache && compilation.getCache(PLUGIN_NAME);
|
|
39
|
+
logger.time('optimize css assets');
|
|
38
40
|
for (const assetName of Object.keys(compilationAssets)) {
|
|
39
41
|
if (!/\.(?:css|scss|sass|less|styl)$/.test(assetName)) {
|
|
40
42
|
continue;
|
|
@@ -51,6 +53,7 @@ class CssOptimizerPlugin {
|
|
|
51
53
|
cacheItem = cache.getItemCache(name, eTag);
|
|
52
54
|
const cachedOutput = await cacheItem.getPromise();
|
|
53
55
|
if (cachedOutput) {
|
|
56
|
+
logger.debug(`${name} restored from cache`);
|
|
54
57
|
await this.addWarnings(compilation, cachedOutput.warnings);
|
|
55
58
|
compilation.updateAsset(name, cachedOutput.source, (assetInfo) => ({
|
|
56
59
|
...assetInfo,
|
|
@@ -61,7 +64,10 @@ class CssOptimizerPlugin {
|
|
|
61
64
|
}
|
|
62
65
|
const { source, map: inputMap } = styleAssetSource.sourceAndMap();
|
|
63
66
|
const input = typeof source === 'string' ? source : source.toString();
|
|
67
|
+
const optimizeAssetLabel = `optimize asset: ${asset.name}`;
|
|
68
|
+
logger.time(optimizeAssetLabel);
|
|
64
69
|
const { code, warnings, map } = await this.optimize(input, asset.name, inputMap, this.targets);
|
|
70
|
+
logger.timeEnd(optimizeAssetLabel);
|
|
65
71
|
await this.addWarnings(compilation, warnings);
|
|
66
72
|
const optimizedAsset = map
|
|
67
73
|
? new SourceMapSource(code, name, map)
|
|
@@ -75,6 +81,7 @@ class CssOptimizerPlugin {
|
|
|
75
81
|
warnings,
|
|
76
82
|
}));
|
|
77
83
|
}
|
|
84
|
+
logger.timeEnd('optimize css assets');
|
|
78
85
|
});
|
|
79
86
|
});
|
|
80
87
|
}
|
|
@@ -38,10 +38,12 @@ class JavaScriptOptimizerPlugin {
|
|
|
38
38
|
apply(compiler) {
|
|
39
39
|
const { OriginalSource, SourceMapSource } = compiler.webpack.sources;
|
|
40
40
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
41
|
+
const logger = compilation.getLogger('build-angular.JavaScriptOptimizerPlugin');
|
|
41
42
|
compilation.hooks.processAssets.tapPromise({
|
|
42
43
|
name: PLUGIN_NAME,
|
|
43
44
|
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,
|
|
44
45
|
}, async (compilationAssets) => {
|
|
46
|
+
logger.time('optimize js assets');
|
|
45
47
|
const scriptsToOptimize = [];
|
|
46
48
|
const cache = compilation.options.cache && compilation.getCache('JavaScriptOptimizerPlugin');
|
|
47
49
|
// Analyze the compilation assets for scripts that require optimization
|
|
@@ -61,6 +63,7 @@ class JavaScriptOptimizerPlugin {
|
|
|
61
63
|
cacheItem = cache.getItemCache(name, eTag);
|
|
62
64
|
const cachedOutput = await cacheItem.getPromise();
|
|
63
65
|
if (cachedOutput) {
|
|
66
|
+
logger.debug(`${name} restored from cache`);
|
|
64
67
|
compilation.updateAsset(name, cachedOutput.source, (assetInfo) => ({
|
|
65
68
|
...assetInfo,
|
|
66
69
|
minimized: true,
|
|
@@ -125,6 +128,7 @@ class JavaScriptOptimizerPlugin {
|
|
|
125
128
|
try {
|
|
126
129
|
const tasks = [];
|
|
127
130
|
for (const { name, code, map, cacheItem } of scriptsToOptimize) {
|
|
131
|
+
logger.time(`optimize asset: ${name}`);
|
|
128
132
|
tasks.push(workerPool
|
|
129
133
|
.run({
|
|
130
134
|
asset: {
|
|
@@ -142,6 +146,7 @@ class JavaScriptOptimizerPlugin {
|
|
|
142
146
|
...assetInfo,
|
|
143
147
|
minimized: true,
|
|
144
148
|
}));
|
|
149
|
+
logger.timeEnd(`optimize asset: ${name}`);
|
|
145
150
|
return cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.storePromise({
|
|
146
151
|
source: optimizedAsset,
|
|
147
152
|
});
|
|
@@ -155,6 +160,7 @@ class JavaScriptOptimizerPlugin {
|
|
|
155
160
|
finally {
|
|
156
161
|
void workerPool.destroy();
|
|
157
162
|
}
|
|
163
|
+
logger.timeEnd('optimize js assets');
|
|
158
164
|
});
|
|
159
165
|
});
|
|
160
166
|
}
|
|
@@ -34,7 +34,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
34
34
|
};
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
const path = __importStar(require("path"));
|
|
37
|
-
const glob = __importStar(require("glob"));
|
|
38
37
|
const webpack_1 = __importDefault(require("webpack"));
|
|
39
38
|
const webpack_dev_middleware_1 = __importDefault(require("webpack-dev-middleware"));
|
|
40
39
|
const stats_1 = require("../../utils/stats");
|
|
@@ -46,27 +45,6 @@ let isBlocked = false;
|
|
|
46
45
|
let webpackMiddleware;
|
|
47
46
|
let successCb;
|
|
48
47
|
let failureCb;
|
|
49
|
-
// Add files to the Karma files array.
|
|
50
|
-
function addKarmaFiles(files, newFiles, prepend = false) {
|
|
51
|
-
const defaults = {
|
|
52
|
-
included: true,
|
|
53
|
-
served: true,
|
|
54
|
-
watched: true,
|
|
55
|
-
};
|
|
56
|
-
const processedFiles = newFiles
|
|
57
|
-
// Remove globs that do not match any files, otherwise Karma will show a warning for these.
|
|
58
|
-
.filter((file) => glob.sync(file.pattern, { nodir: true }).length != 0)
|
|
59
|
-
// Fill in pattern properties with defaults.
|
|
60
|
-
.map((file) => ({ ...defaults, ...file }));
|
|
61
|
-
// It's important to not replace the array, because
|
|
62
|
-
// karma already has a reference to the existing array.
|
|
63
|
-
if (prepend) {
|
|
64
|
-
files.unshift(...processedFiles);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
files.push(...processedFiles);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
48
|
const init = (config, emitter) => {
|
|
71
49
|
if (!config.buildWebpack) {
|
|
72
50
|
throw new Error(`The '@angular-devkit/build-angular/plugins/karma' karma plugin is meant to` +
|
|
@@ -84,10 +62,12 @@ const init = (config, emitter) => {
|
|
|
84
62
|
// frameworks cannot be added dynamically.
|
|
85
63
|
const smsPath = path.dirname(require.resolve('source-map-support'));
|
|
86
64
|
const ksmsPath = path.dirname(require.resolve('karma-source-map-support'));
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
65
|
+
config.files.unshift({
|
|
66
|
+
pattern: path.join(smsPath, 'browser-source-map-support.js'),
|
|
67
|
+
included: true,
|
|
68
|
+
served: true,
|
|
69
|
+
watched: false,
|
|
70
|
+
}, { pattern: path.join(ksmsPath, 'client.js'), included: true, served: true, watched: false });
|
|
91
71
|
}
|
|
92
72
|
config.reporters.unshift('@angular-devkit/build-angular--event-reporter');
|
|
93
73
|
// When using code-coverage, auto-add karma-coverage.
|
|
@@ -162,7 +142,7 @@ const init = (config, emitter) => {
|
|
|
162
142
|
webpackMiddleware = (0, webpack_dev_middleware_1.default)(compiler, webpackMiddlewareConfig);
|
|
163
143
|
emitter.on('exit', (done) => {
|
|
164
144
|
webpackMiddleware.close();
|
|
165
|
-
done();
|
|
145
|
+
compiler.close(() => done());
|
|
166
146
|
});
|
|
167
147
|
function unblock() {
|
|
168
148
|
isBlocked = false;
|
|
@@ -20,6 +20,7 @@ function ensureIvy(wco) {
|
|
|
20
20
|
'\nFor additional information or if the build fails, please see https://angular.io/guide/ivy');
|
|
21
21
|
wco.tsConfig.options.enableIvy = true;
|
|
22
22
|
}
|
|
23
|
+
let es5TargetWarningsShown = false;
|
|
23
24
|
function createIvyPlugin(wco, aot, tsconfig) {
|
|
24
25
|
if (aot) {
|
|
25
26
|
ensureIvy(wco);
|
|
@@ -39,6 +40,10 @@ function createIvyPlugin(wco, aot, tsconfig) {
|
|
|
39
40
|
// as for third-party libraries. This greatly reduces the complexity of static analysis.
|
|
40
41
|
if (wco.scriptTarget < typescript_1.ScriptTarget.ES2015) {
|
|
41
42
|
compilerOptions.target = typescript_1.ScriptTarget.ES2015;
|
|
43
|
+
if (!es5TargetWarningsShown) {
|
|
44
|
+
wco.logger.warn('DEPRECATED: ES5 output is deprecated. Please update TypeScript `target` compiler option to ES2015 or later.');
|
|
45
|
+
es5TargetWarningsShown = true;
|
|
46
|
+
}
|
|
42
47
|
}
|
|
43
48
|
const fileReplacements = {};
|
|
44
49
|
if (buildOptions.fileReplacements) {
|