@angular-devkit/build-angular 15.0.0-next.2 → 15.0.0-next.3
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 +11 -11
- package/src/builders/app-shell/index.js +16 -8
- package/src/builders/browser/schema.d.ts +6 -2
- package/src/builders/browser/schema.json +16 -2
- package/src/builders/browser-esbuild/options.js +6 -1
- package/src/builders/browser-esbuild/schema.d.ts +6 -2
- package/src/builders/browser-esbuild/schema.json +16 -2
- package/src/builders/karma/find-tests-plugin.d.ts +19 -0
- package/src/builders/karma/{find-tests.js → find-tests-plugin.js} +49 -5
- package/src/builders/karma/index.js +40 -38
- package/src/builders/karma/schema.d.ts +7 -3
- package/src/builders/karma/schema.json +18 -3
- package/src/builders/server/schema.d.ts +0 -5
- package/src/builders/server/schema.json +0 -5
- package/src/sass/sass-service-legacy.d.ts +51 -0
- package/src/sass/sass-service-legacy.js +175 -0
- package/src/sass/sass-service.d.ts +6 -9
- package/src/sass/sass-service.js +69 -52
- package/src/{builders/karma/find-tests.d.ts → sass/worker-legacy.d.ts} +1 -1
- package/src/sass/worker-legacy.js +44 -0
- package/src/sass/worker.js +64 -14
- package/src/utils/build-options.d.ts +1 -2
- package/src/utils/environment-options.d.ts +1 -0
- package/src/utils/environment-options.js +11 -1
- package/src/utils/normalize-builder-schema.d.ts +1 -0
- package/src/utils/normalize-builder-schema.js +3 -2
- package/src/utils/normalize-polyfills.d.ts +8 -0
- package/src/utils/normalize-polyfills.js +24 -0
- package/src/utils/webpack-diagnostics.d.ts +1 -1
- package/src/utils/webpack-diagnostics.js +2 -3
- package/src/webpack/configs/common.js +27 -12
- package/src/webpack/configs/styles.js +63 -60
- package/src/webpack/plugins/javascript-optimizer-plugin.js +2 -2
- package/src/webpack/plugins/karma/karma.js +4 -5
- package/src/webpack/plugins/transfer-size-plugin.js +2 -1
- package/src/webpack/utils/helpers.d.ts +0 -1
- package/src/webpack/utils/helpers.js +1 -20
- package/src/webpack/plugins/single-test-transform.d.ts +0 -27
- package/src/webpack/plugins/single-test-transform.js +0 -44
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.normalizePolyfills = void 0;
|
|
11
|
+
const fs_1 = require("fs");
|
|
12
|
+
const path_1 = require("path");
|
|
13
|
+
function normalizePolyfills(polyfills, root) {
|
|
14
|
+
if (!polyfills) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
const polyfillsList = Array.isArray(polyfills) ? polyfills : [polyfills];
|
|
18
|
+
return polyfillsList.map((p) => {
|
|
19
|
+
const resolvedPath = (0, path_1.resolve)(root, p);
|
|
20
|
+
// If file doesn't exist, let the bundle resolve it using node module resolution.
|
|
21
|
+
return (0, fs_1.existsSync)(resolvedPath) ? resolvedPath : p;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
exports.normalizePolyfills = normalizePolyfills;
|
|
@@ -5,6 +5,6 @@
|
|
|
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 { Compilation } from 'webpack';
|
|
8
|
+
import type { Compilation } from 'webpack';
|
|
9
9
|
export declare function addWarning(compilation: Compilation, message: string): void;
|
|
10
10
|
export declare function addError(compilation: Compilation, message: string): void;
|
|
@@ -8,12 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.addError = exports.addWarning = void 0;
|
|
11
|
-
const webpack_1 = require("webpack");
|
|
12
11
|
function addWarning(compilation, message) {
|
|
13
|
-
compilation.warnings.push(new
|
|
12
|
+
compilation.warnings.push(new compilation.compiler.webpack.WebpackError(message));
|
|
14
13
|
}
|
|
15
14
|
exports.addWarning = addWarning;
|
|
16
15
|
function addError(compilation, message) {
|
|
17
|
-
compilation.errors.push(new
|
|
16
|
+
compilation.errors.push(new compilation.compiler.webpack.WebpackError(message));
|
|
18
17
|
}
|
|
19
18
|
exports.addError = addError;
|
|
@@ -54,7 +54,7 @@ const VENDORS_TEST = /[\\/]node_modules[\\/]/;
|
|
|
54
54
|
async function getCommonConfig(wco) {
|
|
55
55
|
var _a, _b;
|
|
56
56
|
const { root, projectRoot, buildOptions, tsConfig, projectName, sourceRoot, tsConfigPath } = wco;
|
|
57
|
-
const { cache, codeCoverage, crossOrigin = 'none', platform = 'browser', aot = true, codeCoverageExclude = [], main, polyfills, sourceMap: { styles: stylesSourceMap, scripts: scriptsSourceMap, vendor: vendorSourceMap, hidden: hiddenSourceMap, }, optimization: { styles: stylesOptimization, scripts: scriptsOptimization }, commonChunk, vendorChunk, subresourceIntegrity, verbose, poll, webWorkerTsConfig, externalDependencies = [], allowedCommonJsDependencies,
|
|
57
|
+
const { cache, codeCoverage, crossOrigin = 'none', platform = 'browser', aot = true, codeCoverageExclude = [], main, polyfills, sourceMap: { styles: stylesSourceMap, scripts: scriptsSourceMap, vendor: vendorSourceMap, hidden: hiddenSourceMap, }, optimization: { styles: stylesOptimization, scripts: scriptsOptimization }, commonChunk, vendorChunk, subresourceIntegrity, verbose, poll, webWorkerTsConfig, externalDependencies = [], allowedCommonJsDependencies, } = buildOptions;
|
|
58
58
|
const isPlatformServer = buildOptions.platform === 'server';
|
|
59
59
|
const extraPlugins = [];
|
|
60
60
|
const extraRules = [];
|
|
@@ -76,14 +76,32 @@ async function getCommonConfig(wco) {
|
|
|
76
76
|
// Fixes Critical dependency: the request of a dependency is an expression
|
|
77
77
|
extraPlugins.push(new webpack_2.ContextReplacementPlugin(/@?hapi|express[\\/]/));
|
|
78
78
|
}
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
if (polyfills === null || polyfills === void 0 ? void 0 : polyfills.length) {
|
|
80
|
+
// `zone.js/testing` is a **special** polyfill because when not imported in the main it fails with the below errors:
|
|
81
|
+
// `Error: Expected to be running in 'ProxyZone', but it was not found.`
|
|
82
|
+
// This was also the reason why previously it was imported in `test.ts` as the first module.
|
|
83
|
+
// From Jia li:
|
|
84
|
+
// This is because the jasmine functions such as beforeEach/it will not be patched by zone.js since
|
|
85
|
+
// jasmine will not be loaded yet, so the ProxyZone will not be there. We have to load zone-testing.js after
|
|
86
|
+
// jasmine is ready.
|
|
87
|
+
// We could force loading 'zone.js/testing' prior to jasmine by changing the order of scripts in 'karma-context.html'.
|
|
88
|
+
// But this has it's own problems as zone.js needs to be loaded prior to jasmine due to patching of timing functions
|
|
89
|
+
// See: https://github.com/jasmine/jasmine/issues/1944
|
|
90
|
+
// Thus the correct order is zone.js -> jasmine -> zone.js/testing.
|
|
91
|
+
const zoneTestingEntryPoint = 'zone.js/testing';
|
|
92
|
+
const polyfillsExludingZoneTesting = polyfills.filter((p) => p !== zoneTestingEntryPoint);
|
|
93
|
+
if (Array.isArray(entryPoints['polyfills'])) {
|
|
94
|
+
entryPoints['polyfills'].push(...polyfillsExludingZoneTesting);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
entryPoints['polyfills'] = polyfillsExludingZoneTesting;
|
|
98
|
+
}
|
|
99
|
+
if (polyfillsExludingZoneTesting.length !== polyfills.length) {
|
|
100
|
+
if (Array.isArray(entryPoints['main'])) {
|
|
101
|
+
entryPoints['main'].unshift(zoneTestingEntryPoint);
|
|
84
102
|
}
|
|
85
103
|
else {
|
|
86
|
-
entryPoints['
|
|
104
|
+
entryPoints['main'] = [zoneTestingEntryPoint];
|
|
87
105
|
}
|
|
88
106
|
}
|
|
89
107
|
}
|
|
@@ -204,10 +222,6 @@ async function getCommonConfig(wco) {
|
|
|
204
222
|
if (platform === 'browser' && (scriptsOptimization || stylesOptimization.minify)) {
|
|
205
223
|
extraMinimizers.push(new transfer_size_plugin_1.TransferSizePlugin());
|
|
206
224
|
}
|
|
207
|
-
const externals = [...externalDependencies];
|
|
208
|
-
if (isPlatformServer && !bundleDependencies) {
|
|
209
|
-
externals.push(({ context, request }, callback) => (0, helpers_1.externalizePackages)(context !== null && context !== void 0 ? context : wco.projectRoot, request, callback));
|
|
210
|
-
}
|
|
211
225
|
let crossOriginLoading = false;
|
|
212
226
|
if (subresourceIntegrity && crossOrigin === 'none') {
|
|
213
227
|
crossOriginLoading = 'anonymous';
|
|
@@ -235,7 +249,7 @@ async function getCommonConfig(wco) {
|
|
|
235
249
|
},
|
|
236
250
|
context: root,
|
|
237
251
|
entry: entryPoints,
|
|
238
|
-
externals,
|
|
252
|
+
externals: externalDependencies,
|
|
239
253
|
output: {
|
|
240
254
|
uniqueName: projectName,
|
|
241
255
|
hashFunction: 'xxhash64',
|
|
@@ -280,6 +294,7 @@ async function getCommonConfig(wco) {
|
|
|
280
294
|
strictExportPresence: true,
|
|
281
295
|
parser: {
|
|
282
296
|
javascript: {
|
|
297
|
+
requireContext: false,
|
|
283
298
|
// Disable auto URL asset module creation. This doesn't effect `new Worker(new URL(...))`
|
|
284
299
|
// https://webpack.js.org/guides/asset-modules/#url-assets
|
|
285
300
|
url: false,
|
|
@@ -37,8 +37,9 @@ 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"));
|
|
40
|
-
const webpack_1 = require("webpack");
|
|
41
40
|
const sass_service_1 = require("../../sass/sass-service");
|
|
41
|
+
const sass_service_legacy_1 = require("../../sass/sass-service-legacy");
|
|
42
|
+
const environment_options_1 = require("../../utils/environment-options");
|
|
42
43
|
const plugins_1 = require("../plugins");
|
|
43
44
|
const css_optimizer_plugin_1 = require("../plugins/css-optimizer-plugin");
|
|
44
45
|
const helpers_1 = require("../utils/helpers");
|
|
@@ -83,7 +84,7 @@ exports.resolveGlobalStyles = resolveGlobalStyles;
|
|
|
83
84
|
// eslint-disable-next-line max-lines-per-function
|
|
84
85
|
function getStylesConfig(wco) {
|
|
85
86
|
var _a, _b, _c;
|
|
86
|
-
const { root, buildOptions } = wco;
|
|
87
|
+
const { root, projectRoot, buildOptions } = wco;
|
|
87
88
|
const extraPlugins = [];
|
|
88
89
|
extraPlugins.push(new plugins_1.AnyComponentStyleBudgetChecker(buildOptions.budgets));
|
|
89
90
|
const cssSourceMap = buildOptions.sourceMap.styles;
|
|
@@ -97,19 +98,14 @@ function getStylesConfig(wco) {
|
|
|
97
98
|
// Add plugin to remove hashes from lazy styles.
|
|
98
99
|
extraPlugins.push(new plugins_1.RemoveHashPlugin({ chunkNames: noInjectNames, hashFormat }));
|
|
99
100
|
}
|
|
100
|
-
const sassImplementation =
|
|
101
|
-
|
|
101
|
+
const sassImplementation = environment_options_1.useLegacySass
|
|
102
|
+
? new sass_service_legacy_1.SassLegacyWorkerImplementation()
|
|
103
|
+
: new sass_service_1.SassWorkerImplementation();
|
|
102
104
|
extraPlugins.push({
|
|
103
105
|
apply(compiler) {
|
|
104
106
|
compiler.hooks.shutdown.tap('sass-worker', () => {
|
|
105
107
|
sassImplementation.close();
|
|
106
108
|
});
|
|
107
|
-
compiler.hooks.afterCompile.tap('sass-worker', (compilation) => {
|
|
108
|
-
for (const message of sassTildeUsageMessage) {
|
|
109
|
-
compilation.warnings.push(new webpack_1.WebpackError(message));
|
|
110
|
-
}
|
|
111
|
-
sassTildeUsageMessage.clear();
|
|
112
|
-
});
|
|
113
109
|
},
|
|
114
110
|
});
|
|
115
111
|
const assetNameTemplate = (0, helpers_1.assetNameTemplateFactory)(hashFormat);
|
|
@@ -147,7 +143,6 @@ function getStylesConfig(wco) {
|
|
|
147
143
|
: undefined,
|
|
148
144
|
plugins: [
|
|
149
145
|
postcssImports({
|
|
150
|
-
resolve: (url) => (url.startsWith('~') ? url.slice(1) : url),
|
|
151
146
|
load: (filename) => {
|
|
152
147
|
return new Promise((resolve, reject) => {
|
|
153
148
|
loader.fs.readFile(filename, (err, data) => {
|
|
@@ -243,30 +238,7 @@ function getStylesConfig(wco) {
|
|
|
243
238
|
},
|
|
244
239
|
{
|
|
245
240
|
loader: require.resolve('sass-loader'),
|
|
246
|
-
options:
|
|
247
|
-
implementation: sassImplementation,
|
|
248
|
-
sourceMap: true,
|
|
249
|
-
sassOptions: {
|
|
250
|
-
importer: (url, from) => {
|
|
251
|
-
if (url.charAt(0) === '~') {
|
|
252
|
-
sassTildeUsageMessage.add(`'${from}' imports '${url}' with a tilde. Usage of '~' in imports is deprecated.`);
|
|
253
|
-
}
|
|
254
|
-
return null;
|
|
255
|
-
},
|
|
256
|
-
// Prevent use of `fibers` package as it no longer works in newer Node.js versions
|
|
257
|
-
fiber: false,
|
|
258
|
-
// bootstrap-sass requires a minimum precision of 8
|
|
259
|
-
precision: 8,
|
|
260
|
-
includePaths,
|
|
261
|
-
// Use expanded as otherwise sass will remove comments that are needed for autoprefixer
|
|
262
|
-
// Ex: /* autoprefixer grid: autoplace */
|
|
263
|
-
// See: https://github.com/webpack-contrib/sass-loader/blob/45ad0be17264ceada5f0b4fb87e9357abe85c4ff/src/getSassOptions.js#L68-L70
|
|
264
|
-
outputStyle: 'expanded',
|
|
265
|
-
// Silences compiler warnings from 3rd party stylesheets
|
|
266
|
-
quietDeps: !buildOptions.verbose,
|
|
267
|
-
verbose: buildOptions.verbose,
|
|
268
|
-
},
|
|
269
|
-
},
|
|
241
|
+
options: getSassLoaderOptions(root, projectRoot, sassImplementation, includePaths, false, !buildOptions.verbose),
|
|
270
242
|
},
|
|
271
243
|
],
|
|
272
244
|
},
|
|
@@ -281,31 +253,7 @@ function getStylesConfig(wco) {
|
|
|
281
253
|
},
|
|
282
254
|
{
|
|
283
255
|
loader: require.resolve('sass-loader'),
|
|
284
|
-
options:
|
|
285
|
-
implementation: sassImplementation,
|
|
286
|
-
sourceMap: true,
|
|
287
|
-
sassOptions: {
|
|
288
|
-
importer: (url, from) => {
|
|
289
|
-
if (url.charAt(0) === '~') {
|
|
290
|
-
sassTildeUsageMessage.add(`'${from}' imports '${url}' with a tilde. Usage of '~' in imports is deprecated.`);
|
|
291
|
-
}
|
|
292
|
-
return null;
|
|
293
|
-
},
|
|
294
|
-
// Prevent use of `fibers` package as it no longer works in newer Node.js versions
|
|
295
|
-
fiber: false,
|
|
296
|
-
indentedSyntax: true,
|
|
297
|
-
// bootstrap-sass requires a minimum precision of 8
|
|
298
|
-
precision: 8,
|
|
299
|
-
includePaths,
|
|
300
|
-
// Use expanded as otherwise sass will remove comments that are needed for autoprefixer
|
|
301
|
-
// Ex: /* autoprefixer grid: autoplace */
|
|
302
|
-
// See: https://github.com/webpack-contrib/sass-loader/blob/45ad0be17264ceada5f0b4fb87e9357abe85c4ff/src/getSassOptions.js#L68-L70
|
|
303
|
-
outputStyle: 'expanded',
|
|
304
|
-
// Silences compiler warnings from 3rd party stylesheets
|
|
305
|
-
quietDeps: !buildOptions.verbose,
|
|
306
|
-
verbose: buildOptions.verbose,
|
|
307
|
-
},
|
|
308
|
-
},
|
|
256
|
+
options: getSassLoaderOptions(root, projectRoot, sassImplementation, includePaths, true, !buildOptions.verbose),
|
|
309
257
|
},
|
|
310
258
|
],
|
|
311
259
|
},
|
|
@@ -382,3 +330,58 @@ function getTailwindConfigPath({ projectRoot, root }) {
|
|
|
382
330
|
}
|
|
383
331
|
return undefined;
|
|
384
332
|
}
|
|
333
|
+
function getSassLoaderOptions(root, projectRoot, implementation, includePaths, indentedSyntax, verbose) {
|
|
334
|
+
return implementation instanceof sass_service_1.SassWorkerImplementation
|
|
335
|
+
? {
|
|
336
|
+
sourceMap: true,
|
|
337
|
+
api: 'modern',
|
|
338
|
+
implementation,
|
|
339
|
+
// Webpack importer is only implemented in the legacy API.
|
|
340
|
+
// See: https://github.com/webpack-contrib/sass-loader/blob/997f3eb41d86dd00d5fa49c395a1aeb41573108c/src/utils.js#L642-L651
|
|
341
|
+
webpackImporter: false,
|
|
342
|
+
sassOptions: {
|
|
343
|
+
loadPaths: [
|
|
344
|
+
...includePaths,
|
|
345
|
+
// Needed to resolve node packages and retain the same behaviour of with the legacy API as sass-loader resolves
|
|
346
|
+
// scss also from the cwd and project root.
|
|
347
|
+
// See: https://github.com/webpack-contrib/sass-loader/blob/997f3eb41d86dd00d5fa49c395a1aeb41573108c/src/utils.js#L307
|
|
348
|
+
projectRoot,
|
|
349
|
+
path.join(root, 'node_modules'),
|
|
350
|
+
],
|
|
351
|
+
// Use expanded as otherwise sass will remove comments that are needed for autoprefixer
|
|
352
|
+
// Ex: /* autoprefixer grid: autoplace */
|
|
353
|
+
// See: https://github.com/webpack-contrib/sass-loader/blob/45ad0be17264ceada5f0b4fb87e9357abe85c4ff/src/getSassOptions.js#L68-L70
|
|
354
|
+
style: 'expanded',
|
|
355
|
+
// Silences compiler warnings from 3rd party stylesheets
|
|
356
|
+
quietDeps: !verbose,
|
|
357
|
+
verbose,
|
|
358
|
+
syntax: indentedSyntax ? 'indented' : 'scss',
|
|
359
|
+
},
|
|
360
|
+
}
|
|
361
|
+
: {
|
|
362
|
+
sourceMap: true,
|
|
363
|
+
api: 'legacy',
|
|
364
|
+
implementation,
|
|
365
|
+
sassOptions: {
|
|
366
|
+
importer: (url, from) => {
|
|
367
|
+
if (url.charAt(0) === '~') {
|
|
368
|
+
throw new Error(`'${from}' imports '${url}' with a tilde. Usage of '~' in imports is no longer supported.`);
|
|
369
|
+
}
|
|
370
|
+
return null;
|
|
371
|
+
},
|
|
372
|
+
// Prevent use of `fibers` package as it no longer works in newer Node.js versions
|
|
373
|
+
fiber: false,
|
|
374
|
+
indentedSyntax,
|
|
375
|
+
// bootstrap-sass requires a minimum precision of 8
|
|
376
|
+
precision: 8,
|
|
377
|
+
includePaths,
|
|
378
|
+
// Use expanded as otherwise sass will remove comments that are needed for autoprefixer
|
|
379
|
+
// Ex: /* autoprefixer grid: autoplace */
|
|
380
|
+
// See: https://github.com/webpack-contrib/sass-loader/blob/45ad0be17264ceada5f0b4fb87e9357abe85c4ff/src/getSassOptions.js#L68-L70
|
|
381
|
+
outputStyle: 'expanded',
|
|
382
|
+
// Silences compiler warnings from 3rd party stylesheets
|
|
383
|
+
quietDeps: !verbose,
|
|
384
|
+
verbose,
|
|
385
|
+
},
|
|
386
|
+
};
|
|
387
|
+
}
|
|
@@ -14,6 +14,7 @@ exports.JavaScriptOptimizerPlugin = void 0;
|
|
|
14
14
|
const piscina_1 = __importDefault(require("piscina"));
|
|
15
15
|
const environment_options_1 = require("../../utils/environment-options");
|
|
16
16
|
const esbuild_targets_1 = require("../../utils/esbuild-targets");
|
|
17
|
+
const webpack_diagnostics_1 = require("../../utils/webpack-diagnostics");
|
|
17
18
|
const esbuild_executor_1 = require("./esbuild-executor");
|
|
18
19
|
/**
|
|
19
20
|
* The maximum number of Workers that will be created to execute optimize tasks.
|
|
@@ -142,8 +143,7 @@ class JavaScriptOptimizerPlugin {
|
|
|
142
143
|
source: optimizedAsset,
|
|
143
144
|
});
|
|
144
145
|
}, (error) => {
|
|
145
|
-
|
|
146
|
-
compilation.errors.push(optimizationError);
|
|
146
|
+
(0, webpack_diagnostics_1.addError)(compilation, `Optimization error [${name}]: ${error.stack || error.message}`);
|
|
147
147
|
}));
|
|
148
148
|
}
|
|
149
149
|
await Promise.all(tasks);
|
|
@@ -109,7 +109,6 @@ const init = (config, emitter) => {
|
|
|
109
109
|
webpackConfig.output.path = `/${KARMA_APPLICATION_PATH}/`;
|
|
110
110
|
webpackConfig.output.publicPath = `/${KARMA_APPLICATION_PATH}/`;
|
|
111
111
|
const compiler = (0, webpack_1.default)(webpackConfig, (error, stats) => {
|
|
112
|
-
var _a;
|
|
113
112
|
if (error) {
|
|
114
113
|
throw error;
|
|
115
114
|
}
|
|
@@ -122,10 +121,10 @@ const init = (config, emitter) => {
|
|
|
122
121
|
warnings: true,
|
|
123
122
|
});
|
|
124
123
|
logger.error((0, stats_1.statsErrorsToString)(statsJson, { colors: true }));
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
124
|
+
if (config.singleRun) {
|
|
125
|
+
// Notify potential listeners of the compile error.
|
|
126
|
+
emitter.emit('load_error');
|
|
127
|
+
}
|
|
129
128
|
// Finish Karma run early in case of compilation error.
|
|
130
129
|
emitter.emit('run_complete', [], { exitCode: 1 });
|
|
131
130
|
// Emit a failure build event if there are compilation errors.
|
|
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.TransferSizePlugin = void 0;
|
|
11
11
|
const util_1 = require("util");
|
|
12
12
|
const zlib_1 = require("zlib");
|
|
13
|
+
const webpack_diagnostics_1 = require("../../utils/webpack-diagnostics");
|
|
13
14
|
const brotliCompressAsync = (0, util_1.promisify)(zlib_1.brotliCompress);
|
|
14
15
|
const PLUGIN_NAME = 'angular-transfer-size-estimator';
|
|
15
16
|
class TransferSizePlugin {
|
|
@@ -37,7 +38,7 @@ class TransferSizePlugin {
|
|
|
37
38
|
}));
|
|
38
39
|
})
|
|
39
40
|
.catch((error) => {
|
|
40
|
-
|
|
41
|
+
(0, webpack_diagnostics_1.addWarning)(compilation, `Unable to calculate estimated transfer size for '${assetName}'. Reason: ${error.message}`);
|
|
41
42
|
}));
|
|
42
43
|
}
|
|
43
44
|
await Promise.all(actions);
|
|
@@ -28,5 +28,4 @@ export declare function globalScriptsByBundleName(root: string, scripts: ScriptE
|
|
|
28
28
|
paths: string[];
|
|
29
29
|
}[];
|
|
30
30
|
export declare function assetPatterns(root: string, assets: AssetPatternClass[]): ObjectPattern[];
|
|
31
|
-
export declare function externalizePackages(context: string, request: string | undefined, callback: (error?: Error, result?: string) => void): void;
|
|
32
31
|
export declare function getStatsOptions(verbose?: boolean): WebpackStatsOptions;
|
|
@@ -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.getStatsOptions = exports.
|
|
36
|
+
exports.getStatsOptions = exports.assetPatterns = exports.globalScriptsByBundleName = exports.getCacheSettings = exports.getInstrumentationExcludedPaths = exports.assetNameTemplateFactory = exports.normalizeExtraEntryPoints = exports.getOutputHashFormat = void 0;
|
|
37
37
|
const crypto_1 = require("crypto");
|
|
38
38
|
const fs_1 = require("fs");
|
|
39
39
|
const glob_1 = __importDefault(require("glob"));
|
|
@@ -231,25 +231,6 @@ function assetPatterns(root, assets) {
|
|
|
231
231
|
});
|
|
232
232
|
}
|
|
233
233
|
exports.assetPatterns = assetPatterns;
|
|
234
|
-
function externalizePackages(context, request, callback) {
|
|
235
|
-
if (!request) {
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
// Absolute & Relative paths are not externals
|
|
239
|
-
if (request.startsWith('.') || path.isAbsolute(request)) {
|
|
240
|
-
callback();
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
try {
|
|
244
|
-
require.resolve(request, { paths: [context] });
|
|
245
|
-
callback(undefined, request);
|
|
246
|
-
}
|
|
247
|
-
catch {
|
|
248
|
-
// Node couldn't find it, so it must be user-aliased
|
|
249
|
-
callback();
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
exports.externalizePackages = externalizePackages;
|
|
253
234
|
function getStatsOptions(verbose = false) {
|
|
254
235
|
const webpackOutputOptions = {
|
|
255
236
|
all: false,
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import { logging } from '@angular-devkit/core';
|
|
9
|
-
export interface SingleTestTransformLoaderOptions {
|
|
10
|
-
files?: string[];
|
|
11
|
-
logger?: logging.Logger;
|
|
12
|
-
}
|
|
13
|
-
export declare const SingleTestTransformLoader: string;
|
|
14
|
-
/**
|
|
15
|
-
* This loader transforms the default test file to only run tests
|
|
16
|
-
* for some specs instead of all specs.
|
|
17
|
-
* It works by replacing the known content of the auto-generated test file:
|
|
18
|
-
* const context = require.context('./', true, /\.spec\.ts$/);
|
|
19
|
-
* context.keys().map(context);
|
|
20
|
-
* with:
|
|
21
|
-
* const context = { keys: () => ({ map: (_a) => { } }) };
|
|
22
|
-
* context.keys().map(context);
|
|
23
|
-
* So that it does nothing.
|
|
24
|
-
* Then it adds import statements for each file in the files options
|
|
25
|
-
* array to import them directly, and thus run the tests there.
|
|
26
|
-
*/
|
|
27
|
-
export default function loader(this: import('webpack').LoaderContext<SingleTestTransformLoaderOptions>, source: string): string;
|
|
@@ -1,44 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.SingleTestTransformLoader = void 0;
|
|
11
|
-
const core_1 = require("@angular-devkit/core");
|
|
12
|
-
const path_1 = require("path");
|
|
13
|
-
exports.SingleTestTransformLoader = __filename;
|
|
14
|
-
/**
|
|
15
|
-
* This loader transforms the default test file to only run tests
|
|
16
|
-
* for some specs instead of all specs.
|
|
17
|
-
* It works by replacing the known content of the auto-generated test file:
|
|
18
|
-
* const context = require.context('./', true, /\.spec\.ts$/);
|
|
19
|
-
* context.keys().map(context);
|
|
20
|
-
* with:
|
|
21
|
-
* const context = { keys: () => ({ map: (_a) => { } }) };
|
|
22
|
-
* context.keys().map(context);
|
|
23
|
-
* So that it does nothing.
|
|
24
|
-
* Then it adds import statements for each file in the files options
|
|
25
|
-
* array to import them directly, and thus run the tests there.
|
|
26
|
-
*/
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
-
function loader(source) {
|
|
29
|
-
const { files = [], logger = console } = this.getOptions();
|
|
30
|
-
// signal the user that expected content is not present.
|
|
31
|
-
if (!source.includes('require.context(')) {
|
|
32
|
-
logger.error(core_1.tags.stripIndent `The 'include' option requires that the 'main' file for tests includes the below line:
|
|
33
|
-
const context = require.context('./', true, /\.spec\.ts$/);
|
|
34
|
-
Arguments passed to require.context are not strict and can be changed.`);
|
|
35
|
-
return source;
|
|
36
|
-
}
|
|
37
|
-
const targettedImports = files
|
|
38
|
-
.map((path) => `require('./${path.replace('.' + (0, path_1.extname)(path), '')}');`)
|
|
39
|
-
.join('\n');
|
|
40
|
-
const mockedRequireContext = 'Object.assign(() => { }, { keys: () => [], resolve: () => undefined });\n';
|
|
41
|
-
source = source.replace(/require\.context\(.*/, mockedRequireContext + targettedImports);
|
|
42
|
-
return source;
|
|
43
|
-
}
|
|
44
|
-
exports.default = loader;
|