angular-modal-gallery: window on server side undefined , hence Mousetrap is not defined

I’m submitting a…


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ x] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request

Current behavior

when running universal example https://github.com/Ks89/angular-modal-gallery/tree/master/examples/universal npm run build:ssr && npm run serve:ssr getting error on server side: Node Express server listening on http://localhost:4000 ERROR { Error: Uncaught (in promise): ReferenceError: Mousetrap is not defined ReferenceError: Mousetrap is not defined at new KeyboardService

Expected behavior

no error

Minimal reproduction of the problem with instructions

My official live example on StackBlitz (based on https://stackblitz.com/edit/angular-modal-gallery-v5) is:

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

gallery is working in browser , but it breaks other stuff for me server-side : specifically translation

had to revert to previous working version of gallery 4.0.1

although using it with wrappers -

var implementation = function () { }; if (typeof window !== ‘undefined’) { implementation = require(‘mousetrap’); } module.exports = implementation;

Environment (the most important section to fill very carefully)


- Node version: v7.0.0 
- npm version: 3.10.8  
- Operating System and version: MAC  
- Angular version: X.Y.Z 
- angular-cli version (or SystemJS/Webpack): X.Y.Z same as universal example
- I'm using Server Side Rendering with angular-universal: YES
- I'm compiling with mode: PROD with AOT



Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX

Others:

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 18 (13 by maintainers)

Commits related to this issue

Most upvoted comments

@mrVers I’ll check this weekend.

SSR has many missing features so I suppose that can add your workaround without problems.

Obviously I’ll remove everything when Google will release a serious version of angular-universal 😃

Seems to work, need more time to fully test. Thank you for quick resolution.

Released as 5.2.0-beta.1.

Could you try if it is working now?

To install use ‘npm i --save angular-modal-gallery@5.2.0-beta.1’