You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/07/30 05:10:06 UTC

[GitHub] [cordova-android] xqqy opened a new issue #796: proper content-type for JavaScript dynamic import

xqqy opened a new issue #796: proper content-type for JavaScript dynamic import
URL: https://github.com/apache/cordova-android/issues/796
 
 
   # Bug Report
   
   ## Problem
   JavaScript [dynamic import](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/import) would not work. Because when load .js file,it didn't have a  proper content-type. 
   
   ### What is expected to happen?
   Behave as what in a normal browser. 
   
   
   ### What does actually happen?
   Webview will catch a error "{message:Failed to fetch dynamically imported module:<the .js file name>,stack:TypeError:Failed to fetch dynamically imported module:<the .js file name>,}".
   Which I thought it is because it didn't have a proper HTTP content-type inside.
   
   
   ## Information
   <!-- Include all relevant information that might help understand and reproduce the problem -->
   It will catch a error:
   message: "Failed to fetch dynamically imported module: file:///android_asset/www/js/module/U0_0.js"
   stack: "TypeError: Failed to fetch dynamically imported module: file:///android_asset/www/js/module/U0_0.js"
   __proto__: Object
   constructor: function()
   message: ""
   name: "TypeError"
   toString: function()
   __proto__: Object
   constructor: function()
   message: ""
   name: "Error"
   toString: function()
   __proto__: Object
   __defineGetter__: function()
   __defineSetter__: function()
   __lookupGetter__: function()
   __lookupSetter__: function()
   __proto__: null
   constructor: function()
   hasOwnProperty: function()
   isPrototypeOf: function()
   propertyIsEnumerable: function()
   toLocaleString: function()
   toString: function()
   valueOf: function()
   __proto__: null
   
   
   To reproduce the problem in my [project](https://www.gitlab.com/acted/h2):
   click "开始游戏"-"进入关卡"(it will stuck here due to it can't load javascript file)
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   My project are in [https://www.gitlab.com/acted/h2]( https://www.gitlab.com/acted/h2
   )
   In file 'www/js/plus.js' function 'clsup' line125
   
   code of dynamic import which caused a error:
   `        import('./module/'+node+'.js')
               .then(module => {
                   module.clsup_e();//由该模块进行渲染
               })
               .catch(err => {
                   console.error(err);
                   dialogAlert("动态加载失败,请升级浏览器。推荐电脑使用Firefox,手机使用MS edge");
               });
   `
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you experiencing the issue? -->
   System :Android9
   WebView:Chrome 75.0.3770.101
   devices:MI4C with mokee 90.0-libra-201907290826-NIGHTLY
   
   
   ### Version information
   <!-- 
   What are relevant versions you are using?
   For example:
   Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins 
   Other Frameworks: Ionic Framework and CLI version
   Operating System, Android Studio, Xcode etc.
   -->
   cordova-lib@9.0.1 with:
     cordova-common@3.2.0
     cordova-create@2.0.0
     cordova-fetch@2.0.1
     cordova-serve@3.0.0
   
   Environment: 
     OS: linux
     Node: v12.7.0
     npm: 6.10.0
   
   Plugins:
     cordova-plugin-dialogs
     cordova-plugin-whitelist
   
   Android platform:
     ERROR: android: Command failed with exit code ENOENT
   
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [ x] I searched for existing GitHub issues
   - [ x] I updated all Cordova tooling to most recent version
   - [ x] I included all the necessary information above
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org