@angular/build 21.0.0-next.3 → 21.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 +8 -8
- package/src/builders/application/index.js +2 -1
- package/src/builders/karma/application_builder.d.ts +0 -2
- package/src/builders/karma/application_builder.js +39 -351
- package/src/builders/karma/assets-middleware.d.ts +26 -0
- package/src/builders/karma/assets-middleware.js +65 -0
- package/src/builders/karma/coverage.d.ts +9 -0
- package/src/builders/karma/coverage.js +31 -0
- package/src/builders/karma/karma-config.d.ts +11 -0
- package/src/builders/karma/karma-config.js +79 -0
- package/src/builders/karma/polyfills-plugin.d.ts +13 -0
- package/src/builders/karma/polyfills-plugin.js +74 -0
- package/src/builders/karma/progress-reporter.d.ts +17 -0
- package/src/builders/karma/progress-reporter.js +73 -0
- package/src/builders/karma/utils.d.ts +17 -0
- package/src/builders/karma/utils.js +66 -0
- package/src/builders/unit-test/builder.js +140 -44
- package/src/builders/unit-test/options.d.ts +4 -1
- package/src/builders/unit-test/options.js +11 -5
- package/src/builders/unit-test/runners/api.d.ts +19 -1
- package/src/builders/unit-test/runners/dependency-checker.d.ts +43 -0
- package/src/builders/unit-test/runners/dependency-checker.js +82 -0
- package/src/builders/unit-test/runners/karma/executor.js +26 -2
- package/src/builders/unit-test/runners/karma/index.js +17 -0
- package/src/builders/unit-test/runners/vitest/browser-provider.d.ts +3 -2
- package/src/builders/unit-test/runners/vitest/build-options.js +1 -0
- package/src/builders/unit-test/runners/vitest/executor.d.ts +4 -5
- package/src/builders/unit-test/runners/vitest/executor.js +20 -133
- package/src/builders/unit-test/runners/vitest/index.js +19 -2
- package/src/builders/unit-test/runners/vitest/plugins.d.ts +23 -0
- package/src/builders/unit-test/runners/vitest/plugins.js +131 -0
- package/src/builders/unit-test/schema.d.ts +54 -30
- package/src/builders/unit-test/schema.js +1 -1
- package/src/builders/unit-test/schema.json +65 -16
- package/src/tools/esbuild/application-code-bundle.js +4 -7
- package/src/tools/vite/middlewares/assets-middleware.d.ts +2 -0
- package/src/tools/vite/middlewares/assets-middleware.js +31 -0
- package/src/tools/vite/utils.js +0 -1
- package/src/utils/normalize-cache.js +1 -1
- package/src/utils/supported-browsers.js +7 -3
- package/src/utils/test-files.d.ts +17 -0
- package/src/utils/test-files.js +82 -0
- package/.browserslistrc +0 -7
|
@@ -0,0 +1,131 @@
|
|
|
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.createVitestPlugins = createVitestPlugins;
|
|
14
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
15
|
+
const promises_1 = require("node:fs/promises");
|
|
16
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
17
|
+
const assets_middleware_1 = require("../../../../tools/vite/middlewares/assets-middleware");
|
|
18
|
+
const path_1 = require("../../../../utils/path");
|
|
19
|
+
function createVitestPlugins(options, testSetupFiles, browserOptions, pluginOptions) {
|
|
20
|
+
const { workspaceRoot, projectName, buildResultFiles, testFileToEntryPoint } = pluginOptions;
|
|
21
|
+
return [
|
|
22
|
+
{
|
|
23
|
+
name: 'angular:project-init',
|
|
24
|
+
// Type is incorrect. This allows a Promise<void>.
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
26
|
+
configureVitest: async (context) => {
|
|
27
|
+
// Create a subproject that can be configured with plugins for browser mode.
|
|
28
|
+
// Plugins defined directly in the vite overrides will not be present in the
|
|
29
|
+
// browser specific Vite instance.
|
|
30
|
+
await context.injectTestProjects({
|
|
31
|
+
test: {
|
|
32
|
+
name: projectName,
|
|
33
|
+
root: workspaceRoot,
|
|
34
|
+
globals: true,
|
|
35
|
+
setupFiles: testSetupFiles,
|
|
36
|
+
// Use `jsdom` if no browsers are explicitly configured.
|
|
37
|
+
// `node` is effectively no "environment" and the default.
|
|
38
|
+
environment: browserOptions.browser ? 'node' : 'jsdom',
|
|
39
|
+
browser: browserOptions.browser,
|
|
40
|
+
include: options.include,
|
|
41
|
+
...(options.exclude ? { exclude: options.exclude } : {}),
|
|
42
|
+
},
|
|
43
|
+
plugins: [
|
|
44
|
+
{
|
|
45
|
+
name: 'angular:test-in-memory-provider',
|
|
46
|
+
enforce: 'pre',
|
|
47
|
+
resolveId: (id, importer) => {
|
|
48
|
+
if (importer && (id[0] === '.' || id[0] === '/')) {
|
|
49
|
+
let fullPath;
|
|
50
|
+
if (testFileToEntryPoint.has(importer)) {
|
|
51
|
+
fullPath = (0, path_1.toPosixPath)(node_path_1.default.join(workspaceRoot, id));
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
fullPath = (0, path_1.toPosixPath)(node_path_1.default.join(node_path_1.default.dirname(importer), id));
|
|
55
|
+
}
|
|
56
|
+
const relativePath = node_path_1.default.relative(workspaceRoot, fullPath);
|
|
57
|
+
if (buildResultFiles.has((0, path_1.toPosixPath)(relativePath))) {
|
|
58
|
+
return fullPath;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (testFileToEntryPoint.has(id)) {
|
|
62
|
+
return id;
|
|
63
|
+
}
|
|
64
|
+
(0, node_assert_1.default)(buildResultFiles.size > 0, 'buildResult must be available for resolving.');
|
|
65
|
+
const relativePath = node_path_1.default.relative(workspaceRoot, id);
|
|
66
|
+
if (buildResultFiles.has((0, path_1.toPosixPath)(relativePath))) {
|
|
67
|
+
return id;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
load: async (id) => {
|
|
71
|
+
(0, node_assert_1.default)(buildResultFiles.size > 0, 'buildResult must be available for in-memory loading.');
|
|
72
|
+
// Attempt to load as a source test file.
|
|
73
|
+
const entryPoint = testFileToEntryPoint.get(id);
|
|
74
|
+
let outputPath;
|
|
75
|
+
if (entryPoint) {
|
|
76
|
+
outputPath = entryPoint + '.js';
|
|
77
|
+
// To support coverage exclusion of the actual test file, the virtual
|
|
78
|
+
// test entry point only references the built and bundled intermediate file.
|
|
79
|
+
return {
|
|
80
|
+
code: `import "./${outputPath}";`,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
// Attempt to load as a built artifact.
|
|
85
|
+
const relativePath = node_path_1.default.relative(workspaceRoot, id);
|
|
86
|
+
outputPath = (0, path_1.toPosixPath)(relativePath);
|
|
87
|
+
}
|
|
88
|
+
const outputFile = buildResultFiles.get(outputPath);
|
|
89
|
+
if (outputFile) {
|
|
90
|
+
const sourceMapPath = outputPath + '.map';
|
|
91
|
+
const sourceMapFile = buildResultFiles.get(sourceMapPath);
|
|
92
|
+
const code = outputFile.origin === 'memory'
|
|
93
|
+
? Buffer.from(outputFile.contents).toString('utf-8')
|
|
94
|
+
: await (0, promises_1.readFile)(outputFile.inputPath, 'utf-8');
|
|
95
|
+
const map = sourceMapFile
|
|
96
|
+
? sourceMapFile.origin === 'memory'
|
|
97
|
+
? Buffer.from(sourceMapFile.contents).toString('utf-8')
|
|
98
|
+
: await (0, promises_1.readFile)(sourceMapFile.inputPath, 'utf-8')
|
|
99
|
+
: undefined;
|
|
100
|
+
return {
|
|
101
|
+
code,
|
|
102
|
+
map: map ? JSON.parse(map) : undefined,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
configureServer: (server) => {
|
|
107
|
+
server.middlewares.use((0, assets_middleware_1.createBuildAssetsMiddleware)(server.config.base, buildResultFiles));
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: 'angular:html-index',
|
|
112
|
+
transformIndexHtml: () => {
|
|
113
|
+
// Add all global stylesheets
|
|
114
|
+
if (buildResultFiles.has('styles.css')) {
|
|
115
|
+
return [
|
|
116
|
+
{
|
|
117
|
+
tag: 'link',
|
|
118
|
+
attrs: { href: 'styles.css', rel: 'stylesheet' },
|
|
119
|
+
injectTo: 'head',
|
|
120
|
+
},
|
|
121
|
+
];
|
|
122
|
+
}
|
|
123
|
+
return [];
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
];
|
|
131
|
+
}
|
|
@@ -3,76 +3,96 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export type Schema = {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* 'ChromeHeadless') will enable headless mode
|
|
6
|
+
* Specifies the browsers to use for test execution. When not specified, tests are run in a
|
|
7
|
+
* Node.js environment using jsdom. For both Vitest and Karma, browser names ending with
|
|
8
|
+
* 'Headless' (e.g., 'ChromeHeadless') will enable headless mode.
|
|
9
9
|
*/
|
|
10
10
|
browsers?: string[];
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
* can also pass
|
|
14
|
-
* `project:target:production,staging`.
|
|
12
|
+
* Specifies the build target to use for the unit test build in the format
|
|
13
|
+
* `project:target[:configuration]`. You can also pass a comma-separated list of
|
|
14
|
+
* configurations. Example: `project:target:production,staging`.
|
|
15
15
|
*/
|
|
16
16
|
buildTarget: string;
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* Enables code coverage reporting for tests.
|
|
19
19
|
*/
|
|
20
20
|
codeCoverage?: boolean;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Specifies glob patterns of files to exclude from the code coverage report.
|
|
23
23
|
*/
|
|
24
24
|
codeCoverageExclude?: string[];
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Specifies the reporters to use for code coverage results. Each reporter can be a string
|
|
27
|
+
* representing its name, or a tuple containing the name and an options object. Built-in
|
|
28
|
+
* reporters include 'html', 'lcov', 'lcovonly', 'text', 'text-summary', 'cobertura',
|
|
29
|
+
* 'json', and 'json-summary'.
|
|
27
30
|
*/
|
|
28
31
|
codeCoverageReporters?: SchemaCodeCoverageReporter[];
|
|
29
32
|
/**
|
|
30
|
-
*
|
|
33
|
+
* Enables debugging mode for tests, allowing the use of the Node Inspector.
|
|
31
34
|
*/
|
|
32
35
|
debug?: boolean;
|
|
33
36
|
/**
|
|
34
|
-
*
|
|
37
|
+
* Dumps build output files to the `.angular/cache` directory for debugging purposes.
|
|
38
|
+
*/
|
|
39
|
+
dumpVirtualFiles?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Specifies glob patterns of files to exclude from testing, relative to the project root.
|
|
35
42
|
*/
|
|
36
43
|
exclude?: string[];
|
|
37
44
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
* Specifies a regular expression pattern to match against test suite and test names. Only
|
|
46
|
+
* tests with a name matching the pattern will be executed. For example, `^App` will run
|
|
47
|
+
* only tests in suites beginning with 'App'.
|
|
48
|
+
*/
|
|
49
|
+
filter?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Specifies glob patterns of files to include for testing, relative to the project root.
|
|
52
|
+
* This option also has special handling for directory paths (includes all `.spec.ts` files
|
|
53
|
+
* within) and file paths (includes the corresponding `.spec` file if one exists).
|
|
44
54
|
*/
|
|
45
55
|
include?: string[];
|
|
46
56
|
/**
|
|
47
|
-
*
|
|
57
|
+
* Specifies a file path for the test report, applying only to the first reporter. To
|
|
58
|
+
* configure output files for multiple reporters, use the tuple format `['reporter-name', {
|
|
59
|
+
* outputFile: '...' }]` within the `reporters` option. When not provided, output is written
|
|
60
|
+
* to the console.
|
|
61
|
+
*/
|
|
62
|
+
outputFile?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Shows build progress information in the console. Defaults to the `progress` setting of
|
|
65
|
+
* the specified `buildTarget`.
|
|
48
66
|
*/
|
|
49
67
|
progress?: boolean;
|
|
50
68
|
/**
|
|
51
|
-
* TypeScript file that
|
|
52
|
-
* The
|
|
69
|
+
* Specifies the path to a TypeScript file that provides an array of Angular providers for
|
|
70
|
+
* the test environment. The file must contain a default export of the provider array.
|
|
53
71
|
*/
|
|
54
72
|
providersFile?: string;
|
|
55
73
|
/**
|
|
56
|
-
*
|
|
74
|
+
* Specifies the reporters to use during test execution. Each reporter can be a string
|
|
75
|
+
* representing its name, or a tuple containing the name and an options object. Built-in
|
|
76
|
+
* reporters include 'default', 'verbose', 'dots', 'json', 'junit', 'tap', 'tap-flat', and
|
|
77
|
+
* 'html'. You can also provide a path to a custom reporter.
|
|
57
78
|
*/
|
|
58
|
-
reporters?:
|
|
79
|
+
reporters?: SchemaReporter[];
|
|
59
80
|
/**
|
|
60
|
-
*
|
|
81
|
+
* Specifies the test runner to use for test execution.
|
|
61
82
|
*/
|
|
62
83
|
runner: Runner;
|
|
63
84
|
/**
|
|
64
|
-
* A list of global setup
|
|
65
|
-
*
|
|
66
|
-
* is also initialized prior to the execution of these files.
|
|
85
|
+
* A list of paths to global setup files that are executed before the test files. The
|
|
86
|
+
* application's polyfills and the Angular TestBed are always initialized before these files.
|
|
67
87
|
*/
|
|
68
88
|
setupFiles?: string[];
|
|
69
89
|
/**
|
|
70
|
-
* The
|
|
90
|
+
* The path to the TypeScript configuration file, relative to the workspace root.
|
|
71
91
|
*/
|
|
72
92
|
tsConfig: string;
|
|
73
93
|
/**
|
|
74
|
-
*
|
|
75
|
-
* otherwise.
|
|
94
|
+
* Enables watch mode, which re-runs tests when source files change. Defaults to `true` in
|
|
95
|
+
* TTY environments and `false` otherwise.
|
|
76
96
|
*/
|
|
77
97
|
watch?: boolean;
|
|
78
98
|
};
|
|
@@ -90,8 +110,12 @@ export declare enum CoverageReporters {
|
|
|
90
110
|
Text = "text",
|
|
91
111
|
TextSummary = "text-summary"
|
|
92
112
|
}
|
|
113
|
+
export type SchemaReporter = ReporterReporter[] | string;
|
|
114
|
+
export type ReporterReporter = {
|
|
115
|
+
[key: string]: any;
|
|
116
|
+
} | string;
|
|
93
117
|
/**
|
|
94
|
-
*
|
|
118
|
+
* Specifies the test runner to use for test execution.
|
|
95
119
|
*/
|
|
96
120
|
export declare enum Runner {
|
|
97
121
|
Karma = "karma",
|
|
@@ -15,7 +15,7 @@ var CoverageReporters;
|
|
|
15
15
|
CoverageReporters["TextSummary"] = "text-summary";
|
|
16
16
|
})(CoverageReporters || (exports.CoverageReporters = CoverageReporters = {}));
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* Specifies the test runner to use for test execution.
|
|
19
19
|
*/
|
|
20
20
|
var Runner;
|
|
21
21
|
(function (Runner) {
|
|
@@ -6,20 +6,20 @@
|
|
|
6
6
|
"properties": {
|
|
7
7
|
"buildTarget": {
|
|
8
8
|
"type": "string",
|
|
9
|
-
"description": "
|
|
9
|
+
"description": "Specifies the build target to use for the unit test build in the format `project:target[:configuration]`. You can also pass a comma-separated list of configurations. Example: `project:target:production,staging`.",
|
|
10
10
|
"pattern": "^[^:\\s]*:[^:\\s]*(:[^\\s]+)?$"
|
|
11
11
|
},
|
|
12
12
|
"tsConfig": {
|
|
13
13
|
"type": "string",
|
|
14
|
-
"description": "The
|
|
14
|
+
"description": "The path to the TypeScript configuration file, relative to the workspace root."
|
|
15
15
|
},
|
|
16
16
|
"runner": {
|
|
17
17
|
"type": "string",
|
|
18
|
-
"description": "
|
|
18
|
+
"description": "Specifies the test runner to use for test execution.",
|
|
19
19
|
"enum": ["karma", "vitest"]
|
|
20
20
|
},
|
|
21
21
|
"browsers": {
|
|
22
|
-
"description": "
|
|
22
|
+
"description": "Specifies the browsers to use for test execution. When not specified, tests are run in a Node.js environment using jsdom. For both Vitest and Karma, browser names ending with 'Headless' (e.g., 'ChromeHeadless') will enable headless mode.",
|
|
23
23
|
"type": "array",
|
|
24
24
|
"items": {
|
|
25
25
|
"type": "string"
|
|
@@ -32,39 +32,43 @@
|
|
|
32
32
|
"type": "string"
|
|
33
33
|
},
|
|
34
34
|
"default": ["**/*.spec.ts"],
|
|
35
|
-
"description": "
|
|
35
|
+
"description": "Specifies glob patterns of files to include for testing, relative to the project root. This option also has special handling for directory paths (includes all `.spec.ts` files within) and file paths (includes the corresponding `.spec` file if one exists)."
|
|
36
36
|
},
|
|
37
37
|
"exclude": {
|
|
38
38
|
"type": "array",
|
|
39
39
|
"items": {
|
|
40
40
|
"type": "string"
|
|
41
41
|
},
|
|
42
|
-
"description": "
|
|
42
|
+
"description": "Specifies glob patterns of files to exclude from testing, relative to the project root."
|
|
43
|
+
},
|
|
44
|
+
"filter": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"description": "Specifies a regular expression pattern to match against test suite and test names. Only tests with a name matching the pattern will be executed. For example, `^App` will run only tests in suites beginning with 'App'."
|
|
43
47
|
},
|
|
44
48
|
"watch": {
|
|
45
49
|
"type": "boolean",
|
|
46
|
-
"description": "
|
|
50
|
+
"description": "Enables watch mode, which re-runs tests when source files change. Defaults to `true` in TTY environments and `false` otherwise."
|
|
47
51
|
},
|
|
48
52
|
"debug": {
|
|
49
53
|
"type": "boolean",
|
|
50
|
-
"description": "
|
|
54
|
+
"description": "Enables debugging mode for tests, allowing the use of the Node Inspector.",
|
|
51
55
|
"default": false
|
|
52
56
|
},
|
|
53
57
|
"codeCoverage": {
|
|
54
58
|
"type": "boolean",
|
|
55
|
-
"description": "
|
|
59
|
+
"description": "Enables code coverage reporting for tests.",
|
|
56
60
|
"default": false
|
|
57
61
|
},
|
|
58
62
|
"codeCoverageExclude": {
|
|
59
63
|
"type": "array",
|
|
60
|
-
"description": "
|
|
64
|
+
"description": "Specifies glob patterns of files to exclude from the code coverage report.",
|
|
61
65
|
"items": {
|
|
62
66
|
"type": "string"
|
|
63
67
|
}
|
|
64
68
|
},
|
|
65
69
|
"codeCoverageReporters": {
|
|
66
70
|
"type": "array",
|
|
67
|
-
"description": "
|
|
71
|
+
"description": "Specifies the reporters to use for code coverage results. Each reporter can be a string representing its name, or a tuple containing the name and an options object. Built-in reporters include 'html', 'lcov', 'lcovonly', 'text', 'text-summary', 'cobertura', 'json', and 'json-summary'.",
|
|
68
72
|
"items": {
|
|
69
73
|
"oneOf": [
|
|
70
74
|
{
|
|
@@ -88,14 +92,49 @@
|
|
|
88
92
|
},
|
|
89
93
|
"reporters": {
|
|
90
94
|
"type": "array",
|
|
91
|
-
"description": "
|
|
95
|
+
"description": "Specifies the reporters to use during test execution. Each reporter can be a string representing its name, or a tuple containing the name and an options object. Built-in reporters include 'default', 'verbose', 'dots', 'json', 'junit', 'tap', 'tap-flat', and 'html'. You can also provide a path to a custom reporter.",
|
|
92
96
|
"items": {
|
|
93
|
-
"
|
|
97
|
+
"oneOf": [
|
|
98
|
+
{
|
|
99
|
+
"anyOf": [
|
|
100
|
+
{
|
|
101
|
+
"$ref": "#/definitions/reporters-enum"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"type": "string"
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"type": "array",
|
|
110
|
+
"minItems": 1,
|
|
111
|
+
"maxItems": 2,
|
|
112
|
+
"items": [
|
|
113
|
+
{
|
|
114
|
+
"anyOf": [
|
|
115
|
+
{
|
|
116
|
+
"$ref": "#/definitions/reporters-enum"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"type": "string"
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"type": "object"
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
]
|
|
94
129
|
}
|
|
95
130
|
},
|
|
131
|
+
"outputFile": {
|
|
132
|
+
"type": "string",
|
|
133
|
+
"description": "Specifies a file path for the test report, applying only to the first reporter. To configure output files for multiple reporters, use the tuple format `['reporter-name', { outputFile: '...' }]` within the `reporters` option. When not provided, output is written to the console."
|
|
134
|
+
},
|
|
96
135
|
"providersFile": {
|
|
97
136
|
"type": "string",
|
|
98
|
-
"description": "TypeScript file that
|
|
137
|
+
"description": "Specifies the path to a TypeScript file that provides an array of Angular providers for the test environment. The file must contain a default export of the provider array.",
|
|
99
138
|
"minLength": 1
|
|
100
139
|
},
|
|
101
140
|
"setupFiles": {
|
|
@@ -103,11 +142,17 @@
|
|
|
103
142
|
"items": {
|
|
104
143
|
"type": "string"
|
|
105
144
|
},
|
|
106
|
-
"description": "A list of global setup
|
|
145
|
+
"description": "A list of paths to global setup files that are executed before the test files. The application's polyfills and the Angular TestBed are always initialized before these files."
|
|
107
146
|
},
|
|
108
147
|
"progress": {
|
|
109
148
|
"type": "boolean",
|
|
110
|
-
"description": "
|
|
149
|
+
"description": "Shows build progress information in the console. Defaults to the `progress` setting of the specified `buildTarget`."
|
|
150
|
+
},
|
|
151
|
+
"dumpVirtualFiles": {
|
|
152
|
+
"type": "boolean",
|
|
153
|
+
"description": "Dumps build output files to the `.angular/cache` directory for debugging purposes.",
|
|
154
|
+
"default": false,
|
|
155
|
+
"visible": false
|
|
111
156
|
}
|
|
112
157
|
},
|
|
113
158
|
"additionalProperties": false,
|
|
@@ -124,6 +169,10 @@
|
|
|
124
169
|
"json",
|
|
125
170
|
"json-summary"
|
|
126
171
|
]
|
|
172
|
+
},
|
|
173
|
+
"reporters-enum": {
|
|
174
|
+
"type": "string",
|
|
175
|
+
"enum": ["default", "verbose", "dots", "json", "junit", "tap", "tap-flat", "html"]
|
|
127
176
|
}
|
|
128
177
|
}
|
|
129
178
|
}
|
|
@@ -418,8 +418,6 @@ function getEsBuildCommonOptions(options) {
|
|
|
418
418
|
packages = 'external';
|
|
419
419
|
}
|
|
420
420
|
}
|
|
421
|
-
const minifySyntax = optimizationOptions.scripts;
|
|
422
|
-
const minifyIdentifiers = minifySyntax && environment_options_1.allowMangle;
|
|
423
421
|
return {
|
|
424
422
|
absWorkingDir: workspaceRoot,
|
|
425
423
|
format: 'esm',
|
|
@@ -431,10 +429,9 @@ function getEsBuildCommonOptions(options) {
|
|
|
431
429
|
metafile: true,
|
|
432
430
|
legalComments: options.extractLicenses ? 'none' : 'eof',
|
|
433
431
|
logLevel: options.verbose && !jsonLogs ? 'debug' : 'silent',
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
minifyWhitespace: minifySyntax,
|
|
432
|
+
minifyIdentifiers: optimizationOptions.scripts && environment_options_1.allowMangle,
|
|
433
|
+
minifySyntax: optimizationOptions.scripts,
|
|
434
|
+
minifyWhitespace: optimizationOptions.scripts,
|
|
438
435
|
pure: ['forwardRef'],
|
|
439
436
|
outdir: workspaceRoot,
|
|
440
437
|
outExtension: outExtension ? { '.js': `.${outExtension}` } : undefined,
|
|
@@ -451,7 +448,7 @@ function getEsBuildCommonOptions(options) {
|
|
|
451
448
|
// Only set to false when script optimizations are enabled. It should not be set to true because
|
|
452
449
|
// Angular turns `ngDevMode` into an object for development debugging purposes when not defined
|
|
453
450
|
// which a constant true value would break.
|
|
454
|
-
...(
|
|
451
|
+
...(optimizationOptions.scripts ? { 'ngDevMode': 'false' } : undefined),
|
|
455
452
|
'ngJitMode': jit ? 'true' : 'false',
|
|
456
453
|
'ngServerMode': 'false',
|
|
457
454
|
'ngHmrMode': options.templateUpdates ? 'true' : 'false',
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.dev/license
|
|
7
7
|
*/
|
|
8
8
|
import type { Connect, ViteDevServer } from 'vite';
|
|
9
|
+
import { ResultFile } from '../../../builders/application/results';
|
|
9
10
|
import { AngularMemoryOutputFiles, AngularOutputAssets } from '../utils';
|
|
10
11
|
export interface ComponentStyleRecord {
|
|
11
12
|
rawContent: Uint8Array;
|
|
@@ -13,3 +14,4 @@ export interface ComponentStyleRecord {
|
|
|
13
14
|
reload?: boolean;
|
|
14
15
|
}
|
|
15
16
|
export declare function createAngularAssetsMiddleware(server: ViteDevServer, assets: AngularOutputAssets, outputFiles: AngularMemoryOutputFiles, componentStyles: Map<string, ComponentStyleRecord>, encapsulateStyle: (style: Uint8Array, componentId: string) => string): Connect.NextHandleFunction;
|
|
17
|
+
export declare function createBuildAssetsMiddleware(basePath: string, buildResultFiles: ReadonlyMap<string, ResultFile>, readHandler?: (path: string) => Buffer): Connect.NextHandleFunction;
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.createAngularAssetsMiddleware = createAngularAssetsMiddleware;
|
|
11
|
+
exports.createBuildAssetsMiddleware = createBuildAssetsMiddleware;
|
|
11
12
|
const mrmime_1 = require("mrmime");
|
|
12
13
|
const node_crypto_1 = require("node:crypto");
|
|
13
14
|
const node_fs_1 = require("node:fs");
|
|
@@ -171,3 +172,33 @@ function checkAndHandleEtag(req, res, etag) {
|
|
|
171
172
|
}
|
|
172
173
|
return false;
|
|
173
174
|
}
|
|
175
|
+
function createBuildAssetsMiddleware(basePath, buildResultFiles, readHandler = node_fs_1.readFileSync) {
|
|
176
|
+
return function buildAssetsMiddleware(req, res, next) {
|
|
177
|
+
if (req.url === undefined || res.writableEnded) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
// Parse the incoming request.
|
|
181
|
+
// The base of the URL is unused but required to parse the URL.
|
|
182
|
+
const pathname = (0, utils_1.pathnameWithoutBasePath)(req.url, basePath);
|
|
183
|
+
const extension = (0, node_path_1.extname)(pathname);
|
|
184
|
+
if (extension && !/\.[mc]?[jt]s(?:\.map)?$/.test(extension)) {
|
|
185
|
+
const outputFile = buildResultFiles.get(pathname.slice(1));
|
|
186
|
+
if (outputFile) {
|
|
187
|
+
const contents = outputFile.origin === 'memory' ? outputFile.contents : readHandler(outputFile.inputPath);
|
|
188
|
+
const etag = `W/${(0, node_crypto_1.createHash)('sha256').update(contents).digest('hex')}`;
|
|
189
|
+
if (checkAndHandleEtag(req, res, etag)) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const mimeType = (0, mrmime_1.lookup)(extension);
|
|
193
|
+
if (mimeType) {
|
|
194
|
+
res.setHeader('Content-Type', mimeType);
|
|
195
|
+
}
|
|
196
|
+
res.setHeader('ETag', etag);
|
|
197
|
+
res.setHeader('Cache-Control', 'no-cache');
|
|
198
|
+
res.end(contents);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
next();
|
|
203
|
+
};
|
|
204
|
+
}
|
package/src/tools/vite/utils.js
CHANGED
|
@@ -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 = '21.0.0-next.
|
|
13
|
+
const VERSION = '21.0.0-next.4';
|
|
14
14
|
function hasCacheMetadata(value) {
|
|
15
15
|
return (!!value &&
|
|
16
16
|
typeof value === 'object' &&
|
|
@@ -12,11 +12,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.getSupportedBrowsers = getSupportedBrowsers;
|
|
14
14
|
const browserslist_1 = __importDefault(require("browserslist"));
|
|
15
|
+
// The below is replaced by bazel `npm_package`.
|
|
16
|
+
const BASELINE_DATE = '2025-08-20';
|
|
15
17
|
function getSupportedBrowsers(projectRoot, logger) {
|
|
16
18
|
// Read the browserslist configuration containing Angular's browser support policy.
|
|
17
|
-
const angularBrowserslist = (0, browserslist_1.default)(
|
|
18
|
-
path: require.resolve('../../.browserslistrc'),
|
|
19
|
-
});
|
|
19
|
+
const angularBrowserslist = (0, browserslist_1.default)(`baseline widely available on ${getBaselineDate()}`);
|
|
20
20
|
// Use Angular's configuration as the default.
|
|
21
21
|
browserslist_1.default.defaults = angularBrowserslist;
|
|
22
22
|
// Get the minimum set of browser versions supported by Angular.
|
|
@@ -50,3 +50,7 @@ function getSupportedBrowsers(projectRoot, logger) {
|
|
|
50
50
|
}
|
|
51
51
|
return Array.from(browsersFromConfigOrDefault);
|
|
52
52
|
}
|
|
53
|
+
function getBaselineDate() {
|
|
54
|
+
// Unlike `npm_package`, `ts_project` which is used to run unit tests does not support substitutions.
|
|
55
|
+
return BASELINE_DATE[0] === 'B' ? '2025-01-01' : BASELINE_DATE;
|
|
56
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 '../builders/application/results';
|
|
9
|
+
/**
|
|
10
|
+
* Writes a collection of build result files to a specified directory.
|
|
11
|
+
* This function handles both in-memory and on-disk files, creating subdirectories
|
|
12
|
+
* as needed.
|
|
13
|
+
*
|
|
14
|
+
* @param files A map of file paths to `ResultFile` objects, representing the build output.
|
|
15
|
+
* @param testDir The absolute path to the directory where the files should be written.
|
|
16
|
+
*/
|
|
17
|
+
export declare function writeTestFiles(files: Record<string, ResultFile>, testDir: string): Promise<void>;
|