Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): Windows Node.js 20 prerendering f…
Browse files Browse the repository at this point in the history
…ailure (#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)
  • Loading branch information
alan-agius4 committed Oct 31, 2023
1 parent 0d54f2d commit 559e891
Showing 1 changed file with 4 additions and 3 deletions.
Expand Up @@ -69,7 +69,10 @@ export function resolve(
}

export async function load(url: string, context: { format?: string | null }, nextLoad: Function) {
if (isFileProtocol(url)) {
const { format } = context;

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

if (source !== undefined) {
const { format } = context;

return {
format,
shortCircuit: true,
Expand Down

0 comments on commit 559e891

Please sign in to comment.