pwa-builder/ManifoldCordova

UWP Win 10 WinJS error

Closed this issue · 3 comments

Using VS 2015 with Cordova Tools, Cordova 6.1.1:
When running UWP Win 10 version of blank app with hostedwebapp plugin installed, a WinJS error pops up:

Unhandled exception at line 9, column 9 in ms-appx://[REMOVED]/www/js/wrapper.js

0x800a1391 - JavaScript runtime error: 'WinJS' is undefined

Workaround:
I've wrapped the whole content of wrapper.js into a window.load =function() { } block to make sure it's executed only when wapper.html has loaded.
Seems to do the trick.

Just wanted to make sure that this is a correct workaround.
Thanks!

Thanks for reaching out. So i can see there being a problem if wrapper.js tries to execute on a cordova API before the api is loaded. Generally we recommend that you utilize the Cordova "deviceready" event to start any js execution that might call a cordova API. This when you know everything will be ready. Does this help your situation?

Helllo!
This is happening with just pointing to a website that does not contain any cordova code. And the applicatoins index.html and index.js are both pretty much empty (but I don't think the plugimn would use that as the start url points to a local dev server serving a normal html page).

Where / When does wrapper.html get called?
Thanks

I've been able to repro this 100% by setting up new project and adding the plugin and running windows 10 UWP build via command line.
Every time the problem is fixed as soon as I wrap the content of wrapper.js around a window.onload = function() function