Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

开发环境下存在兼容性问题 #528

Closed
hansnow opened this issue May 23, 2018 · 1 comment
Closed

开发环境下存在兼容性问题 #528

hansnow opened this issue May 23, 2018 · 1 comment

Comments

@hansnow
Copy link
Contributor

hansnow commented May 23, 2018

问题

开发环境下,浏览器加载的umi.js文件中存在这样一段代码

/* 799 */
/*!*********************************************************************!*\
  !*** ./node_modules/umi-build-dev/lib/utils/guessJSFileFromPath.js ***!
  \*********************************************************************/
/*! dynamic exports provided */
/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = _default;

function _default(pathname) {
  let ret = null;
  pathname = pathname.replace(/\.html?$/, '');

  if (pathname.slice(-1) === '/') {
    ret = `${pathname.slice(0, -1)}/index.js`;
  } else {
    ret = `${pathname}.js`;
  } // strip the start slash


  ret = ret.slice(1);
  return ret;
}

其中的let和Template literals语法会让一些兼容性不太好的浏览器报错,导致页面白屏

原因

出现问题的文件在NotFound.js#L4中被引用,从build.js#L46来看,NotFound.js使用browserBabelConfig进行编译,而guessJSFileFromPath.js使用nodeBabelConfig进行编译,也就是说guessJSFileFromPath.js用错了编译配置

解决方案

guessJSFileFromPath.js使用browserBabelConfig编译

其他

在问题并不存在于生产环境(即build之后)

sorrycc added a commit that referenced this issue May 23, 2018
fix: compatibility issue in dev server(#528)
@sorrycc
Copy link
Member

sorrycc commented May 23, 2018

Thanks for PR, closed via #528 .

@sorrycc sorrycc closed this as completed May 23, 2018
sorrycc pushed a commit that referenced this issue Jun 23, 2022
* refactor: 🔥 remove unnessary isPromise

* refactor: 🔥 remove isPromise decision

* chore: ⏪ revert client side change

* test: ✅ BDD style rerange test

* test: ✅  revert to tdd style test case

Co-authored-by: pshu <pishu.spf@antfin.com>
xierenyuan pushed a commit to xierenyuan/umi that referenced this issue Jun 23, 2022
* refactor: 🔥 remove unnessary isPromise

* refactor: 🔥 remove isPromise decision

* chore: ⏪ revert client side change

* test: ✅ BDD style rerange test

* test: ✅  revert to tdd style test case

Co-authored-by: pshu <pishu.spf@antfin.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants