angular / angular-cli

CLI tool for Angular
https://cli.angular.dev
MIT License
26.78k stars 11.98k forks source link

Getting Cannot read property 'polyfillWrapFlushCallback' of undefined #27282

Closed jz1494 closed 8 months ago

jz1494 commented 8 months ago

Command

build

Is this a regression?

The previous version in which this bug was not present was

No response

Description

Using a Polymer Ui Library whichs uses custom webcomponenets, when i am using this with Angular universal getting below error on build.

Screenshot-296-

Here are the package.json

  "scripts": {
    "ng": "ng",
    "start": "ng serve --proxy-conf proxy.conf.json",
    "start-qa": "ng serve --configuration=local",
    "qa": "ng build --configuration=qa --aot --output-hashing=all",
    "dqa": "firebase use upmerch-qa && firebase deploy --only hosting",
    "test": "ng test",
    "pree2e": "webdriver-manager update --standalone false --gecko false",
    "e2e": "protractor",
    "postinstall": "ngcc"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^11.0.7",
    "@angular/cdk": "^11.0.3",
    "@angular/common": "^11.0.7",
    "@angular/compiler": "^11.0.7",
    "@angular/core": "^11.0.7",
    "@angular/fire": "6.1.4",
    "@angular/forms": "^11.0.7",
    "@angular/localize": "^11.0.7",
    "@angular/material": "^11.0.3",
    "@angular/platform-browser": "^11.0.7",
    "@angular/platform-browser-dynamic": "^11.0.7",
    "@angular/platform-server": "^11.0.7",
    "@angular/router": "^11.0.7",
    "@ckeditor/ckeditor5-angular": "^2.0.1",
    "@ckeditor/ckeditor5-build-classic": "^25.0.0",
    "@codebakery/origami": "^3.2.0",
    "@ng-select/ng-option-highlight": "0.0.6",
    "@ng-select/ng-select": "^6.1.0",
    "@ngx-meta/core": "^9.0.0",
    "@polymer/app-layout": "^3.1.0",
    "@polymer/gold-phone-input": "^3.0.1",
    "@polymer/iron-flex-layout": "^3.0.1",
    "@polymer/iron-icons": "^3.0.1",
    "@polymer/iron-list": "^3.1.0",
    "@polymer/paper-badge": "^3.1.0",
    "@polymer/paper-button": "^3.0.1",
    "@polymer/paper-card": "^3.0.1",
    "@polymer/paper-checkbox": "^3.1.0",
    "@polymer/paper-dialog": "^3.0.1",
    "@polymer/paper-dropdown-menu": "^3.1.0",
    "@polymer/paper-icon-button": "^3.0.2",
    "@polymer/paper-input": "^3.2.1",
    "@polymer/paper-item": "^3.0.1",
    "@polymer/paper-listbox": "^3.0.1",
    "@polymer/paper-progress": "^3.0.1",
    "@polymer/paper-spinner": "^3.0.2",
    "@polymer/paper-styles": "^3.0.1",
    "@polymer/paper-swatch-picker": "^3.0.1",
    "@polymer/paper-tabs": "^3.1.0",
    "@polymer/paper-toast": "^3.0.1",
    "@polymer/paper-toggle-button": "^3.0.1",
    "@polymer/paper-toolbar": "^3.0.1",
    "@polymer/paper-tooltip": "^3.0.1",
    "@polymer/polymer": "^3.4.1",
    "@tinymce/tinymce-angular": "^4.2.4",
    "@types/bowser": "1.0.30",
    "@types/file-saver": "^2.0.1",
    "@types/gapi": "0.0.31",
    "@types/jquery": "2.0.41",
    "@types/lodash": "^4.14.118",
    "@types/socket.io-client": "^3.0.0",
    "@webcomponents/webcomponentsjs": "^2.5.0",

Server.ts

import 'zone.js/dist/zone-node';

import { ngExpressEngine } from '@nguniversal/express-engine';
import * as express from 'express';
import { join } from 'path';
// import 'node-self';
const domino = require('domino');
// const fs = require('fs');
import * as fs from 'fs';
// import * as path from 'path';

// import { existsSync } from 'fs';
// import * as domino from 'domino';
// const template = fs.readFileSync(path.join(distFolder, 'index.html')).toString();
// Shim for the global window and document objects.
const distFolder = join(process.cwd(), 'dist/browser');
const indexHtml = fs.existsSync(join(distFolder, 'index.original.html')) ? 'index.original.html' : 'index';
// const template = fs.readFileSync(join(distFolder, indexHtml)).toString();
// const template = fs.readFileSync(path.join(distFolder, 'index.html')).toString();
// const template = fs.readFileSync(path.join('.', 'dist', 'browser', 'index.html')).toString();
const win = domino.createWindow(indexHtml);
// console.log('Win==>',win);
global['window'] = win;
// global['self'] =  win;
console.log('self==>',global['self']);
console.log('self==>',global['self']===global['window']);
global['document'] = win.document;
global['HTMLElement'] = win.HTMLElement;
global['navigator'] = win.navigator;

import { AppServerModule } from './src/main.server';
import { APP_BASE_HREF } from '@angular/common';

// The Express app is exported so that it can be used by serverless Functions.
export function app(): express.Express {
  const server = express();

  console.log('server side');

  const path = require('path');

  // Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
  server.engine('html', ngExpressEngine({
    bootstrap: AppServerModule,
  }));

  server.set('view engine', 'html');
  server.set('views', distFolder);

  // Example Express Rest API endpoints
  // server.get('/api/**', (req, res) => { });
  // Serve static files from /browser
  server.get('*.*', express.static(distFolder, {
    maxAge: '1y'
  }));

Minimal Reproduction

Using command to create build : npm run build:ssr and after that using this command to serve : npm run serve:ssr - Here getting the above error

Exception or Error

No response

Your Environment

Angular CLI: 11.0.6
Node: 14.15.4
OS: win32 x64

Angular: 11.0.7
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, platform-server, router
Ivy Workspace: <error>

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.803.29
@angular-devkit/build-angular   0.1100.6
@angular-devkit/core            11.0.6
@angular-devkit/schematics      11.0.6
@angular/cdk                    11.0.3
@angular/cli                    11.0.6
@angular/fire                   6.1.4
@angular/material               11.0.3
@nguniversal/builders           <error>
@nguniversal/express-engine     <error>
@schematics/angular             11.0.6
@schematics/update              0.1100.6
rxjs                            6.6.3
typescript                      4.0.5

Anything else relevant?

No response

alan-agius4 commented 8 months ago

Hello, we reviewed this issue and determined that it doesn't fall into the bug report or feature request category. This issue tracker is not suitable for support requests, please repost your issue on StackOverflow using tag angular-cli.

If you are wondering why we don't resolve support issues via the issue tracker, please check out this explanation.

angular-automatic-lock-bot[bot] commented 7 months ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.