1

I found this gem angular universal: dynamic imports for browser only. However it was using isBrowser which appears to be no longer available in angular9. I am aware of isPlatformBrowser however that only appears to work in a component with dependency injection. Any way of doing this in angular9 inside a lazy loaded module?

Also should mention that using app.server.module & app.module to differentiate the two didn't appear to be a solution due to this module in particular being lazy loaded. I'm ultimately attempting to prerender my routes, including those that are lazy loaded.

Some primeng components are not compatible with SSR as they make calls to document and navigator. I'm after SEO.

lightbulb112
  • 123
  • 1
  • 9
  • Also should mention that using app.server.module & app.module to differentiate the two didn't appear to be a solution due to this module in particular being lazy loaded. I'm ultimately attempting to prerender my routes, including those that are lazy loaded. – lightbulb112 Jul 11 '20 at 16:36
  • You can edit your post to add your comment. Which module is it that you don't want to include and why? – David Jul 11 '20 at 19:08
  • Try using domino in `server.ts` and add `isPlaformBrowser` checks in your code. Otherwise, you could try something like this to load primeng module dynamically on the client : https://stackoverflow.com/questions/62646218/angular-10-universal-amcharts-4-why-the-server-tries-to-load-the-chart – David Jul 12 '20 at 08:25
  • That example shows a component. I need platform_id from a module. – lightbulb112 Jul 12 '20 at 17:49
  • You can inject platform_id into a module the same way. The example was more to show you how to lazy load 3rd party module based on the platform – David Jul 12 '20 at 22:19

0 Answers0