question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

applyDomino not working anymore (incl. 2 MWE's: 1 working, 1 not)

See original GitHub issue

I’m submitting a…


[x] Regression 
[ ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

applyDomino isn’t working after webpack.server.config.js has been dropped in Angular 9.

Expected behavior

applyDomino mocks the window object like in ng-universal version 1.2.0 with the presence of webpack.server.config.js.

Minimal reproduction of the problem with instructions

ng-universal with version of 1.2.0, webpack.server.config.js and few changes in angular.json (Angular 8): https://github.com/danieldanielecki/universal-nest-working-window (steps to run the project are in README.md). applyDomino does works in that repo and has an effect during the SSR, which was described in the steps to run the project.

Forked from https://github.com/TrilonIO/universal-nest, ng-universal with version 3.X.X without webpack.server.config.js using the Angular Builders: https://github.com/danieldanielecki/universal-nest applyDomino does not work in that repo and has no an effect during the SSR

Note: I have forked the project, that’s why didn’t upgrade it to the latest Nest. However, on my personal project an upgrade from Angular 8 to Angular 10/newest NestJS also throws a similar error related to window causing breaking the SSR app without excluding the problematic library. It was not the case before, the DOM-related objects were mocked up.

What is the motivation / use case for changing the behavior?

Some third-party plugins access window or any other DOM-related objects directly. We need those plugins in our SSR apps. The one-line solution by using applyDomino is a breeze in comparison to the number of hacks we can find online. I was also one of those to admit that on StackOverflow. Maybe it’s related to the lack of WebpackConfigFactory, which has been dropped. Maybe that’s the lack of webpack.server.config.js, but maybe that’s something related to Angular Builders. Another idea is the lack of a bundle anymore. Really don’t know, but as you’ll be able to see on the MWE’s, applyDomino did work, but does not.

If there’s something wrong in my setup of the forked repo please submit a pull request to https://github.com/danieldanielecki/universal-nest It took me quite some time to go through all the online resources, my pre-upgrade legacy project, check out what has changed, create the MWE’s, and submit this issue. Would be really appreciated.

Might be related to #163, #429. I’ve also tried NestJS’ Discord, but it didn’t solve this issue so I’ve created MWE’s to showcase this black on white.

Environment


(See MWE's)
 
For Tooling issues:
- Node version: `v12.18.3`
- Platform:  `Mac`

Others:

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
danieldanieleckicommented, Jan 31, 2021

I’ve fixed it by using raw domino in my main.ts, do take a look into #830 (comment).

However, it doesn’t change the fact that applyDomino has stopped working.

Edit: the final code in main.ts

import { createWindow } from 'domino';
import { join } from 'path';
const indexHtml = join(
  process.cwd(),
  'dist/nbinar/browser/index2.html'
);
const win = createWindow(indexHtml);

// Polyfills
(global as any).window = win;
(global as any).document = win.document;
(global as any).navigator = win.navigator;

It must be before you import ApplicationModule from server/app.module.ts.

0reactions
pinktoadettecommented, May 21, 2021

Will there be a fix for this in next release?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Domino's: Pizza Delivery & Carryout, Pasta, Chicken & More
Order pizza, pasta, sandwiches & more online for carryout or delivery from Domino's. View menu, find locations, track orders. Sign up for Domino's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found