ES6 Modules/Imports in Apache Cordova Hybrid App Throw MIME Type Error ES6 Modules/Imports in Apache Cordova Hybrid App Throw MIME Type Error google-chrome google-chrome

ES6 Modules/Imports in Apache Cordova Hybrid App Throw MIME Type Error


File system fetched files do not have a MIME type, but due to a tightened security ES6 modules must be served only with "application/javascript" MIME type.

As a workaround you may include (like I did) a web server in your app. See, for example, cordova-httpd.


I wound up solving this problem by using webpack to compile all of my code and assets into a single file. This allowed the use of import syntax without all of the associated problems in Apache Cordova. It's not as good as native support, but it was the best solution for me.


I solved it by just removing all the occurrences of type="module" in the cordova project.