When I add some cordova plugins to my project via npm, the dev build fails to serve the javascript files to the client webview.
I have some plugins listed in my .meteor/cordova-plugins
file:
cordova-plugin-file@4.3.3
cordova-plugin-file-transfer@1.6.3
cordova-plugin-x-toast@2.6.0
cordova-plugin-inappbrowser@1.7.1
The first two work fine and I can use their features in my JS. The last two on the other hand, fail to load on my android device. The meteor client makes requests for the JS files that the plugins provide, but the internal server responds with the default meteor bootstrap HTML instead of the JS contents.
I don’t know much about the cordova build process, so this has me stumped. Some details follow.
The working plugins have their JavaScript fetched like this (details from chrome dev tools):
General
Request URL: http://localhost:12072/plugins/cordova-plugin-file/www/File.js
Request Method: GET
Status Code: 200 OK (from disk cache)
Referrer Policy: no-referrer-when-downgrade
Response Headers
Client-Via: shouldInterceptRequest
Content-Length: 2712
Content-Type: text/javascript
The failing plugins have HTML served to them instead:
General
Request URL: http://localhost:12072/plugins/cordova-plugin-x-toast/www/Toast.js
Request Method: GET
Status Code: 200 OK (from disk cache)
Referrer Policy: no-referrer-when-downgrade
Response Headers
Client-Via: shouldInterceptRequest
Content-Length: 15202
Content-Type: text/html
The HTML that is served is the same as the initial HTML that is served when you request any non-special path.
As a result of the JS not arriving in the client, we get this stack trace in the console:
Uncaught Error: Module cordova-plugin-x-toast.Toast does not exist.
at addEntry (cordova.js:1469)
at Object.exports.clobbers (cordova.js:1479)
at onScriptLoadingComplete (cordova.js:1893)
at scriptLoadedCallback (cordova.js:1926)
at HTMLScriptElement.<anonymous> (cordova.js:1880)
The only place in the built files that I found reference to the working plugins but not the broken plugins was .meteor/local/cordova-build/platforms/android/assets/cdvasset.manifest
.
Both the working and the broken plugins have entries for their files in both:
.meteor/local/cordova-build/platforms/android/assets/www/cordova_plugins.js
.meteor/local/cordova-build/platforms/android/platform_www/cordova_plugins.js
and the files for all of the plugins are in both:
.meteor/local/cordova-build/platforms/android/assets/www/plugins/
.meteor/local/cordova-build/platforms/android/platform_www/plugins/