@angular-devkit/build-angular 14.0.0-next.7 → 14.0.0-rc.0
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 +30 -30
- package/src/babel/presets/application.d.ts +1 -1
- package/src/babel/webpack-loader.d.ts +1 -0
- package/src/babel/webpack-loader.js +2 -0
- package/src/builders/app-shell/index.js +1 -2
- package/src/builders/browser/index.js +3 -4
- 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 +34 -0
- package/src/builders/browser-esbuild/esbuild.js +59 -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 +258 -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 +118 -0
- package/src/builders/karma/index.d.ts +1 -1
- package/src/builders/karma/index.js +5 -5
- package/src/utils/normalize-asset-patterns.d.ts +2 -2
- package/src/utils/normalize-asset-patterns.js +34 -10
- package/src/utils/normalize-builder-schema.js +2 -3
- package/src/utils/normalize-file-replacements.d.ts +4 -4
- package/src/utils/normalize-file-replacements.js +38 -18
- package/src/utils/service-worker.d.ts +1 -2
- package/src/utils/service-worker.js +9 -11
- 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/karma/karma.js +6 -26
- package/src/webpack/plugins/typescript.js +1 -2
|
@@ -0,0 +1,118 @@
|
|
|
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: '/',
|
|
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
|
+
const filename = path.basename(outputFile.path);
|
|
66
|
+
if (filename.endsWith('.css')) {
|
|
67
|
+
outputPath = outputFile.path;
|
|
68
|
+
contents = outputFile.text;
|
|
69
|
+
}
|
|
70
|
+
else if (filename.endsWith('.css.map')) {
|
|
71
|
+
map = outputFile.text;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
// The output files could also contain resources (images/fonts/etc.) that were referenced
|
|
75
|
+
resourceFiles.push(outputFile);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
errors: result.errors,
|
|
81
|
+
warnings: result.warnings,
|
|
82
|
+
contents,
|
|
83
|
+
map,
|
|
84
|
+
path: outputPath,
|
|
85
|
+
resourceFiles,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Bundle a stylesheet that exists as a file on the filesystem.
|
|
90
|
+
*
|
|
91
|
+
* @param filename The path to the file to bundle.
|
|
92
|
+
* @param options The stylesheet bundling options to use.
|
|
93
|
+
* @returns The bundle result object.
|
|
94
|
+
*/
|
|
95
|
+
async function bundleStylesheetFile(filename, options) {
|
|
96
|
+
return bundleStylesheet({ entryPoints: [filename] }, options);
|
|
97
|
+
}
|
|
98
|
+
exports.bundleStylesheetFile = bundleStylesheetFile;
|
|
99
|
+
/**
|
|
100
|
+
* Bundle stylesheet text data from a string.
|
|
101
|
+
*
|
|
102
|
+
* @param data The string content of a stylesheet to bundle.
|
|
103
|
+
* @param dataOptions The options to use to resolve references and name output of the stylesheet data.
|
|
104
|
+
* @param bundleOptions The stylesheet bundling options to use.
|
|
105
|
+
* @returns The bundle result object.
|
|
106
|
+
*/
|
|
107
|
+
async function bundleStylesheetText(data, dataOptions, bundleOptions) {
|
|
108
|
+
const result = bundleStylesheet({
|
|
109
|
+
stdin: {
|
|
110
|
+
contents: data,
|
|
111
|
+
sourcefile: dataOptions.virtualName,
|
|
112
|
+
resolveDir: dataOptions.resolvePath,
|
|
113
|
+
loader: 'css',
|
|
114
|
+
},
|
|
115
|
+
}, bundleOptions);
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
exports.bundleStylesheetText = bundleStylesheetText;
|
|
@@ -23,5 +23,5 @@ export declare function execute(options: KarmaBuilderOptions, context: BuilderCo
|
|
|
23
23
|
karmaOptions?: (options: KarmaConfigOptions) => KarmaConfigOptions;
|
|
24
24
|
}): Observable<BuilderOutput>;
|
|
25
25
|
export { KarmaBuilderOptions };
|
|
26
|
-
declare const _default: import("@angular-devkit/architect/src/internal").Builder<Record<string, string> & KarmaBuilderOptions & import("
|
|
26
|
+
declare const _default: import("@angular-devkit/architect/src/internal").Builder<Record<string, string> & KarmaBuilderOptions & import("../../../../core/src").JsonObject>;
|
|
27
27
|
export default _default;
|
|
@@ -32,8 +32,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
33
|
exports.execute = void 0;
|
|
34
34
|
const architect_1 = require("@angular-devkit/architect");
|
|
35
|
-
const
|
|
36
|
-
const path_1 = require("path");
|
|
35
|
+
const path = __importStar(require("path"));
|
|
37
36
|
const rxjs_1 = require("rxjs");
|
|
38
37
|
const operators_1 = require("rxjs/operators");
|
|
39
38
|
const purge_cache_1 = require("../../utils/purge-cache");
|
|
@@ -108,7 +107,8 @@ function execute(options, context, transforms = {}) {
|
|
|
108
107
|
throw new Error('The builder requires a target.');
|
|
109
108
|
}
|
|
110
109
|
const projectMetadata = await context.getProjectMetadata(projectName);
|
|
111
|
-
const
|
|
110
|
+
const projectRoot = path.join(context.workspaceRoot, (_c = projectMetadata.root) !== null && _c !== void 0 ? _c : '');
|
|
111
|
+
const projectSourceRoot = path.join(projectRoot, (_d = projectMetadata.sourceRoot) !== null && _d !== void 0 ? _d : '');
|
|
112
112
|
const files = await (0, find_tests_1.findTests)(options.include, context.workspaceRoot, projectSourceRoot);
|
|
113
113
|
// early exit, no reason to start karma
|
|
114
114
|
if (!files.length) {
|
|
@@ -123,7 +123,7 @@ function execute(options, context, transforms = {}) {
|
|
|
123
123
|
webpackConfig.module.rules = rules;
|
|
124
124
|
}
|
|
125
125
|
rules.unshift({
|
|
126
|
-
test:
|
|
126
|
+
test: path.resolve(context.workspaceRoot, options.main),
|
|
127
127
|
use: {
|
|
128
128
|
// cannot be a simple path as it differs between environments
|
|
129
129
|
loader: single_test_transform_1.SingleTestTransformLoader,
|
|
@@ -139,7 +139,7 @@ function execute(options, context, transforms = {}) {
|
|
|
139
139
|
webpackConfig,
|
|
140
140
|
logger: context.logger,
|
|
141
141
|
};
|
|
142
|
-
const config = await karma.config.parseConfig(
|
|
142
|
+
const config = await karma.config.parseConfig(path.resolve(context.workspaceRoot, options.karmaConfig), transforms.karmaOptions ? transforms.karmaOptions(karmaOptions) : karmaOptions, { promiseConfig: true, throwErrors: true });
|
|
143
143
|
return [karma, config];
|
|
144
144
|
}), (0, operators_1.switchMap)(([karma, karmaConfig]) => new rxjs_1.Observable((subscriber) => {
|
|
145
145
|
var _a, _b, _c;
|
|
@@ -5,9 +5,9 @@
|
|
|
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 { BaseException
|
|
8
|
+
import { BaseException } from '@angular-devkit/core';
|
|
9
9
|
import { AssetPattern, AssetPatternClass } from '../builders/browser/schema';
|
|
10
10
|
export declare class MissingAssetSourceRootException extends BaseException {
|
|
11
11
|
constructor(path: String);
|
|
12
12
|
}
|
|
13
|
-
export declare function normalizeAssetPatterns(assetPatterns: AssetPattern[],
|
|
13
|
+
export declare function normalizeAssetPatterns(assetPatterns: AssetPattern[], workspaceRoot: string, projectRoot: string, projectSourceRoot: string | undefined): AssetPatternClass[];
|
|
@@ -6,28 +6,52 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
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
|
+
};
|
|
9
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
33
|
exports.normalizeAssetPatterns = exports.MissingAssetSourceRootException = void 0;
|
|
11
34
|
const core_1 = require("@angular-devkit/core");
|
|
12
35
|
const fs_1 = require("fs");
|
|
36
|
+
const path = __importStar(require("path"));
|
|
13
37
|
class MissingAssetSourceRootException extends core_1.BaseException {
|
|
14
38
|
constructor(path) {
|
|
15
39
|
super(`The ${path} asset path must start with the project source root.`);
|
|
16
40
|
}
|
|
17
41
|
}
|
|
18
42
|
exports.MissingAssetSourceRootException = MissingAssetSourceRootException;
|
|
19
|
-
function normalizeAssetPatterns(assetPatterns,
|
|
20
|
-
// When sourceRoot is not available, we default to ${projectRoot}/src.
|
|
21
|
-
const sourceRoot = maybeSourceRoot || (0, core_1.join)(projectRoot, 'src');
|
|
22
|
-
const resolvedSourceRoot = (0, core_1.resolve)(root, sourceRoot);
|
|
43
|
+
function normalizeAssetPatterns(assetPatterns, workspaceRoot, projectRoot, projectSourceRoot) {
|
|
23
44
|
if (assetPatterns.length === 0) {
|
|
24
45
|
return [];
|
|
25
46
|
}
|
|
47
|
+
// When sourceRoot is not available, we default to ${projectRoot}/src.
|
|
48
|
+
const sourceRoot = projectSourceRoot || path.join(projectRoot, 'src');
|
|
49
|
+
const resolvedSourceRoot = path.resolve(workspaceRoot, sourceRoot);
|
|
26
50
|
return assetPatterns.map((assetPattern) => {
|
|
27
51
|
// Normalize string asset patterns to objects.
|
|
28
52
|
if (typeof assetPattern === 'string') {
|
|
29
|
-
const assetPath =
|
|
30
|
-
const resolvedAssetPath =
|
|
53
|
+
const assetPath = path.normalize(assetPattern);
|
|
54
|
+
const resolvedAssetPath = path.resolve(workspaceRoot, assetPath);
|
|
31
55
|
// Check if the string asset is within sourceRoot.
|
|
32
56
|
if (!resolvedAssetPath.startsWith(resolvedSourceRoot)) {
|
|
33
57
|
throw new MissingAssetSourceRootException(assetPattern);
|
|
@@ -35,7 +59,7 @@ function normalizeAssetPatterns(assetPatterns, root, projectRoot, maybeSourceRoo
|
|
|
35
59
|
let glob, input;
|
|
36
60
|
let isDirectory = false;
|
|
37
61
|
try {
|
|
38
|
-
isDirectory = (0, fs_1.statSync)(
|
|
62
|
+
isDirectory = (0, fs_1.statSync)(resolvedAssetPath).isDirectory();
|
|
39
63
|
}
|
|
40
64
|
catch {
|
|
41
65
|
isDirectory = true;
|
|
@@ -48,12 +72,12 @@ function normalizeAssetPatterns(assetPatterns, root, projectRoot, maybeSourceRoo
|
|
|
48
72
|
}
|
|
49
73
|
else {
|
|
50
74
|
// Files are their own glob.
|
|
51
|
-
glob =
|
|
75
|
+
glob = path.basename(assetPath);
|
|
52
76
|
// Input directory is their original dirname.
|
|
53
|
-
input =
|
|
77
|
+
input = path.dirname(assetPath);
|
|
54
78
|
}
|
|
55
79
|
// Output directory for both is the relative path from source root to input.
|
|
56
|
-
const output =
|
|
80
|
+
const output = path.relative(resolvedSourceRoot, path.resolve(workspaceRoot, input));
|
|
57
81
|
// Return the asset pattern in object format.
|
|
58
82
|
return { glob, input, output };
|
|
59
83
|
}
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.normalizeBrowserSchema = void 0;
|
|
11
|
-
const core_1 = require("@angular-devkit/core");
|
|
12
11
|
const normalize_asset_patterns_1 = require("./normalize-asset-patterns");
|
|
13
12
|
const normalize_cache_1 = require("./normalize-cache");
|
|
14
13
|
const normalize_file_replacements_1 = require("./normalize-file-replacements");
|
|
@@ -20,8 +19,8 @@ function normalizeBrowserSchema(workspaceRoot, projectRoot, projectSourceRoot, o
|
|
|
20
19
|
return {
|
|
21
20
|
...options,
|
|
22
21
|
cache: (0, normalize_cache_1.normalizeCacheOptions)(metadata, workspaceRoot),
|
|
23
|
-
assets: (0, normalize_asset_patterns_1.normalizeAssetPatterns)(options.assets || [],
|
|
24
|
-
fileReplacements: (0, normalize_file_replacements_1.normalizeFileReplacements)(options.fileReplacements || [],
|
|
22
|
+
assets: (0, normalize_asset_patterns_1.normalizeAssetPatterns)(options.assets || [], workspaceRoot, projectRoot, projectSourceRoot),
|
|
23
|
+
fileReplacements: (0, normalize_file_replacements_1.normalizeFileReplacements)(options.fileReplacements || [], workspaceRoot),
|
|
25
24
|
optimization: (0, normalize_optimization_1.normalizeOptimization)(options.optimization),
|
|
26
25
|
sourceMap: normalizedSourceMapOptions,
|
|
27
26
|
preserveSymlinks: options.preserveSymlinks === undefined
|
|
@@ -5,13 +5,13 @@
|
|
|
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 { BaseException
|
|
8
|
+
import { BaseException } from '@angular-devkit/core';
|
|
9
9
|
import { FileReplacement } from '../builders/browser/schema';
|
|
10
10
|
export declare class MissingFileReplacementException extends BaseException {
|
|
11
11
|
constructor(path: String);
|
|
12
12
|
}
|
|
13
13
|
export interface NormalizedFileReplacement {
|
|
14
|
-
replace:
|
|
15
|
-
with:
|
|
14
|
+
replace: string;
|
|
15
|
+
with: string;
|
|
16
16
|
}
|
|
17
|
-
export declare function normalizeFileReplacements(fileReplacements: FileReplacement[],
|
|
17
|
+
export declare function normalizeFileReplacements(fileReplacements: FileReplacement[], workspaceRoot: string): NormalizedFileReplacement[];
|
|
@@ -6,27 +6,51 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
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
|
+
};
|
|
9
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
33
|
exports.normalizeFileReplacements = exports.MissingFileReplacementException = void 0;
|
|
11
34
|
const core_1 = require("@angular-devkit/core");
|
|
12
35
|
const fs_1 = require("fs");
|
|
36
|
+
const path = __importStar(require("path"));
|
|
13
37
|
class MissingFileReplacementException extends core_1.BaseException {
|
|
14
38
|
constructor(path) {
|
|
15
39
|
super(`The ${path} path in file replacements does not exist.`);
|
|
16
40
|
}
|
|
17
41
|
}
|
|
18
42
|
exports.MissingFileReplacementException = MissingFileReplacementException;
|
|
19
|
-
function normalizeFileReplacements(fileReplacements,
|
|
43
|
+
function normalizeFileReplacements(fileReplacements, workspaceRoot) {
|
|
20
44
|
if (fileReplacements.length === 0) {
|
|
21
45
|
return [];
|
|
22
46
|
}
|
|
23
|
-
const normalizedReplacement = fileReplacements.map((replacement) => normalizeFileReplacement(replacement,
|
|
47
|
+
const normalizedReplacement = fileReplacements.map((replacement) => normalizeFileReplacement(replacement, workspaceRoot));
|
|
24
48
|
for (const { replace, with: replacementWith } of normalizedReplacement) {
|
|
25
|
-
if (!(0, fs_1.existsSync)(
|
|
26
|
-
throw new MissingFileReplacementException(
|
|
49
|
+
if (!(0, fs_1.existsSync)(replacementWith)) {
|
|
50
|
+
throw new MissingFileReplacementException(replacementWith);
|
|
27
51
|
}
|
|
28
|
-
if (!(0, fs_1.existsSync)(
|
|
29
|
-
throw new MissingFileReplacementException(
|
|
52
|
+
if (!(0, fs_1.existsSync)(replace)) {
|
|
53
|
+
throw new MissingFileReplacementException(replace);
|
|
30
54
|
}
|
|
31
55
|
}
|
|
32
56
|
return normalizedReplacement;
|
|
@@ -36,22 +60,18 @@ function normalizeFileReplacement(fileReplacement, root) {
|
|
|
36
60
|
let replacePath;
|
|
37
61
|
let withPath;
|
|
38
62
|
if (fileReplacement.src && fileReplacement.replaceWith) {
|
|
39
|
-
replacePath =
|
|
40
|
-
withPath =
|
|
63
|
+
replacePath = fileReplacement.src;
|
|
64
|
+
withPath = fileReplacement.replaceWith;
|
|
41
65
|
}
|
|
42
66
|
else if (fileReplacement.replace && fileReplacement.with) {
|
|
43
|
-
replacePath =
|
|
44
|
-
withPath =
|
|
67
|
+
replacePath = fileReplacement.replace;
|
|
68
|
+
withPath = fileReplacement.with;
|
|
45
69
|
}
|
|
46
70
|
else {
|
|
47
71
|
throw new Error(`Invalid file replacement: ${JSON.stringify(fileReplacement)}`);
|
|
48
72
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
if (root) {
|
|
54
|
-
withPath = (0, core_1.join)(root, withPath);
|
|
55
|
-
}
|
|
56
|
-
return { replace: replacePath, with: withPath };
|
|
73
|
+
return {
|
|
74
|
+
replace: path.join(root, replacePath),
|
|
75
|
+
with: path.join(root, withPath),
|
|
76
|
+
};
|
|
57
77
|
}
|
|
@@ -5,5 +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
|
-
|
|
9
|
-
export declare function augmentAppWithServiceWorker(appRoot: Path, outputPath: Path, baseHref: string, ngswConfigPath?: string): Promise<void>;
|
|
8
|
+
export declare function augmentAppWithServiceWorker(appRoot: string, workspaceRoot: string, outputPath: string, baseHref: string, ngswConfigPath?: string): Promise<void>;
|
|
@@ -31,7 +31,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
31
31
|
};
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
33
|
exports.augmentAppWithServiceWorker = void 0;
|
|
34
|
-
const core_1 = require("@angular-devkit/core");
|
|
35
34
|
const crypto = __importStar(require("crypto"));
|
|
36
35
|
const fs_1 = require("fs");
|
|
37
36
|
const path = __importStar(require("path"));
|
|
@@ -76,12 +75,11 @@ class CliFilesystem {
|
|
|
76
75
|
return items;
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
|
-
async function augmentAppWithServiceWorker(appRoot, outputPath, baseHref, ngswConfigPath) {
|
|
80
|
-
const distPath = (0, core_1.getSystemPath)((0, core_1.normalize)(outputPath));
|
|
78
|
+
async function augmentAppWithServiceWorker(appRoot, workspaceRoot, outputPath, baseHref, ngswConfigPath) {
|
|
81
79
|
// Determine the configuration file path
|
|
82
80
|
const configPath = ngswConfigPath
|
|
83
|
-
?
|
|
84
|
-
: path.join(
|
|
81
|
+
? path.join(workspaceRoot, ngswConfigPath)
|
|
82
|
+
: path.join(appRoot, 'ngsw-config.json');
|
|
85
83
|
// Read the configuration file
|
|
86
84
|
let config;
|
|
87
85
|
try {
|
|
@@ -91,7 +89,7 @@ async function augmentAppWithServiceWorker(appRoot, outputPath, baseHref, ngswCo
|
|
|
91
89
|
catch (error) {
|
|
92
90
|
if (error.code === 'ENOENT') {
|
|
93
91
|
throw new Error('Error: Expected to find an ngsw-config.json configuration file' +
|
|
94
|
-
` in the ${
|
|
92
|
+
` in the ${appRoot} folder. Either provide one or` +
|
|
95
93
|
' disable Service Worker in the angular.json configuration file.');
|
|
96
94
|
}
|
|
97
95
|
else {
|
|
@@ -103,20 +101,20 @@ async function augmentAppWithServiceWorker(appRoot, outputPath, baseHref, ngswCo
|
|
|
103
101
|
// changed to a direct dynamic import.
|
|
104
102
|
const GeneratorConstructor = (await (0, load_esm_1.loadEsmModule)('@angular/service-worker/config')).Generator;
|
|
105
103
|
// Generate the manifest
|
|
106
|
-
const generator = new GeneratorConstructor(new CliFilesystem(
|
|
104
|
+
const generator = new GeneratorConstructor(new CliFilesystem(outputPath), baseHref);
|
|
107
105
|
const output = await generator.process(config);
|
|
108
106
|
// Write the manifest
|
|
109
107
|
const manifest = JSON.stringify(output, null, 2);
|
|
110
|
-
await fs_1.promises.writeFile(path.join(
|
|
108
|
+
await fs_1.promises.writeFile(path.join(outputPath, 'ngsw.json'), manifest);
|
|
111
109
|
// Find the service worker package
|
|
112
110
|
const workerPath = require.resolve('@angular/service-worker/ngsw-worker.js');
|
|
113
111
|
// Write the worker code
|
|
114
|
-
await fs_1.promises.copyFile(workerPath, path.join(
|
|
112
|
+
await fs_1.promises.copyFile(workerPath, path.join(outputPath, 'ngsw-worker.js'), fs_1.constants.COPYFILE_FICLONE);
|
|
115
113
|
// If present, write the safety worker code
|
|
116
114
|
const safetyPath = path.join(path.dirname(workerPath), 'safety-worker.js');
|
|
117
115
|
try {
|
|
118
|
-
await fs_1.promises.copyFile(safetyPath, path.join(
|
|
119
|
-
await fs_1.promises.copyFile(safetyPath, path.join(
|
|
116
|
+
await fs_1.promises.copyFile(safetyPath, path.join(outputPath, 'worker-basic.min.js'), fs_1.constants.COPYFILE_FICLONE);
|
|
117
|
+
await fs_1.promises.copyFile(safetyPath, path.join(outputPath, 'safety-worker.js'), fs_1.constants.COPYFILE_FICLONE);
|
|
120
118
|
}
|
|
121
119
|
catch (error) {
|
|
122
120
|
if (error.code !== 'ENOENT') {
|
|
@@ -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;
|
|
@@ -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.
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.createIvyPlugin = void 0;
|
|
11
|
-
const core_1 = require("@angular-devkit/core");
|
|
12
11
|
const webpack_1 = require("@ngtools/webpack");
|
|
13
12
|
const typescript_1 = require("typescript");
|
|
14
13
|
function ensureIvy(wco) {
|
|
@@ -44,7 +43,7 @@ function createIvyPlugin(wco, aot, tsconfig) {
|
|
|
44
43
|
const fileReplacements = {};
|
|
45
44
|
if (buildOptions.fileReplacements) {
|
|
46
45
|
for (const replacement of buildOptions.fileReplacements) {
|
|
47
|
-
fileReplacements[
|
|
46
|
+
fileReplacements[replacement.replace] = replacement.with;
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
let inlineStyleFileExtension;
|