Server Side Rendering Angular 4/5 Issue - angular5

I am working on angular 5. I am done with my app and created a build and deployed on the server and it works fine.
But I have issue with Search Engine Optimization that pages are not indexed in google. I used Server Side Rendering and have the below error:
F:\universal-demo-v5>node dist/server.js F:\universal-demo-v5\dist\server.js:111436 })(window, document, 'Hammer'); ^ ReferenceError: window is not defined
at Object.defineProperty.value (F:\universal-demo-v5\dist\server.js:111436:4)
at __webpack_require__ (F:\universal-demo-v5\dist\server.js:20:30)
at Object.hammerjs (F:\universal-demo-v5\dist\server.js:139493:18)
at __webpack_require__ (F:\universal-demo-v5\dist\server.js:128177:30)
at Object.../../../../ngx-carousel/src/ngx-carousel/ngx-carousel.component.js (F:\universal-demo-v5\dist\server.js:138668:67)
at __webpack_require__ (F:\universal-demo-v5\dist\server.js:128177:30)
at Object.../../../../ngx-carousel/src/ngx-carousel/ngx-carousel.component.ngfactory.js (F:\universal-demo-v5\dist\server.js:139254:10)
at __webpack_require__ (F:\universal-demo-v5\dist\server.js:128177:30)
at Object.../../../../../src/app/components/home/home.component.ngfactory.js (F:\universal-demo-v5\dist\server.js:129216:11)
at __webpack_require__ (F:\universal-demo-v5\dist\server.js:128177:30)

This is very late but maybe it will help you or someone in the future.
This happens when using Angular Universal, its because the server side rendering doesnt have a 'window' to use, only the browser does.
So when this code is executed the server fails to find the non-existent window. You can fix this by either removing hammerjs (it isnt essential, just adds quality of life to material 2 and similar UI)
Or you can try this fix here: https://github.com/angular/universal/issues/830
Which involves defining the window in your server.ts code so when it runs it works correctly.

Related

I get "t.openWindow is not a function" errors when I use TestCafe Window Management methods

The process for writing multiple windows tests described in TestCafe documentation seems pretty straightforward:
await t.openWindow('https://url.com/addnewproperty')
or even
const initialWindow = await t.getCurrentWindow()
should do it. However, every time I use any of the Window Management methods I get the errors:
TypeError: t.openWindow is not a function and cannot do anything about it.
Does anyone know what am I doing wrong and how to solve the issue?
TestCafe version 1.9.4
The problem was in different versions of Test Cafe used between main codebase and one of the underlying packages. Alex Kamaev answer was a correct one

Syntax error handling in dojo 18n resource file

require(["dojo/i18n!myapp/nls/extTools_i18nStrings"],function(extTools_i18nStrings){
// Do something with the loaded file
});
If the resource file (extTools_i18nStrings) has syntax error, it will be shown in dojo.js. How can I handle it in my code?
Try catch block did not work.
Thanks in advance.
Error: Script error .............dojo.js:15
The quick answer is you don't want to. The right thing to do is fix the bundle. This is the same as having errors in your application code, and you would not expect the code to 'handle' that.
But since i18n is an AMD plugin running as part of the loader (which is why you can't try/catch it), the error might be reported through the AMD micro event API, and you could use that to show a better error. I'm not sure how you 'handle' this syntax error other than showing an error.
If you can't control the quality of the bundles via some part of your development or build process you'd have to invent your own alternative to dojo/i18n and you probably don't want to go down that route for all of your bundles.

Reflect.getOwnMetadata - Updating Aurelia

Reflect.getOwnMetadata is not a function in karma with latest Aurelia
I believe my issue to be the same as this, but I am unsure. I needed to update 'binding' from aurelia-binding#^1.0.0-beta.1.0.5 to aurelia-binding#^1.0.0-beta.1.3.0, due to a bug fix within that release, since updating I recieve the following error:
Uncaught (in promise) Error: TypeError: Reflect.getOwnMetadata is not
a function(…)
After a bit of research, mostly being linked back to the question above in one way or another, I had hoped their solution would solve mine however, gulp watch returns: import 'aurelia...' unexpected reserved work. Unsure what I am missing
I think the actual issue is with loading the following, seems to break here first
(function(System, SystemJS, require) {define(["npm:aurelia-templating-resources#1.0.0-beta.1.0.2/aurelia-templating-resources"], function(main) {
return main;
});
})(System, System);

undefined local variable or method `start_test_server_in_background' for #<Object:0x007ffc49a5e130>

This has been asked before for .12.0 but I am now getting a similar error in .14.2 .
Up until a few weeks ago I was running calabash.framework 11.4 because it worked, was stable, and it was under lock and key on our development server. We went through a recent state of updating all of our gems and services and while our build server still functions calabash is no longer recognizing the "start_server_in_background" method. I am at a loss on how to remedy this. I tried a complete wipe and reinstall on my local mirror to no avail, and am considering rolling everything back to the previous working versions. However I would like to solve this to keep everything up to date.
I have tried the following solutions with no success.
undefined local variable or method `start_test_server_in_background' for main:Object
https://github.com/calabash/calabash-ios/issues/669
https://github.com/calabash/calabash-android/issues/371
This is my error after the scenario runs
undefined local variable or method `start_test_server_in_background' for #<Object:0x007f9a7c07ba48> (NameError)
/Users/mycomp/.rvm/gems/ruby-2.2.1#global/gems/rspec-expectations-3.2.1/lib/rspec/matchers.rb:926:in `method_missing'
/Users/mycomp/KonyiOSWorkspace/user/Kony/iOS-6.0.3.GA_v201503250510/VMAppWithKonylib/features/mobile/helpers/ios/support/app_life_cycle_hooks.rb:44:in `Before'
The recommend way of launching the application is to use:
options = { }
launcher.relaunch(options)
launcher.calabash_notify(self)
In your support/env.rb file you need to:
require 'calabash-cucumber/cucumber'
not calabash-cucumber.

cometd hello world example with dojo

I'm trying to follow the basic cometd example here: http://dojotoolkit.org/reference-guide/1.7/dojox/cometd.html
It's using the old module loader so I tried the equivalent as follows:
require(["dojo/ready","dojo/io/script","dojox/cometd","dojox/cometd/callbackPollTransport"], function(ready, dontcare, cometd) {
ready(function(){
cometd.init('http://localhost:8080/MyCometD/cometd');
comted.subscribe("/test", function(msg){
console.debug(msg);
});
});
});
This doesn't work and I think it has to do with loading modules - there is some sort of silent error as the code within the ready function does not execute at all. What I found is that when the "dojox/cometd" require statement is present, the code within the ready function does not execute.
Running example: http://jsfiddle.net/Q9W8f/2/
Example with dojox/comted removed: http://jsfiddle.net/mMs2h/4/
I haven't worked with the new module loader that much so I bet I just have some simple misconception.
Help!
It seems like youre correct and that there is a 'wait-loop' for a module requirement that never gets loaded. This may be any of the requirements inside dojox.cometd and you'd need to rewrite the codebase for a fix.
I have had similar issue with the RollingListPane, also in dojox repository - and the developers are saying 'we are 100% AMD compliant with 1.7' however the X in dojox is short for experimental. The developement of dojox modules is not done by the core djtk team and there are still glitches..
Try for starters to avoid using CDN which has performed a >>built macro on every single module. This tends to fail at times whilst using AMD. Instead download the tarball and use a local copy - Not compressed (dojo-release-1.7.2-src)
You can find the hello world example in cometD and ExtJs at following link:
http://jksnu.blogspot.in/2013/08/network-reliability-by-cometd-hellow_16.html