@angular/build 19.0.2 → 19.1.0-next.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 +16 -16
- package/src/builders/application/build-action.js +17 -7
- package/src/builders/application/execute-post-bundle.js +3 -3
- package/src/builders/application/options.js +15 -14
- package/src/builders/dev-server/vite-server.js +22 -26
- package/src/builders/extract-i18n/builder.js +17 -7
- package/src/tools/angular/compilation/angular-compilation.js +17 -7
- package/src/tools/angular/compilation/aot-compilation.js +13 -35
- package/src/tools/angular/compilation/factory.js +17 -7
- package/src/tools/angular/compilation/hmr-candidates.d.ts +22 -0
- package/src/tools/angular/compilation/hmr-candidates.js +238 -0
- package/src/tools/babel/plugins/pure-toplevel-functions.js +17 -7
- package/src/tools/esbuild/angular/compiler-plugin.js +33 -7
- package/src/tools/esbuild/angular/source-file-cache.d.ts +1 -1
- package/src/tools/esbuild/angular/source-file-cache.js +17 -7
- package/src/tools/esbuild/global-scripts.js +19 -8
- package/src/tools/esbuild/javascript-transformer-worker.js +17 -7
- package/src/tools/esbuild/stylesheets/less-language.js +17 -7
- package/src/tools/esbuild/stylesheets/sass-language.js +17 -7
- package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js +17 -7
- package/src/tools/vite/plugins/ssr-transform-plugin.js +11 -15
- package/src/utils/check-port.js +17 -7
- package/src/utils/index-file/augment-index-html.js +14 -4
- package/src/utils/index-file/auto-csp.js +17 -7
- package/src/utils/index-file/inline-fonts.js +17 -7
- package/src/utils/load-proxy-config.js +17 -7
- package/src/utils/load-translations.js +17 -7
- package/src/utils/normalize-asset-patterns.js +17 -7
- package/src/utils/normalize-cache.js +1 -1
- package/src/utils/server-rendering/manifest.d.ts +3 -1
- package/src/utils/server-rendering/manifest.js +22 -10
- package/src/utils/server-rendering/prerender.js +3 -3
- package/src/utils/server-rendering/routes-extractor-worker.js +6 -1
- package/src/utils/service-worker.js +17 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/build",
|
|
3
|
-
"version": "19.0.
|
|
3
|
+
"version": "19.1.0-next.0",
|
|
4
4
|
"description": "Official build system for Angular",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Angular CLI",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
"builders": "builders.json",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@ampproject/remapping": "2.3.0",
|
|
26
|
-
"@angular-devkit/architect": "0.
|
|
26
|
+
"@angular-devkit/architect": "0.1901.0-next.0",
|
|
27
27
|
"@babel/core": "7.26.0",
|
|
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
31
|
"@inquirer/confirm": "5.0.2",
|
|
32
|
-
"@vitejs/plugin-basic-ssl": "1.
|
|
32
|
+
"@vitejs/plugin-basic-ssl": "1.2.0",
|
|
33
33
|
"beasties": "0.1.0",
|
|
34
34
|
"browserslist": "^4.23.0",
|
|
35
35
|
"esbuild": "0.24.0",
|
|
@@ -37,31 +37,31 @@
|
|
|
37
37
|
"https-proxy-agent": "7.0.5",
|
|
38
38
|
"istanbul-lib-instrument": "6.0.3",
|
|
39
39
|
"listr2": "8.2.5",
|
|
40
|
-
"magic-string": "0.30.
|
|
40
|
+
"magic-string": "0.30.14",
|
|
41
41
|
"mrmime": "2.0.0",
|
|
42
42
|
"parse5-html-rewriting-stream": "7.0.0",
|
|
43
43
|
"picomatch": "4.0.2",
|
|
44
|
-
"piscina": "4.
|
|
45
|
-
"rollup": "4.
|
|
46
|
-
"sass": "1.
|
|
44
|
+
"piscina": "4.8.0",
|
|
45
|
+
"rollup": "4.28.0",
|
|
46
|
+
"sass": "1.82.0",
|
|
47
47
|
"semver": "7.6.3",
|
|
48
|
-
"vite": "
|
|
48
|
+
"vite": "6.0.2",
|
|
49
49
|
"watchpack": "2.4.2"
|
|
50
50
|
},
|
|
51
51
|
"optionalDependencies": {
|
|
52
|
-
"lmdb": "3.
|
|
52
|
+
"lmdb": "3.2.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@angular/compiler": "^19.0.0",
|
|
56
|
-
"@angular/compiler-cli": "^19.0.0",
|
|
57
|
-
"@angular/localize": "^19.0.0",
|
|
58
|
-
"@angular/platform-server": "^19.0.0",
|
|
59
|
-
"@angular/service-worker": "^19.0.0",
|
|
60
|
-
"@angular/ssr": "^19.0.
|
|
55
|
+
"@angular/compiler": "^19.0.0 || ^19.1.0-next.0",
|
|
56
|
+
"@angular/compiler-cli": "^19.0.0 || ^19.1.0-next.0",
|
|
57
|
+
"@angular/localize": "^19.0.0 || ^19.1.0-next.0",
|
|
58
|
+
"@angular/platform-server": "^19.0.0 || ^19.1.0-next.0",
|
|
59
|
+
"@angular/service-worker": "^19.0.0 || ^19.1.0-next.0",
|
|
60
|
+
"@angular/ssr": "^19.1.0-next.0",
|
|
61
61
|
"less": "^4.2.0",
|
|
62
62
|
"postcss": "^8.4.0",
|
|
63
63
|
"tailwindcss": "^2.0.0 || ^3.0.0",
|
|
64
|
-
"typescript": ">=5.5 <5.
|
|
64
|
+
"typescript": ">=5.5 <5.8"
|
|
65
65
|
},
|
|
66
66
|
"peerDependenciesMeta": {
|
|
67
67
|
"@angular/localize": {
|
|
@@ -22,13 +22,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
22
22
|
}) : function(o, v) {
|
|
23
23
|
o["default"] = v;
|
|
24
24
|
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || function (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
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
|
+
})();
|
|
32
42
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
43
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
44
|
};
|
|
@@ -37,7 +37,7 @@ async function executePostBundleSteps(options, outputFiles, assetFiles, initialF
|
|
|
37
37
|
const allErrors = [];
|
|
38
38
|
const allWarnings = [];
|
|
39
39
|
const prerenderedRoutes = {};
|
|
40
|
-
const { baseHref = '/', serviceWorker, indexHtmlOptions, optimizationOptions, sourcemapOptions, outputMode, serverEntryPoint, prerenderOptions, appShellOptions, workspaceRoot, partialSSRBuild, } = options;
|
|
40
|
+
const { baseHref = '/', serviceWorker, i18nOptions, indexHtmlOptions, optimizationOptions, sourcemapOptions, outputMode, serverEntryPoint, prerenderOptions, appShellOptions, workspaceRoot, partialSSRBuild, } = options;
|
|
41
41
|
// Index HTML content without CSS inlining to be used for server rendering (AppShell, SSG and SSR).
|
|
42
42
|
// NOTE: Critical CSS inlining is deliberately omitted here, as it will be handled during server rendering.
|
|
43
43
|
// Additionally, when using prerendering or AppShell, the index HTML file may be regenerated.
|
|
@@ -56,7 +56,7 @@ async function executePostBundleSteps(options, outputFiles, assetFiles, initialF
|
|
|
56
56
|
}
|
|
57
57
|
// Create server manifest
|
|
58
58
|
if (serverEntryPoint) {
|
|
59
|
-
const { manifestContent, serverAssetsChunks } = (0, manifest_1.generateAngularServerAppManifest)(additionalHtmlOutputFiles, outputFiles, optimizationOptions.styles.inlineCritical ?? false, undefined, locale);
|
|
59
|
+
const { manifestContent, serverAssetsChunks } = (0, manifest_1.generateAngularServerAppManifest)(additionalHtmlOutputFiles, outputFiles, optimizationOptions.styles.inlineCritical ?? false, undefined, locale, baseHref);
|
|
60
60
|
additionalOutputFiles.push(...serverAssetsChunks, (0, utils_1.createOutputFile)(manifest_1.SERVER_APP_MANIFEST_FILENAME, manifestContent, bundler_context_1.BuildOutputFileType.ServerApplication));
|
|
61
61
|
}
|
|
62
62
|
// Pre-render (SSG) and App-shell
|
|
@@ -95,7 +95,7 @@ async function executePostBundleSteps(options, outputFiles, assetFiles, initialF
|
|
|
95
95
|
// Regenerate the manifest to append route tree. This is only needed if SSR is enabled.
|
|
96
96
|
const manifest = additionalOutputFiles.find((f) => f.path === manifest_1.SERVER_APP_MANIFEST_FILENAME);
|
|
97
97
|
(0, node_assert_1.default)(manifest, `${manifest_1.SERVER_APP_MANIFEST_FILENAME} was not found in output files.`);
|
|
98
|
-
const { manifestContent, serverAssetsChunks } = (0, manifest_1.generateAngularServerAppManifest)(additionalHtmlOutputFiles, outputFiles, optimizationOptions.styles.inlineCritical ?? false, serializableRouteTreeNodeForManifest, locale);
|
|
98
|
+
const { manifestContent, serverAssetsChunks } = (0, manifest_1.generateAngularServerAppManifest)(additionalHtmlOutputFiles, outputFiles, optimizationOptions.styles.inlineCritical ?? false, serializableRouteTreeNodeForManifest, locale, baseHref);
|
|
99
99
|
for (const chunk of serverAssetsChunks) {
|
|
100
100
|
const idx = additionalOutputFiles.findIndex(({ path }) => path === chunk.path);
|
|
101
101
|
if (idx === -1) {
|
|
@@ -194,24 +194,25 @@ async function normalizeOptions(context, projectName, options, extensions) {
|
|
|
194
194
|
let indexOutput;
|
|
195
195
|
// The output file will be created within the configured output path
|
|
196
196
|
if (typeof options.index === 'string') {
|
|
197
|
-
|
|
198
|
-
* If SSR is activated, create a distinct entry file for the `index.html`.
|
|
199
|
-
* This is necessary because numerous server/cloud providers automatically serve the `index.html` as a static file
|
|
200
|
-
* if it exists (handling SSG).
|
|
201
|
-
*
|
|
202
|
-
* For instance, accessing `foo.com/` would lead to `foo.com/index.html` being served instead of hitting the server.
|
|
203
|
-
*
|
|
204
|
-
* This approach can also be applied to service workers, where the `index.csr.html` is served instead of the prerendered `index.html`.
|
|
205
|
-
*/
|
|
206
|
-
const indexBaseName = node_path_1.default.basename(options.index);
|
|
207
|
-
indexOutput =
|
|
208
|
-
(ssrOptions || prerenderOptions) && indexBaseName === 'index.html'
|
|
209
|
-
? exports.INDEX_HTML_CSR
|
|
210
|
-
: indexBaseName;
|
|
197
|
+
indexOutput = options.index;
|
|
211
198
|
}
|
|
212
199
|
else {
|
|
213
200
|
indexOutput = options.index.output || 'index.html';
|
|
214
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* If SSR is activated, create a distinct entry file for the `index.html`.
|
|
204
|
+
* This is necessary because numerous server/cloud providers automatically serve the `index.html` as a static file
|
|
205
|
+
* if it exists (handling SSG).
|
|
206
|
+
*
|
|
207
|
+
* For instance, accessing `foo.com/` would lead to `foo.com/index.html` being served instead of hitting the server.
|
|
208
|
+
*
|
|
209
|
+
* This approach can also be applied to service workers, where the `index.csr.html` is served instead of the prerendered `index.html`.
|
|
210
|
+
*/
|
|
211
|
+
const indexBaseName = node_path_1.default.basename(indexOutput);
|
|
212
|
+
indexOutput =
|
|
213
|
+
(ssrOptions || prerenderOptions) && indexBaseName === 'index.html'
|
|
214
|
+
? exports.INDEX_HTML_CSR
|
|
215
|
+
: indexBaseName;
|
|
215
216
|
indexHtmlOptions = {
|
|
216
217
|
input: node_path_1.default.join(workspaceRoot, typeof options.index === 'string' ? options.index : options.index.input),
|
|
217
218
|
output: indexOutput,
|
|
@@ -22,13 +22,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
22
22
|
}) : function(o, v) {
|
|
23
23
|
o["default"] = v;
|
|
24
24
|
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || function (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
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
|
+
})();
|
|
32
42
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
43
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
44
|
};
|
|
@@ -202,17 +212,10 @@ async function* serveWithVite(serverOptions, builderName, builderAction, context
|
|
|
202
212
|
continue;
|
|
203
213
|
}
|
|
204
214
|
// To avoid disconnecting the array objects from the option, these arrays need to be mutated instead of replaced.
|
|
205
|
-
let requiresServerRestart = false;
|
|
206
215
|
if (result.detail?.['externalMetadata']) {
|
|
207
216
|
const { implicitBrowser, implicitServer, explicit } = result.detail['externalMetadata'];
|
|
208
217
|
const implicitServerFiltered = implicitServer.filter((m) => !(0, node_module_1.isBuiltin)(m) && !isAbsoluteUrl(m));
|
|
209
218
|
const implicitBrowserFiltered = implicitBrowser.filter((m) => !isAbsoluteUrl(m));
|
|
210
|
-
if (browserOptions.ssr && serverOptions.prebundle !== false) {
|
|
211
|
-
const previousImplicitServer = new Set(externalMetadata.implicitServer);
|
|
212
|
-
// Restart the server to force SSR dep re-optimization when a dependency has been added.
|
|
213
|
-
// This is a workaround for: https://github.com/vitejs/vite/issues/14896
|
|
214
|
-
requiresServerRestart = implicitServerFiltered.some((dep) => !previousImplicitServer.has(dep));
|
|
215
|
-
}
|
|
216
219
|
// Empty Arrays to avoid growing unlimited with every re-build.
|
|
217
220
|
externalMetadata.explicitBrowser.length = 0;
|
|
218
221
|
externalMetadata.explicitServer.length = 0;
|
|
@@ -234,14 +237,7 @@ async function* serveWithVite(serverOptions, builderName, builderAction, context
|
|
|
234
237
|
server.config.server.fs.allow = [
|
|
235
238
|
...new Set([...server.config.server.fs.allow, ...assetFiles.values()]),
|
|
236
239
|
];
|
|
237
|
-
|
|
238
|
-
// Restart the server to force SSR dep re-optimization when a dependency has been added.
|
|
239
|
-
// This is a workaround for: https://github.com/vitejs/vite/issues/14896
|
|
240
|
-
await server.restart();
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
await handleUpdate(normalizePath, generatedFiles, server, serverOptions, context.logger, componentStyles);
|
|
244
|
-
}
|
|
240
|
+
await handleUpdate(normalizePath, generatedFiles, server, serverOptions, context.logger, componentStyles);
|
|
245
241
|
}
|
|
246
242
|
else {
|
|
247
243
|
const projectName = context.target?.project;
|
|
@@ -336,6 +332,10 @@ async function handleUpdate(normalizePath, generatedFiles, server, serverOptions
|
|
|
336
332
|
if (!updatedFiles.length) {
|
|
337
333
|
return;
|
|
338
334
|
}
|
|
335
|
+
if (destroyAngularServerAppCalled) {
|
|
336
|
+
// Trigger module evaluation before reload to initiate dependency optimization.
|
|
337
|
+
await server.ssrLoadModule('/main.server.mjs');
|
|
338
|
+
}
|
|
339
339
|
if (serverOptions.hmr) {
|
|
340
340
|
if (updatedFiles.every((f) => f.endsWith('.css'))) {
|
|
341
341
|
let requiresReload = false;
|
|
@@ -516,10 +516,6 @@ async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks,
|
|
|
516
516
|
// the Vite client-side code for browser reloading. These would be available by default but when
|
|
517
517
|
// the `allow` option is explicitly configured, they must be included manually.
|
|
518
518
|
allow: [cacheDir, (0, node_path_1.join)(serverOptions.workspaceRoot, 'node_modules'), ...assets.values()],
|
|
519
|
-
// Temporary disable cached FS checks.
|
|
520
|
-
// This is because we configure `config.base` to a virtual directory which causes `getRealPath` to fail.
|
|
521
|
-
// See: https://github.com/vitejs/vite/blob/b2873ac3936de25ca8784327cb9ef16bd4881805/packages/vite/src/node/fsUtils.ts#L45-L67
|
|
522
|
-
cachedChecks: false,
|
|
523
519
|
},
|
|
524
520
|
// This is needed when `externalDependencies` is used to prevent Vite load errors.
|
|
525
521
|
// NOTE: If Vite adds direct support for externals, this can be removed.
|
|
@@ -22,13 +22,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
22
22
|
}) : function(o, v) {
|
|
23
23
|
o["default"] = v;
|
|
24
24
|
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || function (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
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
|
+
})();
|
|
32
42
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
43
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
44
|
};
|
|
@@ -22,13 +22,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
22
22
|
}) : function(o, v) {
|
|
23
23
|
o["default"] = v;
|
|
24
24
|
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || function (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
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
|
+
})();
|
|
32
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
43
|
exports.AngularCompilation = exports.DiagnosticModes = void 0;
|
|
34
44
|
const load_esm_1 = require("../../../utils/load-esm");
|
|
@@ -19,6 +19,13 @@ const angular_host_1 = require("../angular-host");
|
|
|
19
19
|
const jit_bootstrap_transformer_1 = require("../transformers/jit-bootstrap-transformer");
|
|
20
20
|
const web_worker_transformer_1 = require("../transformers/web-worker-transformer");
|
|
21
21
|
const angular_compilation_1 = require("./angular-compilation");
|
|
22
|
+
const hmr_candidates_1 = require("./hmr-candidates");
|
|
23
|
+
/**
|
|
24
|
+
* The modified files count limit for performing component HMR analysis.
|
|
25
|
+
* Performing content analysis for a large amount of files can result in longer rebuild times
|
|
26
|
+
* than a full rebuild would entail.
|
|
27
|
+
*/
|
|
28
|
+
const HMR_MODIFIED_FILE_LIMIT = 32;
|
|
22
29
|
class AngularCompilationState {
|
|
23
30
|
angularProgram;
|
|
24
31
|
compilerHost;
|
|
@@ -51,9 +58,12 @@ class AotCompilation extends angular_compilation_1.AngularCompilation {
|
|
|
51
58
|
if (compilerOptions.externalRuntimeStyles) {
|
|
52
59
|
hostOptions.externalStylesheets ??= new Map();
|
|
53
60
|
}
|
|
61
|
+
const useHmr = compilerOptions['_enableHmr'] &&
|
|
62
|
+
hostOptions.modifiedFiles &&
|
|
63
|
+
hostOptions.modifiedFiles.size <= HMR_MODIFIED_FILE_LIMIT;
|
|
54
64
|
// Collect stale source files for HMR analysis of inline component resources
|
|
55
65
|
let staleSourceFiles;
|
|
56
|
-
if (
|
|
66
|
+
if (useHmr && hostOptions.modifiedFiles && this.#state) {
|
|
57
67
|
for (const modifiedFile of hostOptions.modifiedFiles) {
|
|
58
68
|
const sourceFile = this.#state.typeScriptProgram.getSourceFile(modifiedFile);
|
|
59
69
|
if (sourceFile) {
|
|
@@ -78,8 +88,8 @@ class AotCompilation extends angular_compilation_1.AngularCompilation {
|
|
|
78
88
|
const typeScriptProgram = typescript_1.default.createEmitAndSemanticDiagnosticsBuilderProgram(angularTypeScriptProgram, host, oldProgram, configurationDiagnostics);
|
|
79
89
|
await (0, profiling_1.profileAsync)('NG_ANALYZE_PROGRAM', () => angularCompiler.analyzeAsync());
|
|
80
90
|
let templateUpdates;
|
|
81
|
-
if (
|
|
82
|
-
const componentNodes = collectHmrCandidates(hostOptions.modifiedFiles, angularProgram, staleSourceFiles);
|
|
91
|
+
if (useHmr && hostOptions.modifiedFiles && this.#state) {
|
|
92
|
+
const componentNodes = (0, hmr_candidates_1.collectHmrCandidates)(hostOptions.modifiedFiles, angularProgram, staleSourceFiles);
|
|
83
93
|
for (const node of componentNodes) {
|
|
84
94
|
if (!typescript_1.default.isClassDeclaration(node)) {
|
|
85
95
|
continue;
|
|
@@ -303,35 +313,3 @@ function findAffectedFiles(builder, { ignoreForDiagnostics }, includeTTC) {
|
|
|
303
313
|
}
|
|
304
314
|
return affectedFiles;
|
|
305
315
|
}
|
|
306
|
-
function collectHmrCandidates(modifiedFiles, { compiler }, staleSourceFiles) {
|
|
307
|
-
const candidates = new Set();
|
|
308
|
-
for (const file of modifiedFiles) {
|
|
309
|
-
const templateFileNodes = compiler.getComponentsWithTemplateFile(file);
|
|
310
|
-
if (templateFileNodes.size) {
|
|
311
|
-
templateFileNodes.forEach((node) => candidates.add(node));
|
|
312
|
-
continue;
|
|
313
|
-
}
|
|
314
|
-
const styleFileNodes = compiler.getComponentsWithStyleFile(file);
|
|
315
|
-
if (styleFileNodes.size) {
|
|
316
|
-
styleFileNodes.forEach((node) => candidates.add(node));
|
|
317
|
-
continue;
|
|
318
|
-
}
|
|
319
|
-
const staleSource = staleSourceFiles?.get(file);
|
|
320
|
-
if (staleSource === undefined) {
|
|
321
|
-
// Unknown file requires a rebuild so clear out the candidates and stop collecting
|
|
322
|
-
candidates.clear();
|
|
323
|
-
break;
|
|
324
|
-
}
|
|
325
|
-
const updatedSource = compiler.getCurrentProgram().getSourceFile(file);
|
|
326
|
-
if (updatedSource === undefined) {
|
|
327
|
-
// No longer existing program file requires a rebuild so clear out the candidates and stop collecting
|
|
328
|
-
candidates.clear();
|
|
329
|
-
break;
|
|
330
|
-
}
|
|
331
|
-
// Compare the stale and updated file for changes
|
|
332
|
-
// TODO: Implement -- for now assume a rebuild is needed
|
|
333
|
-
candidates.clear();
|
|
334
|
-
break;
|
|
335
|
-
}
|
|
336
|
-
return candidates;
|
|
337
|
-
}
|
|
@@ -22,13 +22,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
22
22
|
}) : function(o, v) {
|
|
23
23
|
o["default"] = v;
|
|
24
24
|
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || function (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
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
|
+
})();
|
|
32
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
43
|
exports.createAngularCompilation = createAngularCompilation;
|
|
34
44
|
const environment_options_1 = require("../../../utils/environment-options");
|
|
@@ -0,0 +1,22 @@
|
|
|
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 type ng from '@angular/compiler-cli';
|
|
9
|
+
import ts from 'typescript';
|
|
10
|
+
/**
|
|
11
|
+
* Analyzes one or more modified files for changes to determine if any
|
|
12
|
+
* class declarations for Angular components are candidates for hot
|
|
13
|
+
* module replacement (HMR). If any source files are also modified but
|
|
14
|
+
* are not candidates then all candidates become invalid. This invalidation
|
|
15
|
+
* ensures that a full rebuild occurs and the running application stays
|
|
16
|
+
* synchronized with the code.
|
|
17
|
+
* @param modifiedFiles A set of modified files to analyze.
|
|
18
|
+
* @param param1 An Angular compiler instance
|
|
19
|
+
* @param staleSourceFiles A map of paths to previous source file instances.
|
|
20
|
+
* @returns A set of HMR candidate component class declarations.
|
|
21
|
+
*/
|
|
22
|
+
export declare function collectHmrCandidates(modifiedFiles: Set<string>, { compiler }: ng.NgtscProgram, staleSourceFiles: Map<string, ts.SourceFile> | undefined): Set<ts.ClassDeclaration>;
|