What is the purpose to "mock" cordova.js in development?


#1

Hi,

I just noticed that when creating a Ionic app, the cordova.js file which is loaded is a fake one (no content inside).

What is the purpose of doing that? Why the real Cordova isn’t loaded?

The problem I have with this: I’m using a Barcode Scanner plugin, but when I’m writing cordova.plugins.barcodeScanner.scan(... of course I get a ReferenceError: cordova is not defined


#2

Solved.

I didn’t think it was able to load a real cordova.js when doing ionic run --device


#3

the cordovajs is just a javascript bridge between the cordova app and your javascript code.

When opening your app on the browser or while developing, the cordova file isn’t loaded because when you cordova build android / cordova run android the cordova.js file is included on your project.

If you include the cordova.js file manually on your project, you’ll also get an error on browser because that file needs to connect with the cordova wrapper app only available in the app form