Skip to content

Commit bc69d62

Browse files
committed
fix(@nguniversal/builders): address method Promise.prototype.then called on incompatible receiver error
Prerendering does not work when using Node.js versions that contain the following commit nodejs/node#43728 due to `loadesm` is now using `SafePromiseAll` which is not handled properly by zone.js.
1 parent 92d2f8e commit bc69d62

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

modules/builders/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ ts_library(
2525
deps = [
2626
"//modules/common/clover/server",
2727
"//modules/common/engine",
28+
"//modules/common/tools",
2829
"@npm//@angular-devkit/architect",
2930
"@npm//@angular-devkit/build-angular",
3031
"@npm//@angular-devkit/core",

modules/builders/src/prerender/worker.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import type { Type } from '@angular/core';
1010
import type * as platformServer from '@angular/platform-server';
11+
import type { ɵInlineCriticalCssProcessor } from '@nguniversal/common/tools';
1112
import assert from 'node:assert';
1213
import * as fs from 'node:fs';
1314
import * as path from 'node:path';
@@ -89,10 +90,6 @@ async function render({
8990
});
9091

9192
if (inlineCriticalCss) {
92-
const { ɵInlineCriticalCssProcessor: InlineCriticalCssProcessor } = await loadEsmModule<
93-
typeof import('@nguniversal/common/tools')
94-
>('@nguniversal/common/tools');
95-
9693
const inlineCriticalCssProcessor = new InlineCriticalCssProcessor({
9794
deployUrl: deployUrl,
9895
minify: minifyCss,
@@ -118,13 +115,20 @@ async function render({
118115
return result;
119116
}
120117

118+
let InlineCriticalCssProcessor: typeof ɵInlineCriticalCssProcessor;
121119
/**
122120
* Initializes the worker when it is first created by loading the Zone.js package
123121
* into the worker instance.
124122
*
125123
* @returns A promise resolving to the render function of the worker.
126124
*/
127125
async function initialize() {
126+
const { ɵInlineCriticalCssProcessor } = await loadEsmModule<
127+
typeof import('@nguniversal/common/tools')
128+
>('@nguniversal/common/tools');
129+
130+
InlineCriticalCssProcessor = ɵInlineCriticalCssProcessor;
131+
128132
// Setup Zone.js
129133
await import(zonePackage);
130134

0 commit comments

Comments
 (0)