@angular-devkit/build-angular 15.0.0-next.2 → 15.0.0-next.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 +16 -15
- 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/compiler-plugin.d.ts +9 -2
- package/src/builders/browser-esbuild/compiler-plugin.js +114 -90
- package/src/builders/browser-esbuild/esbuild.d.ts +4 -3
- package/src/builders/browser-esbuild/esbuild.js +12 -6
- package/src/builders/browser-esbuild/experimental-warnings.js +0 -3
- package/src/builders/browser-esbuild/index.d.ts +3 -3
- package/src/builders/browser-esbuild/index.js +143 -86
- package/src/builders/browser-esbuild/options.d.ts +26 -4
- package/src/builders/browser-esbuild/options.js +62 -6
- package/src/builders/browser-esbuild/schema.d.ts +6 -2
- package/src/builders/browser-esbuild/schema.json +16 -2
- package/src/builders/browser-esbuild/watcher.d.ts +23 -0
- package/src/builders/browser-esbuild/watcher.js +93 -0
- 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.d.ts +1 -1
- package/src/builders/karma/index.js +86 -43
- package/src/builders/karma/schema.d.ts +8 -4
- 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/process-bundle.js +1 -1
- package/src/utils/service-worker.d.ts +3 -0
- package/src/utils/service-worker.js +29 -2
- package/src/utils/webpack-diagnostics.d.ts +1 -1
- package/src/utils/webpack-diagnostics.js +2 -3
- package/src/webpack/configs/common.js +29 -14
- package/src/webpack/configs/styles.d.ts +1 -7
- package/src/webpack/configs/styles.js +102 -106
- package/src/webpack/plugins/javascript-optimizer-plugin.js +2 -2
- package/src/webpack/plugins/karma/karma.js +4 -5
- package/src/webpack/plugins/scripts-webpack-plugin.js +24 -5
- package/src/webpack/plugins/styles-webpack-plugin.d.ts +19 -0
- package/src/webpack/plugins/styles-webpack-plugin.js +71 -0
- package/src/webpack/plugins/transfer-size-plugin.js +2 -1
- package/src/webpack/utils/helpers.d.ts +5 -2
- package/src/webpack/utils/helpers.js +24 -33
- package/src/webpack/plugins/single-test-transform.d.ts +0 -27
- package/src/webpack/plugins/single-test-transform.js +0 -44
|
@@ -0,0 +1,71 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.StylesWebpackPlugin = void 0;
|
|
14
|
+
const assert_1 = __importDefault(require("assert"));
|
|
15
|
+
const error_1 = require("../../utils/error");
|
|
16
|
+
const webpack_diagnostics_1 = require("../../utils/webpack-diagnostics");
|
|
17
|
+
/**
|
|
18
|
+
* The name of the plugin provided to Webpack when tapping Webpack compiler hooks.
|
|
19
|
+
*/
|
|
20
|
+
const PLUGIN_NAME = 'styles-webpack-plugin';
|
|
21
|
+
class StylesWebpackPlugin {
|
|
22
|
+
constructor(options) {
|
|
23
|
+
this.options = options;
|
|
24
|
+
}
|
|
25
|
+
apply(compiler) {
|
|
26
|
+
const { entryPoints, preserveSymlinks, root } = this.options;
|
|
27
|
+
const webpackOptions = compiler.options;
|
|
28
|
+
const entry = typeof webpackOptions.entry === 'function' ? webpackOptions.entry() : webpackOptions.entry;
|
|
29
|
+
const resolver = compiler.resolverFactory.get('global-styles', {
|
|
30
|
+
conditionNames: ['sass', 'less', 'style'],
|
|
31
|
+
mainFields: ['sass', 'less', 'style', 'main', '...'],
|
|
32
|
+
extensions: ['.scss', '.sass', '.less', '.css'],
|
|
33
|
+
restrictions: [/\.((le|sa|sc|c)ss)$/i],
|
|
34
|
+
preferRelative: true,
|
|
35
|
+
useSyncFileSystemCalls: true,
|
|
36
|
+
symlinks: !preserveSymlinks,
|
|
37
|
+
fileSystem: compiler.inputFileSystem,
|
|
38
|
+
});
|
|
39
|
+
webpackOptions.entry = async () => {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
var _c;
|
|
42
|
+
const entrypoints = await entry;
|
|
43
|
+
for (const [bundleName, paths] of Object.entries(entryPoints)) {
|
|
44
|
+
(_a = entrypoints[bundleName]) !== null && _a !== void 0 ? _a : (entrypoints[bundleName] = {});
|
|
45
|
+
const entryImport = ((_b = (_c = entrypoints[bundleName]).import) !== null && _b !== void 0 ? _b : (_c.import = []));
|
|
46
|
+
for (const path of paths) {
|
|
47
|
+
try {
|
|
48
|
+
const resolvedPath = resolver.resolveSync({}, root, path);
|
|
49
|
+
if (resolvedPath) {
|
|
50
|
+
entryImport.push(`${resolvedPath}?ngGlobalStyle`);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
(0, assert_1.default)(this.compilation, 'Compilation cannot be undefined.');
|
|
54
|
+
(0, webpack_diagnostics_1.addError)(this.compilation, `Cannot resolve '${path}'.`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
(0, assert_1.default)(this.compilation, 'Compilation cannot be undefined.');
|
|
59
|
+
(0, error_1.assertIsError)(error);
|
|
60
|
+
(0, webpack_diagnostics_1.addError)(this.compilation, error.message);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return entrypoints;
|
|
65
|
+
};
|
|
66
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
67
|
+
this.compilation = compilation;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.StylesWebpackPlugin = StylesWebpackPlugin;
|
|
@@ -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);
|
|
@@ -21,12 +21,15 @@ export declare type NormalizedEntryPoint = Required<Exclude<ScriptElement | Styl
|
|
|
21
21
|
export declare function normalizeExtraEntryPoints(extraEntryPoints: (ScriptElement | StyleElement)[], defaultBundleName: string): NormalizedEntryPoint[];
|
|
22
22
|
export declare function assetNameTemplateFactory(hashFormat: HashFormat): (resourcePath: string) => string;
|
|
23
23
|
export declare function getInstrumentationExcludedPaths(root: string, excludedPaths: string[]): Set<string>;
|
|
24
|
+
export declare function normalizeGlobalStyles(styleEntrypoints: StyleElement[]): {
|
|
25
|
+
entryPoints: Record<string, string[]>;
|
|
26
|
+
noInjectNames: string[];
|
|
27
|
+
};
|
|
24
28
|
export declare function getCacheSettings(wco: WebpackConfigOptions, angularVersion: string): WebpackOptionsNormalized['cache'];
|
|
25
|
-
export declare function globalScriptsByBundleName(
|
|
29
|
+
export declare function globalScriptsByBundleName(scripts: ScriptElement[]): {
|
|
26
30
|
bundleName: string;
|
|
27
31
|
inject: boolean;
|
|
28
32
|
paths: string[];
|
|
29
33
|
}[];
|
|
30
34
|
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
35
|
export declare function getStatsOptions(verbose?: boolean): WebpackStatsOptions;
|
|
@@ -33,9 +33,8 @@ 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.normalizeGlobalStyles = exports.getInstrumentationExcludedPaths = exports.assetNameTemplateFactory = exports.normalizeExtraEntryPoints = exports.getOutputHashFormat = void 0;
|
|
37
37
|
const crypto_1 = require("crypto");
|
|
38
|
-
const fs_1 = require("fs");
|
|
39
38
|
const glob_1 = __importDefault(require("glob"));
|
|
40
39
|
const path = __importStar(require("path"));
|
|
41
40
|
const schema_1 = require("../../builders/browser/schema");
|
|
@@ -130,6 +129,26 @@ function getInstrumentationExcludedPaths(root, excludedPaths) {
|
|
|
130
129
|
return excluded;
|
|
131
130
|
}
|
|
132
131
|
exports.getInstrumentationExcludedPaths = getInstrumentationExcludedPaths;
|
|
132
|
+
function normalizeGlobalStyles(styleEntrypoints) {
|
|
133
|
+
var _a;
|
|
134
|
+
var _b;
|
|
135
|
+
const entryPoints = {};
|
|
136
|
+
const noInjectNames = [];
|
|
137
|
+
if (styleEntrypoints.length === 0) {
|
|
138
|
+
return { entryPoints, noInjectNames };
|
|
139
|
+
}
|
|
140
|
+
for (const style of normalizeExtraEntryPoints(styleEntrypoints, 'styles')) {
|
|
141
|
+
// Add style entry points.
|
|
142
|
+
(_a = entryPoints[_b = style.bundleName]) !== null && _a !== void 0 ? _a : (entryPoints[_b] = []);
|
|
143
|
+
entryPoints[style.bundleName].push(style.input);
|
|
144
|
+
// Add non injected styles to the list.
|
|
145
|
+
if (!style.inject) {
|
|
146
|
+
noInjectNames.push(style.bundleName);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return { entryPoints, noInjectNames };
|
|
150
|
+
}
|
|
151
|
+
exports.normalizeGlobalStyles = normalizeGlobalStyles;
|
|
133
152
|
function getCacheSettings(wco, angularVersion) {
|
|
134
153
|
const { enabled, path: cacheDirectory } = wco.buildOptions.cache;
|
|
135
154
|
if (enabled) {
|
|
@@ -164,31 +183,22 @@ function getCacheSettings(wco, angularVersion) {
|
|
|
164
183
|
return false;
|
|
165
184
|
}
|
|
166
185
|
exports.getCacheSettings = getCacheSettings;
|
|
167
|
-
function globalScriptsByBundleName(
|
|
186
|
+
function globalScriptsByBundleName(scripts) {
|
|
168
187
|
return normalizeExtraEntryPoints(scripts, 'scripts').reduce((prev, curr) => {
|
|
169
188
|
const { bundleName, inject, input } = curr;
|
|
170
|
-
let resolvedPath = path.resolve(root, input);
|
|
171
|
-
if (!(0, fs_1.existsSync)(resolvedPath)) {
|
|
172
|
-
try {
|
|
173
|
-
resolvedPath = require.resolve(input, { paths: [root] });
|
|
174
|
-
}
|
|
175
|
-
catch {
|
|
176
|
-
throw new Error(`Script file ${input} does not exist.`);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
189
|
const existingEntry = prev.find((el) => el.bundleName === bundleName);
|
|
180
190
|
if (existingEntry) {
|
|
181
191
|
if (existingEntry.inject && !inject) {
|
|
182
192
|
// All entries have to be lazy for the bundle to be lazy.
|
|
183
193
|
throw new Error(`The ${bundleName} bundle is mixing injected and non-injected scripts.`);
|
|
184
194
|
}
|
|
185
|
-
existingEntry.paths.push(
|
|
195
|
+
existingEntry.paths.push(input);
|
|
186
196
|
}
|
|
187
197
|
else {
|
|
188
198
|
prev.push({
|
|
189
199
|
bundleName,
|
|
190
200
|
inject,
|
|
191
|
-
paths: [
|
|
201
|
+
paths: [input],
|
|
192
202
|
});
|
|
193
203
|
}
|
|
194
204
|
return prev;
|
|
@@ -231,25 +241,6 @@ function assetPatterns(root, assets) {
|
|
|
231
241
|
});
|
|
232
242
|
}
|
|
233
243
|
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
244
|
function getStatsOptions(verbose = false) {
|
|
254
245
|
const webpackOutputOptions = {
|
|
255
246
|
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;
|