Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Hammerjs window undefined issue #189

Closed
flauc opened this issue Oct 4, 2016 · 5 comments
Closed

Hammerjs window undefined issue #189

flauc opened this issue Oct 4, 2016 · 5 comments

Comments

@flauc
Copy link

flauc commented Oct 4, 2016

I've added hammerjs like this in my webpack:

            new webpack.ProvidePlugin({
                Hammer: 'hammerjs',
            })

And everything works, however i get the window undefined error from the server. I know how to do DI Swapping and this is what i do when i need window usually but the problem here is that i think it's angular that is causing the error this time because this is the error i get:

 ReferenceError: window is not defined
          at HammerGesturesPlugin.supports

Now as far as i can say it doesn't really break anything it just throws the error.

@MarkPieszak
Copy link
Member

MarkPieszak commented Oct 4, 2016

Thanks for reporting the issue! The problem is window is a Browser only object, at the moment you could do some conditional things such as isBrowser from Universal, to make sure it's not used on the server side pretender of your App.

You can follow the general issue here, where support for window and other globals will be added: (if at the very least suppressed and ignored on the server)
angular/universal#534

@flauc
Copy link
Author

flauc commented Oct 5, 2016

Thank you for the quick response 👍

@PatrickJS
Copy link
Member

thanks, the current workaround was added to app.node.module

@ng-state
Copy link

ng-state commented Nov 6, 2017

Hi, having troubles to use Hammer with server side renderin.
gdi2290 also cannot find app.node.module file to look for work around.
Is there any other possible solutions how to use it?

p.s. alos - MarkPieszak is Angular universal going to support window since task you provided is closed

@Toxicable
Copy link

@ng-state if you have an issue it would be best to open an issue for it since this one is pretty outdated

as for your second comment I have a proposal here: angular/universal#828
Feel free to add any opinions on the matter there

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants