@angular/build 19.2.0-next.1 → 19.2.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 +18 -13
- package/src/builders/application/build-action.js +6 -1
- package/src/builders/application/execute-build.js +1 -5
- package/src/builders/application/execute-post-bundle.js +2 -2
- package/src/builders/application/i18n.js +6 -3
- package/src/builders/application/options.d.ts +5 -1
- package/src/builders/application/options.js +9 -1
- package/src/builders/dev-server/schema.d.ts +4 -4
- package/src/builders/dev-server/schema.json +2 -2
- package/src/builders/dev-server/vite-server.js +45 -4
- package/src/builders/karma/application_builder.d.ts +15 -0
- package/src/builders/karma/application_builder.js +490 -0
- package/src/builders/karma/find-tests.d.ts +15 -0
- package/src/builders/karma/find-tests.js +144 -0
- package/src/builders/karma/index.d.ts +23 -0
- package/src/builders/karma/index.js +135 -0
- package/src/builders/karma/polyfills/init_sourcemaps.js +10 -0
- package/src/builders/karma/polyfills/init_test_bed.js +19 -0
- package/src/builders/karma/polyfills/jasmine_global.js +18 -0
- package/src/builders/karma/polyfills/jasmine_global_cleanup.js +14 -0
- package/src/builders/karma/schema.d.ts +248 -0
- package/src/builders/karma/schema.js +15 -0
- package/src/builders/karma/schema.json +347 -0
- package/src/private.d.ts +2 -0
- package/src/private.js +6 -1
- package/src/tools/angular/compilation/hmr-candidates.js +43 -12
- package/src/tools/babel/plugins/add-code-coverage.js +8 -1
- package/src/tools/esbuild/angular/compiler-plugin.js +8 -3
- package/src/tools/esbuild/i18n-inliner.d.ts +9 -0
- package/src/tools/esbuild/i18n-inliner.js +110 -21
- package/src/tools/esbuild/index-html-generator.js +1 -8
- package/src/tools/esbuild/stylesheets/less-language.js +16 -4
- package/src/tools/esbuild/stylesheets/sass-language.js +2 -5
- package/src/tools/esbuild/utils.js +4 -1
- package/src/tools/vite/middlewares/html-fallback-middleware.js +2 -1
- package/src/tools/vite/plugins/angular-memory-plugin.d.ts +1 -1
- package/src/tools/vite/plugins/angular-memory-plugin.js +11 -16
- package/src/utils/error.js +2 -2
- package/src/utils/index-file/auto-csp.js +1 -1
- package/src/utils/index-file/index-html-generator.js +3 -2
- package/src/utils/index-file/inline-critical-css.d.ts +1 -0
- package/src/utils/index-file/inline-critical-css.js +11 -7
- package/src/utils/load-translations.js +3 -3
- package/src/utils/normalize-asset-patterns.js +3 -3
- package/src/utils/normalize-cache.js +1 -1
- package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +1 -2
- package/src/utils/server-rendering/manifest.js +7 -2
- package/src/utils/server-rendering/prerender.js +3 -3
- package/src/utils/server-rendering/render-worker.js +2 -2
- package/src/utils/server-rendering/routes-extractor-worker.js +2 -2
- package/src/utils/service-worker.js +2 -2
- package/src/utils/version.js +2 -2
package/builders.json
CHANGED
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
"schema": "./src/builders/extract-i18n/schema.json",
|
|
16
16
|
"description": "Extract i18n messages from an application."
|
|
17
17
|
},
|
|
18
|
+
"karma": {
|
|
19
|
+
"implementation": "./src/builders/karma",
|
|
20
|
+
"schema": "./src/builders/karma/schema.json",
|
|
21
|
+
"description": "Run Karma unit tests."
|
|
22
|
+
},
|
|
18
23
|
"ng-packagr": {
|
|
19
24
|
"implementation": "./src/builders/ng-packagr/index",
|
|
20
25
|
"schema": "./src/builders/ng-packagr/schema.json",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/build",
|
|
3
|
-
"version": "19.2.0-
|
|
3
|
+
"version": "19.2.0-rc.0",
|
|
4
4
|
"description": "Official build system for Angular",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Angular CLI",
|
|
@@ -23,33 +23,34 @@
|
|
|
23
23
|
"builders": "builders.json",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@ampproject/remapping": "2.3.0",
|
|
26
|
-
"@angular-devkit/architect": "0.1902.0-
|
|
27
|
-
"@babel/core": "7.26.
|
|
26
|
+
"@angular-devkit/architect": "0.1902.0-rc.0",
|
|
27
|
+
"@babel/core": "7.26.9",
|
|
28
28
|
"@babel/helper-annotate-as-pure": "7.25.9",
|
|
29
29
|
"@babel/helper-split-export-declaration": "7.24.7",
|
|
30
30
|
"@babel/plugin-syntax-import-attributes": "7.26.0",
|
|
31
|
-
"@inquirer/confirm": "5.1.
|
|
31
|
+
"@inquirer/confirm": "5.1.6",
|
|
32
32
|
"@vitejs/plugin-basic-ssl": "1.2.0",
|
|
33
33
|
"beasties": "0.2.0",
|
|
34
34
|
"browserslist": "^4.23.0",
|
|
35
|
-
"esbuild": "0.
|
|
35
|
+
"esbuild": "0.25.0",
|
|
36
36
|
"fast-glob": "3.3.3",
|
|
37
37
|
"https-proxy-agent": "7.0.6",
|
|
38
38
|
"istanbul-lib-instrument": "6.0.3",
|
|
39
39
|
"listr2": "8.2.5",
|
|
40
40
|
"magic-string": "0.30.17",
|
|
41
|
-
"mrmime": "2.0.
|
|
41
|
+
"mrmime": "2.0.1",
|
|
42
42
|
"parse5-html-rewriting-stream": "7.0.0",
|
|
43
43
|
"picomatch": "4.0.2",
|
|
44
44
|
"piscina": "4.8.0",
|
|
45
|
-
"rollup": "4.
|
|
46
|
-
"sass": "1.
|
|
47
|
-
"semver": "7.
|
|
48
|
-
"
|
|
45
|
+
"rollup": "4.34.8",
|
|
46
|
+
"sass": "1.85.0",
|
|
47
|
+
"semver": "7.7.1",
|
|
48
|
+
"source-map-support": "0.5.21",
|
|
49
|
+
"vite": "6.1.0",
|
|
49
50
|
"watchpack": "2.4.2"
|
|
50
51
|
},
|
|
51
52
|
"optionalDependencies": {
|
|
52
|
-
"lmdb": "3.2.
|
|
53
|
+
"lmdb": "3.2.6"
|
|
53
54
|
},
|
|
54
55
|
"peerDependencies": {
|
|
55
56
|
"@angular/compiler": "^19.0.0 || ^19.2.0-next.0",
|
|
@@ -57,12 +58,13 @@
|
|
|
57
58
|
"@angular/localize": "^19.0.0 || ^19.2.0-next.0",
|
|
58
59
|
"@angular/platform-server": "^19.0.0 || ^19.2.0-next.0",
|
|
59
60
|
"@angular/service-worker": "^19.0.0 || ^19.2.0-next.0",
|
|
60
|
-
"@angular/ssr": "^19.2.0-
|
|
61
|
+
"@angular/ssr": "^19.2.0-rc.0",
|
|
62
|
+
"karma": "^6.4.0",
|
|
61
63
|
"less": "^4.2.0",
|
|
62
64
|
"ng-packagr": "^19.0.0 || ^19.2.0-next.0",
|
|
63
65
|
"postcss": "^8.4.0",
|
|
64
66
|
"tailwindcss": "^2.0.0 || ^3.0.0 || ^4.0.0",
|
|
65
|
-
"typescript": ">=5.5 <5.
|
|
67
|
+
"typescript": ">=5.5 <5.9"
|
|
66
68
|
},
|
|
67
69
|
"peerDependenciesMeta": {
|
|
68
70
|
"@angular/localize": {
|
|
@@ -77,6 +79,9 @@
|
|
|
77
79
|
"@angular/ssr": {
|
|
78
80
|
"optional": true
|
|
79
81
|
},
|
|
82
|
+
"karma": {
|
|
83
|
+
"optional": true
|
|
84
|
+
},
|
|
80
85
|
"less": {
|
|
81
86
|
"optional": true
|
|
82
87
|
},
|
|
@@ -127,6 +127,9 @@ async function* runEsBuildBuildAction(action, options) {
|
|
|
127
127
|
if (!watcher) {
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
|
+
// Used to force a full result on next rebuild if there were initial errors.
|
|
131
|
+
// This ensures at least one full result is emitted.
|
|
132
|
+
let hasInitialErrors = result.errors.length > 0;
|
|
130
133
|
// Wait for changes and rebuild as needed
|
|
131
134
|
const currentWatchFiles = new Set(result.watchFiles);
|
|
132
135
|
try {
|
|
@@ -164,9 +167,11 @@ async function* runEsBuildBuildAction(action, options) {
|
|
|
164
167
|
if (staleWatchFiles?.size) {
|
|
165
168
|
watcher.remove([...staleWatchFiles]);
|
|
166
169
|
}
|
|
167
|
-
for (const outputResult of emitOutputResults(result, outputOptions, changes, incrementalResults ? rebuildState : undefined)) {
|
|
170
|
+
for (const outputResult of emitOutputResults(result, outputOptions, changes, incrementalResults && !hasInitialErrors ? rebuildState : undefined)) {
|
|
168
171
|
yield outputResult;
|
|
169
172
|
}
|
|
173
|
+
// Clear initial build errors flag if no errors are now present
|
|
174
|
+
hasInitialErrors &&= result.errors.length > 0;
|
|
170
175
|
}
|
|
171
176
|
}
|
|
172
177
|
finally {
|
|
@@ -148,7 +148,6 @@ async function executeBuild(options, context, rebuildState) {
|
|
|
148
148
|
}
|
|
149
149
|
const { metafile, initialFiles, outputFiles } = bundlingResult;
|
|
150
150
|
executionResult.outputFiles.push(...outputFiles);
|
|
151
|
-
const changedFiles = rebuildState && executionResult.findChangedFiles(rebuildState.previousOutputInfo);
|
|
152
151
|
// Analyze files for bundle budget failures if present
|
|
153
152
|
let budgetFailures;
|
|
154
153
|
if (options.budgets) {
|
|
@@ -191,10 +190,6 @@ async function executeBuild(options, context, rebuildState) {
|
|
|
191
190
|
if (serverEntryPoint) {
|
|
192
191
|
executionResult.addOutputFile(manifest_1.SERVER_APP_ENGINE_MANIFEST_FILENAME, (0, manifest_1.generateAngularServerAppEngineManifest)(i18nOptions, baseHref), bundler_context_1.BuildOutputFileType.ServerRoot);
|
|
193
192
|
}
|
|
194
|
-
// Override auto-CSP settings if we are serving through Vite middleware.
|
|
195
|
-
if (context.builder.builderName === 'dev-server' && options.security) {
|
|
196
|
-
options.security.autoCsp = false;
|
|
197
|
-
}
|
|
198
193
|
// Perform i18n translation inlining if enabled
|
|
199
194
|
if (i18nOptions.shouldInline) {
|
|
200
195
|
const result = await (0, i18n_1.inlineI18n)(metafile, options, executionResult, initialFiles);
|
|
@@ -218,6 +213,7 @@ async function executeBuild(options, context, rebuildState) {
|
|
|
218
213
|
executionResult.addOutputFile('stats.json', JSON.stringify(metafile, null, 2), bundler_context_1.BuildOutputFileType.Root);
|
|
219
214
|
}
|
|
220
215
|
if (!jsonLogs) {
|
|
216
|
+
const changedFiles = rebuildState && executionResult.findChangedFiles(rebuildState.previousOutputInfo);
|
|
221
217
|
executionResult.addLog((0, utils_1.logBuildStats)(metafile, outputFiles, initialFiles, budgetFailures, colors, changedFiles, estimatedTransferSizes, !!ssrOptions, verbose));
|
|
222
218
|
}
|
|
223
219
|
return executionResult;
|
|
@@ -38,7 +38,7 @@ async function executePostBundleSteps(metafile, options, outputFiles, assetFiles
|
|
|
38
38
|
const allErrors = [];
|
|
39
39
|
const allWarnings = [];
|
|
40
40
|
const prerenderedRoutes = {};
|
|
41
|
-
const { baseHref = '/', serviceWorker,
|
|
41
|
+
const { baseHref = '/', serviceWorker, ssrOptions, indexHtmlOptions, optimizationOptions, sourcemapOptions, outputMode, serverEntryPoint, prerenderOptions, appShellOptions, publicPath, workspaceRoot, partialSSRBuild, } = options;
|
|
42
42
|
// Index HTML content without CSS inlining to be used for server rendering (AppShell, SSG and SSR).
|
|
43
43
|
// NOTE: Critical CSS inlining is deliberately omitted here, as it will be handled during server rendering.
|
|
44
44
|
// Additionally, when using prerendering or AppShell, the index HTML file may be regenerated.
|
|
@@ -57,7 +57,7 @@ async function executePostBundleSteps(metafile, options, outputFiles, assetFiles
|
|
|
57
57
|
}
|
|
58
58
|
// Create server manifest
|
|
59
59
|
const initialFilesPaths = new Set(initialFiles.keys());
|
|
60
|
-
if (serverEntryPoint) {
|
|
60
|
+
if (serverEntryPoint && (outputMode || prerenderOptions || appShellOptions || ssrOptions)) {
|
|
61
61
|
const { manifestContent, serverAssetsChunks } = (0, manifest_1.generateAngularServerAppManifest)(additionalHtmlOutputFiles, outputFiles, optimizationOptions.styles.inlineCritical ?? false, undefined, locale, baseHref, initialFilesPaths, metafile, publicPath);
|
|
62
62
|
additionalOutputFiles.push(...serverAssetsChunks, (0, utils_1.createOutputFile)(manifest_1.SERVER_APP_MANIFEST_FILENAME, manifestContent, bundler_context_1.BuildOutputFileType.ServerApplication));
|
|
63
63
|
}
|
|
@@ -26,12 +26,13 @@ const options_1 = require("./options");
|
|
|
26
26
|
* @param initialFiles A map containing initial file information for the executed build.
|
|
27
27
|
*/
|
|
28
28
|
async function inlineI18n(metafile, options, executionResult, initialFiles) {
|
|
29
|
-
const { i18nOptions, optimizationOptions, baseHref } = options;
|
|
29
|
+
const { i18nOptions, optimizationOptions, baseHref, cacheOptions } = options;
|
|
30
30
|
// Create the multi-threaded inliner with common options and the files generated from the build.
|
|
31
31
|
const inliner = new i18n_inliner_1.I18nInliner({
|
|
32
32
|
missingTranslation: i18nOptions.missingTranslationBehavior ?? 'warning',
|
|
33
33
|
outputFiles: executionResult.outputFiles,
|
|
34
34
|
shouldOptimize: optimizationOptions.scripts,
|
|
35
|
+
persistentCachePath: cacheOptions.enabled ? cacheOptions.path : undefined,
|
|
35
36
|
}, environment_options_1.maxWorkers);
|
|
36
37
|
const inlineResult = {
|
|
37
38
|
errors: [],
|
|
@@ -41,6 +42,8 @@ async function inlineI18n(metafile, options, executionResult, initialFiles) {
|
|
|
41
42
|
// For each active locale, use the inliner to process the output files of the build.
|
|
42
43
|
const updatedOutputFiles = [];
|
|
43
44
|
const updatedAssetFiles = [];
|
|
45
|
+
// Root and SSR entry files are not modified.
|
|
46
|
+
const unModifiedOutputFiles = executionResult.outputFiles.filter(({ type }) => type === bundler_context_1.BuildOutputFileType.Root || type === bundler_context_1.BuildOutputFileType.ServerRoot);
|
|
44
47
|
try {
|
|
45
48
|
for (const locale of i18nOptions.inlineLocales) {
|
|
46
49
|
// A locale specific set of files is returned from the inliner.
|
|
@@ -51,7 +54,7 @@ async function inlineI18n(metafile, options, executionResult, initialFiles) {
|
|
|
51
54
|
const { errors, warnings, additionalAssets, additionalOutputFiles, prerenderedRoutes: generatedRoutes, } = await (0, execute_post_bundle_1.executePostBundleSteps)(metafile, {
|
|
52
55
|
...options,
|
|
53
56
|
baseHref: (0, options_1.getLocaleBaseHref)(baseHref, i18nOptions, locale) ?? baseHref,
|
|
54
|
-
}, localeOutputFiles, executionResult.assetFiles, initialFiles, locale);
|
|
57
|
+
}, [...unModifiedOutputFiles, ...localeOutputFiles], executionResult.assetFiles, initialFiles, locale);
|
|
55
58
|
localeOutputFiles.push(...additionalOutputFiles);
|
|
56
59
|
inlineResult.errors.push(...errors);
|
|
57
60
|
inlineResult.warnings.push(...warnings);
|
|
@@ -81,7 +84,7 @@ async function inlineI18n(metafile, options, executionResult, initialFiles) {
|
|
|
81
84
|
// Update the result with all localized files.
|
|
82
85
|
executionResult.outputFiles = [
|
|
83
86
|
// Root and SSR entry files are not modified.
|
|
84
|
-
...
|
|
87
|
+
...unModifiedOutputFiles,
|
|
85
88
|
// Updated files for each locale.
|
|
86
89
|
...updatedOutputFiles,
|
|
87
90
|
];
|
|
@@ -196,7 +196,11 @@ export declare function normalizeOptions(context: BuilderContext, projectName: s
|
|
|
196
196
|
partialSSRBuild: boolean;
|
|
197
197
|
externalRuntimeStyles: boolean | undefined;
|
|
198
198
|
instrumentForCoverage: ((filename: string) => boolean) | undefined;
|
|
199
|
-
security:
|
|
199
|
+
security: {
|
|
200
|
+
autoCsp: {
|
|
201
|
+
unsafeEval: boolean;
|
|
202
|
+
} | undefined;
|
|
203
|
+
};
|
|
200
204
|
templateUpdates: boolean;
|
|
201
205
|
incrementalResults: boolean;
|
|
202
206
|
}>;
|
|
@@ -236,8 +236,16 @@ async function normalizeOptions(context, projectName, options, extensions) {
|
|
|
236
236
|
throw new Error('The "index" option cannot be set to false when enabling "ssr", "prerender" or "app-shell".');
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
+
const autoCsp = options.security?.autoCsp;
|
|
240
|
+
const security = {
|
|
241
|
+
autoCsp: autoCsp
|
|
242
|
+
? {
|
|
243
|
+
unsafeEval: autoCsp === true ? false : !!autoCsp.unsafeEval,
|
|
244
|
+
}
|
|
245
|
+
: undefined,
|
|
246
|
+
};
|
|
239
247
|
// Initial options to keep
|
|
240
|
-
const { allowedCommonJsDependencies, aot = true, baseHref, crossOrigin, externalDependencies, extractLicenses, inlineStyleLanguage = 'css', outExtension, serviceWorker, poll, polyfills, statsJson, outputMode, stylePreprocessorOptions, subresourceIntegrity, verbose, watch, progress = true, externalPackages, namedChunks, budgets, deployUrl, clearScreen, define, partialSSRBuild = false, externalRuntimeStyles, instrumentForCoverage,
|
|
248
|
+
const { allowedCommonJsDependencies, aot = true, baseHref, crossOrigin, externalDependencies, extractLicenses, inlineStyleLanguage = 'css', outExtension, serviceWorker, poll, polyfills, statsJson, outputMode, stylePreprocessorOptions, subresourceIntegrity, verbose, watch, progress = true, externalPackages, namedChunks, budgets, deployUrl, clearScreen, define, partialSSRBuild = false, externalRuntimeStyles, instrumentForCoverage, } = options;
|
|
241
249
|
// Return all the normalized options
|
|
242
250
|
return {
|
|
243
251
|
advancedOptimizations: !!aot && optimizationOptions.scripts,
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export type Schema = {
|
|
5
5
|
/**
|
|
6
|
-
* The hosts that
|
|
7
|
-
* same name. For further details:
|
|
6
|
+
* The hosts that the development server will respond to. This option sets the Vite option
|
|
7
|
+
* of the same name. For further details:
|
|
8
8
|
* https://vite.dev/config/server-options.html#server-allowedhosts
|
|
9
9
|
*/
|
|
10
10
|
allowedHosts?: AllowedHosts;
|
|
@@ -86,8 +86,8 @@ export type Schema = {
|
|
|
86
86
|
watch?: boolean;
|
|
87
87
|
};
|
|
88
88
|
/**
|
|
89
|
-
* The hosts that
|
|
90
|
-
* same name. For further details:
|
|
89
|
+
* The hosts that the development server will respond to. This option sets the Vite option
|
|
90
|
+
* of the same name. For further details:
|
|
91
91
|
* https://vite.dev/config/server-options.html#server-allowedhosts
|
|
92
92
|
*/
|
|
93
93
|
export type AllowedHosts = string[] | boolean;
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"description": "SSL certificate to use for serving HTTPS."
|
|
38
38
|
},
|
|
39
39
|
"allowedHosts": {
|
|
40
|
-
"description": "The hosts that
|
|
40
|
+
"description": "The hosts that the development server will respond to. This option sets the Vite option of the same name. For further details: https://vite.dev/config/server-options.html#server-allowedhosts",
|
|
41
41
|
"default": [],
|
|
42
42
|
"oneOf": [
|
|
43
43
|
{
|
|
44
44
|
"type": "array",
|
|
45
|
-
"description": "
|
|
45
|
+
"description": "A list of hosts that the development server will respond to.",
|
|
46
46
|
"items": {
|
|
47
47
|
"type": "string"
|
|
48
48
|
}
|
|
@@ -82,6 +82,10 @@ async function* serveWithVite(serverOptions, builderName, builderAction, context
|
|
|
82
82
|
browserOptions.prerender = undefined;
|
|
83
83
|
browserOptions.ssr ||= true;
|
|
84
84
|
}
|
|
85
|
+
// Disable auto CSP.
|
|
86
|
+
browserOptions.security = {
|
|
87
|
+
autoCsp: false,
|
|
88
|
+
};
|
|
85
89
|
// Set all packages as external to support Vite's prebundle caching
|
|
86
90
|
browserOptions.externalPackages = serverOptions.prebundle;
|
|
87
91
|
// Disable generating a full manifest with routes.
|
|
@@ -161,6 +165,7 @@ async function* serveWithVite(serverOptions, builderName, builderAction, context
|
|
|
161
165
|
},
|
|
162
166
|
});
|
|
163
167
|
}
|
|
168
|
+
yield { baseUrl: '', success: false };
|
|
164
169
|
continue;
|
|
165
170
|
}
|
|
166
171
|
// Clear existing error overlay on successful result
|
|
@@ -321,6 +326,29 @@ async function* serveWithVite(serverOptions, builderName, builderAction, context
|
|
|
321
326
|
break;
|
|
322
327
|
}
|
|
323
328
|
});
|
|
329
|
+
// Setup component HMR invalidation
|
|
330
|
+
// Invalidation occurs when the runtime cannot update a component
|
|
331
|
+
server.hot.on('angular:invalidate', (data) => {
|
|
332
|
+
if (typeof data?.id !== 'string') {
|
|
333
|
+
context.logger.warn('Development server client sent invalid internal invalidate event.');
|
|
334
|
+
}
|
|
335
|
+
// Clear invalid template update
|
|
336
|
+
templateUpdates.delete(data.id);
|
|
337
|
+
// Some cases are expected unsupported update scenarios but some may be errors.
|
|
338
|
+
// If an error occurred, log the error in addition to the invalidation.
|
|
339
|
+
if (data.error) {
|
|
340
|
+
context.logger.error(`Component update failed${data.message ? `: ${data.message}` : '.'}` +
|
|
341
|
+
'\nPlease consider reporting the error at https://github.com/angular/angular-cli/issues');
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
context.logger.warn(`Component update unsupported${data.message ? `: ${data.message}` : '.'}`);
|
|
345
|
+
}
|
|
346
|
+
server?.ws.send({
|
|
347
|
+
type: 'full-reload',
|
|
348
|
+
path: '*',
|
|
349
|
+
});
|
|
350
|
+
context.logger.info('Page reload sent to client(s).');
|
|
351
|
+
});
|
|
324
352
|
const urls = server.resolvedUrls;
|
|
325
353
|
if (urls && (urls.local.length || urls.network.length)) {
|
|
326
354
|
serverUrl = new URL(urls.local[0] ?? urls.network[0]);
|
|
@@ -506,6 +534,7 @@ function updateResultRecord(outputPath, file, normalizePath, htmlIndexPath, gene
|
|
|
506
534
|
}
|
|
507
535
|
}
|
|
508
536
|
}
|
|
537
|
+
// eslint-disable-next-line max-lines-per-function
|
|
509
538
|
async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks, externalMetadata, ssrMode, prebundleTransformer, target, zoneless, componentStyles, templateUpdates, prebundleLoaderExtensions, define, extensionMiddleware, indexHtmlTransformer, thirdPartySourcemaps = false) {
|
|
510
539
|
const proxy = await (0, utils_2.loadProxyConfiguration)(serverOptions.workspaceRoot, serverOptions.proxyConfig);
|
|
511
540
|
// dynamically import Vite for ESM compatibility
|
|
@@ -522,6 +551,14 @@ async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks,
|
|
|
522
551
|
ssrFiles = ['./main.server.mjs', './server.mjs'];
|
|
523
552
|
break;
|
|
524
553
|
}
|
|
554
|
+
/**
|
|
555
|
+
* Required when using `externalDependencies` to prevent Vite load errors.
|
|
556
|
+
*
|
|
557
|
+
* @note Can be removed if Vite introduces native support for externals.
|
|
558
|
+
* @note Vite misresolves browser modules in SSR when accessing URLs with multiple segments
|
|
559
|
+
* (e.g., 'foo/bar'), as they are not correctly re-based from the base href.
|
|
560
|
+
*/
|
|
561
|
+
const preTransformRequests = externalMetadata.explicitBrowser.length === 0 && ssrMode === plugins_1.ServerSsrMode.NoSsr;
|
|
525
562
|
const cacheDir = (0, node_path_1.join)(serverOptions.cacheOptions.path, serverOptions.buildTarget.project, 'vite');
|
|
526
563
|
const configuration = {
|
|
527
564
|
configFile: false,
|
|
@@ -550,7 +587,11 @@ async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks,
|
|
|
550
587
|
mainFields: ['es2020', 'browser', 'module', 'main'],
|
|
551
588
|
preserveSymlinks,
|
|
552
589
|
},
|
|
590
|
+
dev: {
|
|
591
|
+
preTransformRequests,
|
|
592
|
+
},
|
|
553
593
|
server: {
|
|
594
|
+
preTransformRequests,
|
|
554
595
|
warmup: {
|
|
555
596
|
ssrFiles,
|
|
556
597
|
},
|
|
@@ -571,6 +612,9 @@ async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks,
|
|
|
571
612
|
? (proxy ?? {})
|
|
572
613
|
: proxy,
|
|
573
614
|
cors: {
|
|
615
|
+
// This will add the header `Access-Control-Allow-Origin: http://example.com`,
|
|
616
|
+
// where `http://example.com` is the requesting origin.
|
|
617
|
+
origin: true,
|
|
574
618
|
// Allow preflight requests to be proxied.
|
|
575
619
|
preflightContinue: true,
|
|
576
620
|
},
|
|
@@ -587,9 +631,6 @@ async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks,
|
|
|
587
631
|
...[...assets.values()].map(({ source }) => source),
|
|
588
632
|
],
|
|
589
633
|
},
|
|
590
|
-
// This is needed when `externalDependencies` is used to prevent Vite load errors.
|
|
591
|
-
// NOTE: If Vite adds direct support for externals, this can be removed.
|
|
592
|
-
preTransformRequests: externalMetadata.explicitBrowser.length === 0,
|
|
593
634
|
},
|
|
594
635
|
ssr: {
|
|
595
636
|
// Note: `true` and `/.*/` have different sematics. When true, the `external` option is ignored.
|
|
@@ -631,7 +672,7 @@ async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks,
|
|
|
631
672
|
outputFiles,
|
|
632
673
|
templateUpdates,
|
|
633
674
|
external: externalMetadata.explicitBrowser,
|
|
634
|
-
|
|
675
|
+
disableViteTransport: !serverOptions.liveReload,
|
|
635
676
|
}),
|
|
636
677
|
],
|
|
637
678
|
// Browser only optimizeDeps. (This does not run for SSR dependencies).
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
import type { BuilderContext, BuilderOutput } from '@angular-devkit/architect';
|
|
10
|
+
import type { ConfigOptions } from 'karma';
|
|
11
|
+
import { Schema as KarmaBuilderOptions } from './schema';
|
|
12
|
+
export declare function execute(options: KarmaBuilderOptions, context: BuilderContext, karmaOptions: ConfigOptions, transforms?: {
|
|
13
|
+
karmaOptions?: (options: ConfigOptions) => ConfigOptions;
|
|
14
|
+
}): AsyncIterable<BuilderOutput>;
|
|
15
|
+
export declare function writeTestFiles(files: Record<string, ResultFile>, testDir: string): Promise<void>;
|