You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by GitBox <gi...@apache.org> on 2020/03/17 06:42:47 UTC

[GitHub] [incubator-weex-cli] cnryb opened a new issue #618: weex调试时遭遇 Cannot assign to read only property 'exec' of object '[object RegExp]'

cnryb opened a new issue #618: weex调试时遭遇 Cannot assign to read only property 'exec' of object '[object RegExp]'
URL: https://github.com/apache/incubator-weex-cli/issues/618
 
 
   详细的错误信息
   
   ```
   Uncaught TypeError: Cannot assign to read only property 'exec' of object '[object RegExp]'
       at debug-test.weex.d8281d.js:410
       at Object../node_modules/core-js/modules/_fix-re-wks.js (debug-test.weex.d8281d.js:413)
       at __webpack_require__ (debug-test.weex.d8281d.js:22)
       at Object../node_modules/core-js/modules/es6.regexp.split.js (debug-test.weex.d8281d.js:1036)
       at __webpack_require__ (debug-test.weex.d8281d.js:22)
       at Object../node_modules/weex-vue-loader/lib/script-loader.js!./node_modules/babel-loader/lib/index.js!./node_modules/weex-vue-loader/lib/selector.js?type=script&index=0!./pages/debug-test/App.vue (debug-test.weex.d8281d.js:1842)
       at __webpack_require__ (debug-test.weex.d8281d.js:22)
       at Object../pages/debug-test/App.vue (debug-test.weex.d8281d.js:1889)
       at __webpack_require__ (debug-test.weex.d8281d.js:22)
       at Object.<anonymous> (debug-test.weex.d8281d.js:1949)
   ```
   [异常weex js bundle.zip](https://github.com/apache/incubator-weex-cli/files/4341615/weex.js.bundle.zip)   
   在测试代码中只写了一句js代码 ` ''.split('')`
   
   从错误信息可以看到异常是从 core-js 中触发出来的。是这个地方
   ```
     var re = /(?:)/;
     var originalExec = re.exec;
     re.exec = function () { return originalExec.apply(this, arguments); };
   ``` 
   这个问题以前被你们遇到过,但没有找到明确的解决方案,https://github.com/zloirock/core-js/issues/461
   
   ---
   从 js framework 中发现对一些对象做了[冻结操作](https://github.com/apache/incubator-weex/blob/master/runtime/shared/env/freeze.js#L37),包括上面出问题的 RegExp.prototype 。
   
   所以引出了一下问题。
   1、在weex js framework中执行 freeze 的目的是什么?
   2、为什么相同的代码能在 app 中能够正常运行,没有抛出错误?在调试工具中调试js代码时报错能够理解,这时代码执行在chrome中,前面执行了 freeze 后面对freeze的对象进行修改,报错很合理。
   3、想到一个处理这个问题的办法,请帮忙看看会不会引出其他的问题。
   weex调试,开启JS调试时,app中的js framework的代码会在 [Runtime]/index.js 中被以importScripts() 的方式导入进来,在导入之前看到了 mock js framework api 的操作。所以我打算在导入 js framework 之前插入 Object.freeze = function(obj) { return obj } 。让 js framework 中的冻结操作失效(简单测试可行)。
   
   @YorkShen 能不能帮忙呀?

----------------------------------------------------------------
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