@angular-devkit/build-angular 18.2.0-next.3 → 18.2.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/package.json +18 -18
- package/src/builders/browser-esbuild/index.d.ts +8 -6
- package/src/builders/browser-esbuild/index.js +9 -49
- package/src/builders/dev-server/builder.js +5 -3
- package/src/builders/extract-i18n/application-extraction.js +11 -13
- package/src/builders/jest/index.js +21 -18
- package/src/builders/web-test-runner/index.js +15 -5
- package/src/builders/web-test-runner/write-test-files.d.ts +9 -0
- package/src/builders/web-test-runner/write-test-files.js +41 -0
- package/src/utils/normalize-cache.js +1 -1
- package/src/babel-bazel.d.ts +0 -17
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "18.2.0
|
|
3
|
+
"version": "18.2.0",
|
|
4
4
|
"description": "Angular Webpack Build Facade",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"typings": "src/index.d.ts",
|
|
7
7
|
"builders": "builders.json",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@ampproject/remapping": "2.3.0",
|
|
10
|
-
"@angular-devkit/architect": "0.1802.0
|
|
11
|
-
"@angular-devkit/build-webpack": "0.1802.0
|
|
12
|
-
"@angular-devkit/core": "18.2.0
|
|
13
|
-
"@angular/build": "18.2.0
|
|
10
|
+
"@angular-devkit/architect": "0.1802.0",
|
|
11
|
+
"@angular-devkit/build-webpack": "0.1802.0",
|
|
12
|
+
"@angular-devkit/core": "18.2.0",
|
|
13
|
+
"@angular/build": "18.2.0",
|
|
14
14
|
"@babel/core": "7.25.2",
|
|
15
15
|
"@babel/generator": "7.25.0",
|
|
16
16
|
"@babel/helper-annotate-as-pure": "7.24.7",
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
"@babel/plugin-transform-async-generator-functions": "7.25.0",
|
|
19
19
|
"@babel/plugin-transform-async-to-generator": "7.24.7",
|
|
20
20
|
"@babel/plugin-transform-runtime": "7.24.7",
|
|
21
|
-
"@babel/preset-env": "7.25.
|
|
21
|
+
"@babel/preset-env": "7.25.3",
|
|
22
22
|
"@babel/runtime": "7.25.0",
|
|
23
|
-
"@discoveryjs/json-ext": "0.6.
|
|
24
|
-
"@ngtools/webpack": "18.2.0
|
|
23
|
+
"@discoveryjs/json-ext": "0.6.1",
|
|
24
|
+
"@ngtools/webpack": "18.2.0",
|
|
25
25
|
"@vitejs/plugin-basic-ssl": "1.1.0",
|
|
26
26
|
"ansi-colors": "4.1.3",
|
|
27
|
-
"autoprefixer": "10.4.
|
|
27
|
+
"autoprefixer": "10.4.20",
|
|
28
28
|
"babel-loader": "9.1.3",
|
|
29
29
|
"browserslist": "^4.21.5",
|
|
30
30
|
"copy-webpack-plugin": "12.0.2",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"parse5-html-rewriting-stream": "7.0.0",
|
|
50
50
|
"picomatch": "4.0.2",
|
|
51
51
|
"piscina": "4.6.1",
|
|
52
|
-
"postcss": "8.4.
|
|
52
|
+
"postcss": "8.4.41",
|
|
53
53
|
"postcss-loader": "8.1.1",
|
|
54
54
|
"resolve-url-loader": "5.0.0",
|
|
55
55
|
"rxjs": "7.8.1",
|
|
@@ -58,10 +58,10 @@
|
|
|
58
58
|
"semver": "7.6.3",
|
|
59
59
|
"source-map-loader": "5.0.0",
|
|
60
60
|
"source-map-support": "0.5.21",
|
|
61
|
-
"terser": "5.31.
|
|
61
|
+
"terser": "5.31.6",
|
|
62
62
|
"tree-kill": "1.2.2",
|
|
63
63
|
"tslib": "2.6.3",
|
|
64
|
-
"vite": "5.
|
|
64
|
+
"vite": "5.4.0",
|
|
65
65
|
"watchpack": "2.4.1",
|
|
66
66
|
"webpack": "5.93.0",
|
|
67
67
|
"webpack-dev-middleware": "7.3.0",
|
|
@@ -73,16 +73,16 @@
|
|
|
73
73
|
"esbuild": "0.23.0"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"@angular/compiler-cli": "^18.0.0
|
|
77
|
-
"@angular/localize": "^18.0.0
|
|
78
|
-
"@angular/platform-server": "^18.0.0
|
|
79
|
-
"@angular/service-worker": "^18.0.0
|
|
76
|
+
"@angular/compiler-cli": "^18.0.0",
|
|
77
|
+
"@angular/localize": "^18.0.0",
|
|
78
|
+
"@angular/platform-server": "^18.0.0",
|
|
79
|
+
"@angular/service-worker": "^18.0.0",
|
|
80
80
|
"@web/test-runner": "^0.18.0",
|
|
81
81
|
"browser-sync": "^3.0.2",
|
|
82
82
|
"jest": "^29.5.0",
|
|
83
83
|
"jest-environment-jsdom": "^29.5.0",
|
|
84
84
|
"karma": "^6.3.0",
|
|
85
|
-
"ng-packagr": "^18.0.0
|
|
85
|
+
"ng-packagr": "^18.0.0",
|
|
86
86
|
"protractor": "^7.0.0",
|
|
87
87
|
"tailwindcss": "^2.0.0 || ^3.0.0",
|
|
88
88
|
"typescript": ">=5.4 <5.6"
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"devkit",
|
|
130
130
|
"sdk"
|
|
131
131
|
],
|
|
132
|
-
"packageManager": "yarn@4.
|
|
132
|
+
"packageManager": "yarn@4.4.0",
|
|
133
133
|
"repository": {
|
|
134
134
|
"type": "git",
|
|
135
135
|
"url": "https://github.com/angular/angular-cli.git"
|
|
@@ -5,10 +5,12 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.dev/license
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
9
|
-
import { BuilderContext } from '@angular-devkit/architect';
|
|
8
|
+
import { type ApplicationBuilderOptions } from '@angular/build';
|
|
9
|
+
import { BuilderContext, BuilderOutput } from '@angular-devkit/architect';
|
|
10
10
|
import type { Plugin } from 'esbuild';
|
|
11
11
|
import type { Schema as BrowserBuilderOptions } from './schema';
|
|
12
|
+
export type { BrowserBuilderOptions };
|
|
13
|
+
type OutputPathClass = Exclude<ApplicationBuilderOptions['outputPath'], string | undefined>;
|
|
12
14
|
/**
|
|
13
15
|
* Main execution function for the esbuild-based application builder.
|
|
14
16
|
* The options are compatible with the Webpack-based builder.
|
|
@@ -18,9 +20,9 @@ import type { Schema as BrowserBuilderOptions } from './schema';
|
|
|
18
20
|
*/
|
|
19
21
|
export declare function buildEsbuildBrowser(userOptions: BrowserBuilderOptions, context: BuilderContext, infrastructureSettings?: {
|
|
20
22
|
write?: boolean;
|
|
21
|
-
}, plugins?: Plugin[]): AsyncIterable<
|
|
22
|
-
export declare function
|
|
23
|
-
|
|
24
|
-
}
|
|
23
|
+
}, plugins?: Plugin[]): AsyncIterable<BuilderOutput>;
|
|
24
|
+
export declare function convertBrowserOptions(options: BrowserBuilderOptions): Omit<ApplicationBuilderOptions, 'outputPath'> & {
|
|
25
|
+
outputPath: OutputPathClass;
|
|
26
|
+
};
|
|
25
27
|
declare const _default: import("../../../../architect/src/internal").Builder<BrowserBuilderOptions & import("../../../../core/src").JsonObject>;
|
|
26
28
|
export default _default;
|
|
@@ -6,16 +6,11 @@
|
|
|
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.dev/license
|
|
8
8
|
*/
|
|
9
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
-
};
|
|
12
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
10
|
exports.buildEsbuildBrowser = buildEsbuildBrowser;
|
|
14
|
-
exports.
|
|
15
|
-
const
|
|
11
|
+
exports.convertBrowserOptions = convertBrowserOptions;
|
|
12
|
+
const build_1 = require("@angular/build");
|
|
16
13
|
const architect_1 = require("@angular-devkit/architect");
|
|
17
|
-
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
18
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
19
14
|
const builder_status_warnings_1 = require("./builder-status-warnings");
|
|
20
15
|
/**
|
|
21
16
|
* Main execution function for the esbuild-based application builder.
|
|
@@ -27,43 +22,11 @@ const builder_status_warnings_1 = require("./builder-status-warnings");
|
|
|
27
22
|
async function* buildEsbuildBrowser(userOptions, context, infrastructureSettings, plugins) {
|
|
28
23
|
// Inform user of status of builder and options
|
|
29
24
|
(0, builder_status_warnings_1.logBuilderStatusWarnings)(userOptions, context);
|
|
30
|
-
const normalizedOptions =
|
|
31
|
-
|
|
32
|
-
const fullOutputPath = node_path_1.default.join(context.workspaceRoot, outputPath.base);
|
|
33
|
-
if (deleteOutputPath && infrastructureSettings?.write !== false) {
|
|
34
|
-
await (0, private_1.deleteOutputDir)(context.workspaceRoot, outputPath.base);
|
|
35
|
-
}
|
|
36
|
-
for await (const result of (0, private_1.buildApplicationInternal)(normalizedOptions, context, {
|
|
37
|
-
write: false,
|
|
38
|
-
}, plugins && { codePlugins: plugins })) {
|
|
39
|
-
// Write the file directly from this builder to maintain webpack output compatibility
|
|
40
|
-
// and not output browser files into '/browser'.
|
|
41
|
-
if (infrastructureSettings?.write !== false &&
|
|
42
|
-
(result.kind === private_1.ResultKind.Full || result.kind === private_1.ResultKind.Incremental)) {
|
|
43
|
-
const directoryExists = new Set();
|
|
44
|
-
// Writes the output file to disk and ensures the containing directories are present
|
|
45
|
-
await (0, private_1.emitFilesToDisk)(Object.entries(result.files), async ([filePath, file]) => {
|
|
46
|
-
// Ensure output subdirectories exist
|
|
47
|
-
const basePath = node_path_1.default.dirname(filePath);
|
|
48
|
-
if (basePath && !directoryExists.has(basePath)) {
|
|
49
|
-
await promises_1.default.mkdir(node_path_1.default.join(fullOutputPath, basePath), { recursive: true });
|
|
50
|
-
directoryExists.add(basePath);
|
|
51
|
-
}
|
|
52
|
-
if (file.origin === 'memory') {
|
|
53
|
-
// Write file contents
|
|
54
|
-
await promises_1.default.writeFile(node_path_1.default.join(fullOutputPath, filePath), file.contents);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
// Copy file contents
|
|
58
|
-
await promises_1.default.copyFile(file.inputPath, node_path_1.default.join(fullOutputPath, filePath), promises_1.default.constants.COPYFILE_FICLONE);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
yield result;
|
|
63
|
-
}
|
|
25
|
+
const normalizedOptions = convertBrowserOptions(userOptions);
|
|
26
|
+
yield* (0, build_1.buildApplication)(normalizedOptions, context, { codePlugins: plugins });
|
|
64
27
|
}
|
|
65
|
-
function
|
|
66
|
-
const { main: browser, outputPath, ngswConfigPath, serviceWorker, polyfills, ...otherOptions } = options;
|
|
28
|
+
function convertBrowserOptions(options) {
|
|
29
|
+
const { main: browser, outputPath, ngswConfigPath, serviceWorker, polyfills, resourcesOutputPath, ...otherOptions } = options;
|
|
67
30
|
return {
|
|
68
31
|
browser,
|
|
69
32
|
serviceWorker: serviceWorker ? ngswConfigPath : false,
|
|
@@ -71,13 +34,10 @@ function normalizeOptions(options) {
|
|
|
71
34
|
outputPath: {
|
|
72
35
|
base: outputPath,
|
|
73
36
|
browser: '',
|
|
37
|
+
server: '',
|
|
38
|
+
media: resourcesOutputPath ?? 'media',
|
|
74
39
|
},
|
|
75
40
|
...otherOptions,
|
|
76
41
|
};
|
|
77
42
|
}
|
|
78
|
-
|
|
79
|
-
for await (const result of buildEsbuildBrowser(options, context)) {
|
|
80
|
-
yield { success: result.kind !== private_1.ResultKind.Failure };
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.default = (0, architect_1.createBuilder)(buildEsbuildBrowserArchitect);
|
|
43
|
+
exports.default = (0, architect_1.createBuilder)(buildEsbuildBrowser);
|
|
@@ -72,11 +72,13 @@ function execute(options, context, transforms = {}, extensions) {
|
|
|
72
72
|
if (options.disableHostCheck) {
|
|
73
73
|
context.logger.warn(`The "disableHostCheck" option will not be used because it is not supported by the "${builderName}" builder.`);
|
|
74
74
|
}
|
|
75
|
-
return (0, rxjs_1.defer)(() => Promise.all([Promise.resolve().then(() => __importStar(require('@angular/build/private'))), Promise.resolve().then(() => __importStar(require('../browser-esbuild')))])).pipe((0, rxjs_1.switchMap)(([{ serveWithVite, buildApplicationInternal }, {
|
|
75
|
+
return (0, rxjs_1.defer)(() => Promise.all([Promise.resolve().then(() => __importStar(require('@angular/build/private'))), Promise.resolve().then(() => __importStar(require('../browser-esbuild')))])).pipe((0, rxjs_1.switchMap)(([{ serveWithVite, buildApplicationInternal }, { convertBrowserOptions }]) => serveWithVite(normalizedOptions, builderName, (options, context, codePlugins) => {
|
|
76
76
|
return builderName === '@angular-devkit/build-angular:browser-esbuild'
|
|
77
77
|
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
buildApplicationInternal(convertBrowserOptions(options), context, {
|
|
79
|
+
codePlugins,
|
|
80
|
+
})
|
|
81
|
+
: buildApplicationInternal(options, context, { codePlugins });
|
|
80
82
|
}, context, transforms, extensions)));
|
|
81
83
|
}
|
|
82
84
|
// Warn if the initial options provided by the user enable prebundling with Webpack-based builders
|
|
@@ -17,25 +17,23 @@ const browser_esbuild_1 = require("../browser-esbuild");
|
|
|
17
17
|
async function extractMessages(options, builderName, context, extractorConstructor) {
|
|
18
18
|
const messages = [];
|
|
19
19
|
// Setup the build options for the application based on the buildTarget option
|
|
20
|
-
|
|
20
|
+
let buildOptions;
|
|
21
|
+
if (builderName === '@angular-devkit/build-angular:application') {
|
|
22
|
+
buildOptions = (await context.validateOptions(await context.getTargetOptions(options.buildTarget), builderName));
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
buildOptions = (0, browser_esbuild_1.convertBrowserOptions)((await context.validateOptions(await context.getTargetOptions(options.buildTarget), builderName)));
|
|
26
|
+
}
|
|
21
27
|
buildOptions.optimization = false;
|
|
22
28
|
buildOptions.sourceMap = { scripts: true, vendor: true, styles: false };
|
|
23
29
|
buildOptions.localize = false;
|
|
24
30
|
buildOptions.budgets = undefined;
|
|
25
31
|
buildOptions.index = false;
|
|
26
32
|
buildOptions.serviceWorker = false;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
buildOptions.appShell = false;
|
|
32
|
-
buildOptions.prerender = false;
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
build = browser_esbuild_1.buildEsbuildBrowser;
|
|
36
|
-
}
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
-
const builderResult = await first(build(buildOptions, context, { write: false }));
|
|
33
|
+
buildOptions.ssr = false;
|
|
34
|
+
buildOptions.appShell = false;
|
|
35
|
+
buildOptions.prerender = false;
|
|
36
|
+
const builderResult = await first((0, private_1.buildApplicationInternal)(buildOptions, context));
|
|
39
37
|
let success = false;
|
|
40
38
|
if (!builderResult || builderResult.kind === private_1.ResultKind.Failure) {
|
|
41
39
|
context.logger.error('Application build failed.');
|
|
@@ -33,19 +33,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
33
33
|
const private_1 = require("@angular/build/private");
|
|
34
34
|
const architect_1 = require("@angular-devkit/architect");
|
|
35
35
|
const node_child_process_1 = require("node:child_process");
|
|
36
|
+
const node_crypto_1 = require("node:crypto");
|
|
36
37
|
const fs = __importStar(require("node:fs/promises"));
|
|
37
38
|
const path = __importStar(require("node:path"));
|
|
38
39
|
const node_util_1 = require("node:util");
|
|
39
40
|
const color_1 = require("../../utils/color");
|
|
40
41
|
const test_files_1 = require("../../utils/test-files");
|
|
41
42
|
const schema_1 = require("../browser-esbuild/schema");
|
|
43
|
+
const write_test_files_1 = require("../web-test-runner/write-test-files");
|
|
42
44
|
const options_1 = require("./options");
|
|
43
45
|
const execFile = (0, node_util_1.promisify)(node_child_process_1.execFile);
|
|
44
46
|
/** Main execution function for the Jest builder. */
|
|
45
47
|
exports.default = (0, architect_1.createBuilder)(async (schema, context) => {
|
|
46
48
|
context.logger.warn('NOTE: The Jest builder is currently EXPERIMENTAL and not ready for production use.');
|
|
47
49
|
const options = (0, options_1.normalizeOptions)(schema);
|
|
48
|
-
const testOut = 'dist/test-out'; // TODO(dgp1130): Hide in temp directory.
|
|
50
|
+
const testOut = path.join(context.workspaceRoot, 'dist/test-out', (0, node_crypto_1.randomUUID)()); // TODO(dgp1130): Hide in temp directory.
|
|
49
51
|
// Verify Jest installation and get the path to it's binary.
|
|
50
52
|
// We need to `node_modules/.bin/jest`, but there is no means to resolve that directly. Fortunately Jest's `package.json` exports the
|
|
51
53
|
// same file at `bin/jest`, so we can just resolve that instead.
|
|
@@ -83,7 +85,7 @@ exports.default = (0, architect_1.createBuilder)(async (schema, context) => {
|
|
|
83
85
|
// Build all the test files.
|
|
84
86
|
const jestGlobal = path.join(__dirname, 'jest-global.mjs');
|
|
85
87
|
const initTestBed = path.join(__dirname, 'init-test-bed.mjs');
|
|
86
|
-
const buildResult = await
|
|
88
|
+
const buildResult = await first((0, private_1.buildApplicationInternal)({
|
|
87
89
|
// Build all the test files and also the `jest-global` and `init-test-bed` scripts.
|
|
88
90
|
entryPoints: new Set([...testFiles, jestGlobal, initTestBed]),
|
|
89
91
|
tsConfig: options.tsConfig,
|
|
@@ -99,15 +101,23 @@ exports.default = (0, architect_1.createBuilder)(async (schema, context) => {
|
|
|
99
101
|
styles: false,
|
|
100
102
|
vendor: false,
|
|
101
103
|
},
|
|
102
|
-
});
|
|
103
|
-
if (
|
|
104
|
-
return
|
|
104
|
+
}, context));
|
|
105
|
+
if (buildResult.kind === private_1.ResultKind.Failure) {
|
|
106
|
+
return { success: false };
|
|
107
|
+
}
|
|
108
|
+
else if (buildResult.kind !== private_1.ResultKind.Full) {
|
|
109
|
+
return {
|
|
110
|
+
success: false,
|
|
111
|
+
error: 'A full build result is required from the application builder.',
|
|
112
|
+
};
|
|
105
113
|
}
|
|
114
|
+
// Write test files
|
|
115
|
+
await (0, write_test_files_1.writeTestFiles)(buildResult.files, testOut);
|
|
106
116
|
// Execute Jest on the built output directory.
|
|
107
117
|
const jestProc = execFile(process.execPath, [
|
|
108
118
|
'--experimental-vm-modules',
|
|
109
119
|
jest,
|
|
110
|
-
`--rootDir="${
|
|
120
|
+
`--rootDir="${testOut}"`,
|
|
111
121
|
`--config=${path.join(__dirname, 'jest.config.mjs')}`,
|
|
112
122
|
'--testEnvironment=jsdom',
|
|
113
123
|
// TODO(dgp1130): Enable cache once we have a mechanism for properly clearing / disabling it.
|
|
@@ -150,19 +160,12 @@ exports.default = (0, architect_1.createBuilder)(async (schema, context) => {
|
|
|
150
160
|
}
|
|
151
161
|
return { success: true };
|
|
152
162
|
});
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
return { success: true };
|
|
159
|
-
}
|
|
160
|
-
catch (err) {
|
|
161
|
-
return {
|
|
162
|
-
success: false,
|
|
163
|
-
error: err.message,
|
|
164
|
-
};
|
|
163
|
+
/** Returns the first item yielded by the given generator and cancels the execution. */
|
|
164
|
+
async function first(generator) {
|
|
165
|
+
for await (const value of generator) {
|
|
166
|
+
return value;
|
|
165
167
|
}
|
|
168
|
+
throw new Error('Expected generator to emit at least once.');
|
|
166
169
|
}
|
|
167
170
|
/** Safely resolves the given Node module string. */
|
|
168
171
|
function resolveModule(module) {
|
|
@@ -12,13 +12,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
const private_1 = require("@angular/build/private");
|
|
14
14
|
const architect_1 = require("@angular-devkit/architect");
|
|
15
|
-
const
|
|
15
|
+
const node_crypto_1 = require("node:crypto");
|
|
16
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
16
17
|
const node_module_1 = require("node:module");
|
|
17
18
|
const node_path_1 = __importDefault(require("node:path"));
|
|
18
19
|
const test_files_1 = require("../../utils/test-files");
|
|
19
20
|
const schema_1 = require("../browser-esbuild/schema");
|
|
20
21
|
const builder_status_warnings_1 = require("./builder-status-warnings");
|
|
21
22
|
const options_1 = require("./options");
|
|
23
|
+
const write_test_files_1 = require("./write-test-files");
|
|
22
24
|
exports.default = (0, architect_1.createBuilder)(async (schema, ctx) => {
|
|
23
25
|
ctx.logger.warn('NOTE: The Web Test Runner builder is currently EXPERIMENTAL and not ready for production use.');
|
|
24
26
|
(0, builder_status_warnings_1.logBuilderStatusWarnings)(schema, ctx);
|
|
@@ -37,21 +39,29 @@ exports.default = (0, architect_1.createBuilder)(async (schema, ctx) => {
|
|
|
37
39
|
};
|
|
38
40
|
}
|
|
39
41
|
const options = (0, options_1.normalizeOptions)(schema);
|
|
40
|
-
const testDir = 'dist/test-out';
|
|
42
|
+
const testDir = node_path_1.default.join(ctx.workspaceRoot, 'dist/test-out', (0, node_crypto_1.randomUUID)());
|
|
41
43
|
// Parallelize startup work.
|
|
42
44
|
const [testFiles] = await Promise.all([
|
|
43
45
|
// Glob for files to test.
|
|
44
46
|
(0, test_files_1.findTestFiles)(options.include, options.exclude, ctx.workspaceRoot),
|
|
45
47
|
// Clean build output path.
|
|
46
|
-
|
|
48
|
+
promises_1.default.rm(testDir, { recursive: true, force: true }),
|
|
47
49
|
]);
|
|
48
50
|
// Build the tests and abort on any build failure.
|
|
49
51
|
const buildOutput = await buildTests(testFiles, testDir, options, ctx);
|
|
50
52
|
if (buildOutput.kind === private_1.ResultKind.Failure) {
|
|
51
53
|
return { success: false };
|
|
52
54
|
}
|
|
55
|
+
else if (buildOutput.kind !== private_1.ResultKind.Full) {
|
|
56
|
+
return {
|
|
57
|
+
success: false,
|
|
58
|
+
error: 'A full build result is required from the application builder.',
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
// Write test files
|
|
62
|
+
await (0, write_test_files_1.writeTestFiles)(buildOutput.files, testDir);
|
|
53
63
|
// Run the built tests.
|
|
54
|
-
return await runTests(wtr,
|
|
64
|
+
return await runTests(wtr, testDir, options);
|
|
55
65
|
});
|
|
56
66
|
/** Build all the given test files and write the result to the given output path. */
|
|
57
67
|
async function buildTests(testFiles, outputPath, options, ctx) {
|
|
@@ -96,7 +106,7 @@ function extractZoneTesting(polyfills) {
|
|
|
96
106
|
/** Run Web Test Runner on the given directory of bundled JavaScript tests. */
|
|
97
107
|
async function runTests(wtr, testDir, options) {
|
|
98
108
|
const testPagePath = node_path_1.default.resolve(__dirname, 'test_page.html');
|
|
99
|
-
const testPage = await
|
|
109
|
+
const testPage = await promises_1.default.readFile(testPagePath, 'utf8');
|
|
100
110
|
const runner = await wtr.startTestRunner({
|
|
101
111
|
config: {
|
|
102
112
|
rootDir: testDir,
|
|
@@ -0,0 +1,9 @@
|
|
|
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.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import { ResultFile } from '@angular/build/private';
|
|
9
|
+
export declare function writeTestFiles(files: Record<string, ResultFile>, testDir: string): Promise<void>;
|
|
@@ -0,0 +1,41 @@
|
|
|
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.dev/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.writeTestFiles = writeTestFiles;
|
|
14
|
+
const build_1 = require("@angular/build");
|
|
15
|
+
const private_1 = require("@angular/build/private");
|
|
16
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
17
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
18
|
+
async function writeTestFiles(files, testDir) {
|
|
19
|
+
const directoryExists = new Set();
|
|
20
|
+
// Writes the test related output files to disk and ensures the containing directories are present
|
|
21
|
+
await (0, private_1.emitFilesToDisk)(Object.entries(files), async ([filePath, file]) => {
|
|
22
|
+
if (file.type !== build_1.BuildOutputFileType.Browser && file.type !== build_1.BuildOutputFileType.Media) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const fullFilePath = node_path_1.default.join(testDir, filePath);
|
|
26
|
+
// Ensure output subdirectories exist
|
|
27
|
+
const fileBasePath = node_path_1.default.dirname(fullFilePath);
|
|
28
|
+
if (fileBasePath && !directoryExists.has(fileBasePath)) {
|
|
29
|
+
await promises_1.default.mkdir(fileBasePath, { recursive: true });
|
|
30
|
+
directoryExists.add(fileBasePath);
|
|
31
|
+
}
|
|
32
|
+
if (file.origin === 'memory') {
|
|
33
|
+
// Write file contents
|
|
34
|
+
await promises_1.default.writeFile(fullFilePath, file.contents);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
// Copy file contents
|
|
38
|
+
await promises_1.default.copyFile(file.inputPath, fullFilePath, promises_1.default.constants.COPYFILE_FICLONE);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.normalizeCacheOptions = normalizeCacheOptions;
|
|
11
11
|
const node_path_1 = require("node:path");
|
|
12
12
|
/** Version placeholder is replaced during the build process with actual package version */
|
|
13
|
-
const VERSION = '18.2.0
|
|
13
|
+
const VERSION = '18.2.0';
|
|
14
14
|
function hasCacheMetadata(value) {
|
|
15
15
|
return (!!value &&
|
|
16
16
|
typeof value === 'object' &&
|
package/src/babel-bazel.d.ts
DELETED
|
@@ -1,17 +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.dev/license
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/* eslint-disable import/no-extraneous-dependencies */
|
|
10
|
-
// Workaround for https://github.com/bazelbuild/rules_nodejs/issues/1033
|
|
11
|
-
// Alternative approach instead of https://github.com/angular/angular/pull/33226
|
|
12
|
-
declare module '@babel/core' {
|
|
13
|
-
export * from '@types/babel__core';
|
|
14
|
-
}
|
|
15
|
-
declare module '@babel/generator' {
|
|
16
|
-
export { default } from '@types/babel__generator';
|
|
17
|
-
}
|