Bug Report
Problem
Recently we've been migrating our code to JavaScript Modules. However we've found on some devices, JavaScript Modules fail to load in Cordova.
What is expected to happen?
Install and open the app. On some devices, it fails to get past the splash screen.
What does actually happen?
On some devices, it works. On others, it fails. The problem appears to be the following console error message:
Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.
The app includes a module script as: <script src="scripts/main.js" type="module"></script>
It appears the strict MIME type checker for modules is failing to identify the MIME type for the given script. However the script is loaded from a file: protocol in Cordova. Therefore it is not possible to configure a Content-Type HTTP header.
Information
Presumably the WebView is not being told that the local .js file has the MIME type "application/javascript", and instead gets an empty string, which appears in the error message.
Perhaps cordova-android can be updated to fix this.
Command or Code
Demo APK: https://www.dropbox.com/s/2payb5y2lpcdkro/testOOO.android.debug.apk?dl=0
Cordova project: https://www.dropbox.com/s/zudv2ooa83gzv4u/testOOO.zip?dl=0
Environment, Platform, Device
From my test of four devices I got the following results:
Google Pixel 3 / Android 11: Pass
Google Nexus 9 / Android 7.1.1: Fail
Samsung Galaxy S8 / Android 8: Fail
HTC 10 / Android 8: Fail
I don't know it works on some devices and fails on others, but it makes it a nasty gotcha for development.
Version information
Built with Cordova CLI and cordova-android@9.0.0.
Checklist
Bug Report
Problem
Recently we've been migrating our code to JavaScript Modules. However we've found on some devices, JavaScript Modules fail to load in Cordova.
What is expected to happen?
Install and open the app. On some devices, it fails to get past the splash screen.
What does actually happen?
On some devices, it works. On others, it fails. The problem appears to be the following console error message:
The app includes a module script as: <script src="scripts/main.js" type="module"></script>
It appears the strict MIME type checker for modules is failing to identify the MIME type for the given script. However the script is loaded from a file: protocol in Cordova. Therefore it is not possible to configure a Content-Type HTTP header.
Information
Presumably the WebView is not being told that the local .js file has the MIME type "application/javascript", and instead gets an empty string, which appears in the error message.
Perhaps cordova-android can be updated to fix this.
Command or Code
Demo APK: https://www.dropbox.com/s/2payb5y2lpcdkro/testOOO.android.debug.apk?dl=0
Cordova project: https://www.dropbox.com/s/zudv2ooa83gzv4u/testOOO.zip?dl=0
Environment, Platform, Device
From my test of four devices I got the following results:
Google Pixel 3 / Android 11: Pass
Google Nexus 9 / Android 7.1.1: Fail
Samsung Galaxy S8 / Android 8: Fail
HTC 10 / Android 8: Fail
I don't know it works on some devices and fails on others, but it makes it a nasty gotcha for development.
Version information
Built with Cordova CLI and cordova-android@9.0.0.
Checklist