angular / universal

Server-side rendering and Prerendering for Angular
MIT License
4.04k stars 484 forks source link

When code include browser function (like setTimeout), builder return error #2541

Closed sundaynamaste closed 2 years ago

sundaynamaste commented 2 years ago

🚀 Feature request

What modules are relevant for this feature request?

Description

When use AngularUniversal, sometimes can miss wrap browser function (like setTimeout) with "isPlatformBrowser". (if (isPlatformBrowser(this.platformId)) { // Client only code })

Now builder and express show no errors. so It can be used at Production and keep loading and fail. (https://stackoverflow.com/questions/54700345/angular-universal-express-server-keeps-loading-and-fails-with-err-empty-response)

Describe the solution you'd like

It would be better to show errors and fail to build when build for server (ssr)

Describe alternatives you've considered

express-engine shows the error.

Thanks for your great works!

CaerusKaru commented 2 years ago

We consider using isPlatformBrowser in most cases to be an anti-pattern. You can learn more about why in this article. As such, we won't be considering this proposal for any of the libraries in this repo. However, if you feel strongly enough about this, you are of course welcome to develop your own engine and vend it through NPM. The express-engine after all is little more than a thin wrapper around the utilities vended in the common library.

angular-automatic-lock-bot[bot] commented 2 years 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.