Skip to content

Commit 559e891

Browse files
alan-agius4clydin
andcommitted
fix(@angular-devkit/build-angular): Windows Node.js 20 prerendering failure (#26186)
* fix(@angular-devkit/build-angular): Windows Node.js 20 prerendering failure On Node.js 20 prerendering failed on Windows with `An unhandled exception occurred: No handler function exported` error. This appears to be caused by transforming Piscina CJS bundles using the `JavaScriptTransformer`. interestingly, this does not effect other OS like Linux and Mac. * fixup! fix(@angular-devkit/build-angular): Windows Node.js 20 prerendering failure Co-authored-by: Charles <19598772+clydin@users.noreply.github.com> --------- Co-authored-by: Charles <19598772+clydin@users.noreply.github.com> (cherry picked from commit dbb6329)
1 parent 0d54f2d commit 559e891

File tree

1 file changed

+4
-3
lines changed
  • packages/angular_devkit/build_angular/src/utils/server-rendering/esm-in-memory-loader

1 file changed

+4
-3
lines changed

packages/angular_devkit/build_angular/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ export function resolve(
6969
}
7070

7171
export async function load(url: string, context: { format?: string | null }, nextLoad: Function) {
72-
if (isFileProtocol(url)) {
72+
const { format } = context;
73+
74+
// CommonJs modules require no transformations and are not in memory.
75+
if (format !== 'commonjs' && isFileProtocol(url)) {
7376
const filePath = fileURLToPath(url);
7477
// Remove '/' or drive letter for Windows that was added in the above 'resolve'.
7578
let source = outputFiles[relative('/', filePath)] ?? TRANSFORMED_FILES[filePath];
@@ -81,8 +84,6 @@ export async function load(url: string, context: { format?: string | null }, nex
8184
}
8285

8386
if (source !== undefined) {
84-
const { format } = context;
85-
8687
return {
8788
format,
8889
shortCircuit: true,

0 commit comments

Comments
 (0)