Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
fix(@nguniversal/builders): address method Promise.prototype.then cal…
Browse files Browse the repository at this point in the history
…led 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.
  • Loading branch information
alan-agius4 committed Oct 27, 2022
1 parent 92d2f8e commit ac180a1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions modules/builders/src/prerender/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import type { Type } from '@angular/core';
import type * as platformServer from '@angular/platform-server';
import type { ɵInlineCriticalCssProcessor } from '@nguniversal/common/tools';
import assert from 'node:assert';
import * as fs from 'node:fs';
import * as path from 'node:path';
Expand Down Expand Up @@ -89,10 +90,6 @@ async function render({
});

if (inlineCriticalCss) {
const { ɵInlineCriticalCssProcessor: InlineCriticalCssProcessor } = await loadEsmModule<
typeof import('@nguniversal/common/tools')
>('@nguniversal/common/tools');

const inlineCriticalCssProcessor = new InlineCriticalCssProcessor({
deployUrl: deployUrl,
minify: minifyCss,
Expand All @@ -118,13 +115,20 @@ async function render({
return result;
}

let InlineCriticalCssProcessor: typeof ɵInlineCriticalCssProcessor;
/**
* Initializes the worker when it is first created by loading the Zone.js package
* into the worker instance.
*
* @returns A promise resolving to the render function of the worker.
*/
async function initialize() {
const { ɵInlineCriticalCssProcessor } = await loadEsmModule<
typeof import('@nguniversal/common/tools')
>('@nguniversal/common/tools');

InlineCriticalCssProcessor = ɵInlineCriticalCssProcessor;

// Setup Zone.js
await import(zonePackage);

Expand Down

0 comments on commit ac180a1

Please sign in to comment.