Skip to content

Commit f88ac6f

Browse files
clydindgp1130
authored andcommitted
perf(@angular-devkit/build-angular): skip Angular linker in JIT mode with esbuild
When using the esbuild-based browser application builder in JIT mode, the Angular linker will now be skipped. The runtime Angular compiler present in JIT applications will automatically link any needed code. (cherry picked from commit c06b1bd)
1 parent 54e4acb commit f88ac6f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/angular_devkit/build_angular/src/builders/browser-esbuild/compiler-plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ export function createCompilerPlugin(
399399
// would need to be added to the key as well as a check for any change of content.
400400
let contents = pluginOptions.sourceFileCache?.babelFileCache.get(args.path);
401401
if (contents === undefined) {
402-
contents = await javascriptTransformer.transformFile(args.path);
402+
contents = await javascriptTransformer.transformFile(args.path, pluginOptions.jit);
403403
pluginOptions.sourceFileCache?.babelFileCache.set(args.path, contents);
404404
}
405405

packages/angular_devkit/build_angular/src/builders/browser-esbuild/javascript-transformer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,15 @@ export class JavaScriptTransformer {
5454
* Performs JavaScript transformations on a file from the filesystem.
5555
* If no transformations are required, the data for the original file will be returned.
5656
* @param filename The full path to the file.
57+
* @param skipLinker If true, bypass all Angular linker processing; if false, attempt linking.
5758
* @returns A promise that resolves to a UTF-8 encoded Uint8Array containing the result.
5859
*/
59-
transformFile(filename: string): Promise<Uint8Array> {
60+
transformFile(filename: string, skipLinker?: boolean): Promise<Uint8Array> {
6061
// Always send the request to a worker. Files are almost always from node modules which measn
6162
// they may need linking. The data is also not yet available to perform most transformation checks.
6263
return this.#workerPool.run({
6364
filename,
65+
skipLinker,
6466
...this.#commonOptions,
6567
});
6668
}

0 commit comments

Comments
 (0)