@angular/build 21.0.0-next.2 → 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 +14 -14
- package/src/builders/application/index.js +2 -1
- package/src/builders/application/options.d.ts +4 -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/find-tests.d.ts +2 -1
- package/src/builders/karma/find-tests.js +6 -2
- 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 +5 -2
- package/src/builders/unit-test/options.js +12 -6
- 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 +7 -2
- package/src/builders/unit-test/runners/vitest/executor.d.ts +5 -4
- package/src/builders/unit-test/runners/vitest/executor.js +80 -101
- 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 +66 -19
- package/src/tools/esbuild/stylesheets/bundle-options.d.ts +4 -1
- package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.d.ts +4 -1
- package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js +6 -3
- package/src/tools/vite/middlewares/assets-middleware.d.ts +2 -0
- package/src/tools/vite/middlewares/assets-middleware.js +31 -0
- package/src/utils/normalize-cache.js +1 -1
- package/src/utils/postcss-configuration.d.ts +4 -1
- package/src/utils/postcss-configuration.js +2 -2
- package/src/utils/server-rendering/load-esm-from-memory.d.ts +2 -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
- package/src/typings.d.ts +0 -19
|
@@ -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,41 +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
|
-
"
|
|
43
|
-
|
|
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'."
|
|
44
47
|
},
|
|
45
48
|
"watch": {
|
|
46
49
|
"type": "boolean",
|
|
47
|
-
"description": "
|
|
50
|
+
"description": "Enables watch mode, which re-runs tests when source files change. Defaults to `true` in TTY environments and `false` otherwise."
|
|
48
51
|
},
|
|
49
52
|
"debug": {
|
|
50
53
|
"type": "boolean",
|
|
51
|
-
"description": "
|
|
54
|
+
"description": "Enables debugging mode for tests, allowing the use of the Node Inspector.",
|
|
52
55
|
"default": false
|
|
53
56
|
},
|
|
54
57
|
"codeCoverage": {
|
|
55
58
|
"type": "boolean",
|
|
56
|
-
"description": "
|
|
59
|
+
"description": "Enables code coverage reporting for tests.",
|
|
57
60
|
"default": false
|
|
58
61
|
},
|
|
59
62
|
"codeCoverageExclude": {
|
|
60
63
|
"type": "array",
|
|
61
|
-
"description": "
|
|
64
|
+
"description": "Specifies glob patterns of files to exclude from the code coverage report.",
|
|
62
65
|
"items": {
|
|
63
66
|
"type": "string"
|
|
64
|
-
}
|
|
65
|
-
"default": []
|
|
67
|
+
}
|
|
66
68
|
},
|
|
67
69
|
"codeCoverageReporters": {
|
|
68
70
|
"type": "array",
|
|
69
|
-
"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'.",
|
|
70
72
|
"items": {
|
|
71
73
|
"oneOf": [
|
|
72
74
|
{
|
|
@@ -90,14 +92,49 @@
|
|
|
90
92
|
},
|
|
91
93
|
"reporters": {
|
|
92
94
|
"type": "array",
|
|
93
|
-
"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.",
|
|
94
96
|
"items": {
|
|
95
|
-
"
|
|
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
|
+
]
|
|
96
129
|
}
|
|
97
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
|
+
},
|
|
98
135
|
"providersFile": {
|
|
99
136
|
"type": "string",
|
|
100
|
-
"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.",
|
|
101
138
|
"minLength": 1
|
|
102
139
|
},
|
|
103
140
|
"setupFiles": {
|
|
@@ -105,11 +142,17 @@
|
|
|
105
142
|
"items": {
|
|
106
143
|
"type": "string"
|
|
107
144
|
},
|
|
108
|
-
"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."
|
|
109
146
|
},
|
|
110
147
|
"progress": {
|
|
111
148
|
"type": "boolean",
|
|
112
|
-
"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
|
|
113
156
|
}
|
|
114
157
|
},
|
|
115
158
|
"additionalProperties": false,
|
|
@@ -126,6 +169,10 @@
|
|
|
126
169
|
"json",
|
|
127
170
|
"json-summary"
|
|
128
171
|
]
|
|
172
|
+
},
|
|
173
|
+
"reporters-enum": {
|
|
174
|
+
"type": "string",
|
|
175
|
+
"enum": ["default", "verbose", "dots", "json", "junit", "tap", "tap-flat", "html"]
|
|
129
176
|
}
|
|
130
177
|
}
|
|
131
178
|
}
|
|
@@ -29,7 +29,10 @@ export interface BundleStylesheetOptions {
|
|
|
29
29
|
file: string;
|
|
30
30
|
package: string;
|
|
31
31
|
};
|
|
32
|
-
postcssConfiguration?:
|
|
32
|
+
postcssConfiguration?: {
|
|
33
|
+
config: PostcssConfiguration;
|
|
34
|
+
configPath: string;
|
|
35
|
+
};
|
|
33
36
|
publicPath?: string;
|
|
34
37
|
cacheOptions: NormalizedCachedOptions;
|
|
35
38
|
}
|
|
@@ -46,7 +46,10 @@ export interface StylesheetPluginOptions {
|
|
|
46
46
|
* initialized and used for every stylesheet. This overrides the tailwind integration
|
|
47
47
|
* and any tailwind usage must be manually configured in the custom postcss usage.
|
|
48
48
|
*/
|
|
49
|
-
postcssConfiguration?:
|
|
49
|
+
postcssConfiguration?: {
|
|
50
|
+
config: PostcssConfiguration;
|
|
51
|
+
configPath: string;
|
|
52
|
+
};
|
|
50
53
|
/**
|
|
51
54
|
* Optional Options for configuring Sass behavior.
|
|
52
55
|
*/
|
|
@@ -46,6 +46,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
46
46
|
exports.StylesheetPluginFactory = void 0;
|
|
47
47
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
48
48
|
const promises_1 = require("node:fs/promises");
|
|
49
|
+
const node_module_1 = require("node:module");
|
|
49
50
|
const node_path_1 = require("node:path");
|
|
50
51
|
const tinyglobby_1 = require("tinyglobby");
|
|
51
52
|
const error_1 = require("../../../utils/error");
|
|
@@ -143,13 +144,15 @@ class StylesheetPluginFactory {
|
|
|
143
144
|
node_assert_1.default.equal(++this.initPostcssCallCount, 1, '`initPostcss` was called more than once.');
|
|
144
145
|
const { options } = this;
|
|
145
146
|
if (options.postcssConfiguration) {
|
|
146
|
-
const
|
|
147
|
+
const { config, configPath } = options.postcssConfiguration;
|
|
148
|
+
const postCssInstanceKey = JSON.stringify(config);
|
|
147
149
|
let postcssProcessor = postcssProcessors.get(postCssInstanceKey)?.deref();
|
|
148
150
|
if (!postcssProcessor) {
|
|
149
151
|
postcss ??= (await Promise.resolve().then(() => __importStar(require('postcss')))).default;
|
|
150
152
|
postcssProcessor = postcss();
|
|
151
|
-
|
|
152
|
-
|
|
153
|
+
const postCssPluginRequire = (0, node_module_1.createRequire)((0, node_path_1.dirname)(configPath) + '/');
|
|
154
|
+
for (const [pluginName, pluginOptions] of config.plugins) {
|
|
155
|
+
const plugin = postCssPluginRequire(pluginName);
|
|
153
156
|
if (typeof plugin !== 'function' || plugin.postcss !== true) {
|
|
154
157
|
throw new Error(`Attempted to load invalid Postcss plugin: "${pluginName}"`);
|
|
155
158
|
}
|
|
@@ -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
|
+
}
|
|
@@ -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' &&
|
|
@@ -14,4 +14,7 @@ export interface SearchDirectory {
|
|
|
14
14
|
}
|
|
15
15
|
export declare function generateSearchDirectories(roots: string[]): Promise<SearchDirectory[]>;
|
|
16
16
|
export declare function findTailwindConfiguration(searchDirectories: SearchDirectory[]): string | undefined;
|
|
17
|
-
export declare function loadPostcssConfiguration(searchDirectories: SearchDirectory[]): Promise<
|
|
17
|
+
export declare function loadPostcssConfiguration(searchDirectories: SearchDirectory[]): Promise<{
|
|
18
|
+
configPath: string;
|
|
19
|
+
config: PostcssConfiguration;
|
|
20
|
+
} | undefined>;
|
|
@@ -67,7 +67,7 @@ async function loadPostcssConfiguration(searchDirectories) {
|
|
|
67
67
|
config.plugins.push(element);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
return config;
|
|
70
|
+
return { config, configPath };
|
|
71
71
|
}
|
|
72
72
|
// Normalize plugin object map form
|
|
73
73
|
const entries = Object.entries(raw.plugins);
|
|
@@ -81,5 +81,5 @@ async function loadPostcssConfiguration(searchDirectories) {
|
|
|
81
81
|
}
|
|
82
82
|
config.plugins.push([name, options]);
|
|
83
83
|
}
|
|
84
|
-
return config;
|
|
84
|
+
return { config, configPath };
|
|
85
85
|
}
|
|
@@ -6,12 +6,13 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.dev/license
|
|
7
7
|
*/
|
|
8
8
|
import type { ApplicationRef, Type } from '@angular/core';
|
|
9
|
+
import type { BootstrapContext } from '@angular/platform-browser';
|
|
9
10
|
import type { ɵextractRoutesAndCreateRouteTree, ɵgetOrCreateAngularServerApp } from '@angular/ssr';
|
|
10
11
|
/**
|
|
11
12
|
* Represents the exports available from the main server bundle.
|
|
12
13
|
*/
|
|
13
14
|
interface MainServerBundleExports {
|
|
14
|
-
default: (() => Promise<ApplicationRef>) | Type<unknown>;
|
|
15
|
+
default: ((context: BootstrapContext) => Promise<ApplicationRef>) | Type<unknown>;
|
|
15
16
|
ɵextractRoutesAndCreateRouteTree: typeof ɵextractRoutesAndCreateRouteTree;
|
|
16
17
|
ɵgetOrCreateAngularServerApp: typeof ɵgetOrCreateAngularServerApp;
|
|
17
18
|
}
|
|
@@ -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>;
|
|
@@ -0,0 +1,82 @@
|
|
|
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 __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 () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
43
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.writeTestFiles = writeTestFiles;
|
|
47
|
+
const fs = __importStar(require("node:fs/promises"));
|
|
48
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
49
|
+
const bundler_context_1 = require("../tools/esbuild/bundler-context");
|
|
50
|
+
const utils_1 = require("../tools/esbuild/utils");
|
|
51
|
+
/**
|
|
52
|
+
* Writes a collection of build result files to a specified directory.
|
|
53
|
+
* This function handles both in-memory and on-disk files, creating subdirectories
|
|
54
|
+
* as needed.
|
|
55
|
+
*
|
|
56
|
+
* @param files A map of file paths to `ResultFile` objects, representing the build output.
|
|
57
|
+
* @param testDir The absolute path to the directory where the files should be written.
|
|
58
|
+
*/
|
|
59
|
+
async function writeTestFiles(files, testDir) {
|
|
60
|
+
const directoryExists = new Set();
|
|
61
|
+
// Writes the test related output files to disk and ensures the containing directories are present
|
|
62
|
+
await (0, utils_1.emitFilesToDisk)(Object.entries(files), async ([filePath, file]) => {
|
|
63
|
+
if (file.type !== bundler_context_1.BuildOutputFileType.Browser && file.type !== bundler_context_1.BuildOutputFileType.Media) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const fullFilePath = node_path_1.default.join(testDir, filePath);
|
|
67
|
+
// Ensure output subdirectories exist
|
|
68
|
+
const fileBasePath = node_path_1.default.dirname(fullFilePath);
|
|
69
|
+
if (fileBasePath && !directoryExists.has(fileBasePath)) {
|
|
70
|
+
await fs.mkdir(fileBasePath, { recursive: true });
|
|
71
|
+
directoryExists.add(fileBasePath);
|
|
72
|
+
}
|
|
73
|
+
if (file.origin === 'memory') {
|
|
74
|
+
// Write file contents
|
|
75
|
+
await fs.writeFile(fullFilePath, file.contents);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
// Copy file contents
|
|
79
|
+
await fs.copyFile(file.inputPath, fullFilePath, fs.constants.COPYFILE_FICLONE);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
package/.browserslistrc
DELETED
package/src/typings.d.ts
DELETED
|
@@ -1,19 +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
|
-
// The `bundled_beasties` causes issues with module mappings in Bazel,
|
|
10
|
-
// leading to unexpected behavior with esbuild. Specifically, the problem occurs
|
|
11
|
-
// when esbuild resolves to a different module or version than expected, due to
|
|
12
|
-
// how Bazel handles module mappings.
|
|
13
|
-
//
|
|
14
|
-
// This change aims to resolve esbuild types correctly and maintain consistency
|
|
15
|
-
// in the Bazel build process.
|
|
16
|
-
|
|
17
|
-
declare module 'esbuild' {
|
|
18
|
-
export * from 'esbuild-wasm';
|
|
19
|
-
}
|