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

3.2.17 SSR ReferenceError: LoadingComponent is not defined #5300

Closed
big-camel opened this issue Aug 26, 2020 · 4 comments · Fixed by #5409
Closed

3.2.17 SSR ReferenceError: LoadingComponent is not defined #5300

big-camel opened this issue Aug 26, 2020 · 4 comments · Fixed by #5409
Assignees
Labels
type(ssr) UmiJS SSR

Comments

@big-camel
Copy link
Contributor

big-camel commented Aug 26, 2020

umijs 3.2.17
@umijs/preset-react 1.6.3

开启SSR,生成 dist/umi.server.js 文件后
搜索 server render function
这里 LoadingComponent 好像没有声明

...
/**
     * routes init and patch only once
     * beforeRenderServer must before routes init avoding require error
     */

    if (!routes) {
      // 主要为后面支持按需服务端渲染,单独用 routes 会全编译
      routes = [{
        "path": "/",
        "component": Object(E_projects_react_umi3_2_ssr_test_node_modules_umijs_runtime__WEBPACK_IMPORTED_MODULE_4__["dynamic"])({
          loader: () => Promise.resolve(/*! import() | layouts__BasicLayout */).then(__webpack_require__.bind(null, /*! ./src/layouts/BasicLayout */ "./src/layouts/BasicLayout.js")),
          loading: LoadingComponent
        }),

复现 https://github.com/itellyou-com/umi3.2-ssr-test
服务端 https://github.com/itellyou-com/umi3.2-ssr-test-server
步骤:
在 umi3.2-ssr-test 中 yarn build ,然后将 dist 目录中的文件拷贝到 umi3.2-ssr-test-server ,然后 yarn start ,访问 localhost:3000

ReferenceError: LoadingComponent is not defined
    at q (E:\projects\react\umi3.2-ssr-test-server\dist\umi.server.js:1:1330129)
    at async E:\projects\react\umi3.2-ssr-test-server\src\index.js:28:44
ReferenceError: LoadingComponent is not defined
    at q (E:\projects\react\umi3.2-ssr-test-server\dist\umi.server.js:1:1330129)
    at async E:\projects\react\umi3.2-ssr-test-server\src\index.js:28:44

此时报错,并且 SSR 失效
Originally posted by @itellyou-com in #5263 (comment)

@shlomitsur
Copy link

Happened to me too after upgrading to 3.2.17

@ycjcl868 ycjcl868 self-assigned this Aug 26, 2020
@ycjcl868 ycjcl868 added the type(ssr) UmiJS SSR label Aug 26, 2020
@big-camel
Copy link
Contributor Author

@ycjcl868 啥时候能修复好呢,现在做SSR根本无法用啊

@starsoft35
Copy link

是呀,这bug很长时间了,啥时候能修复好呢

@big-camel
Copy link
Contributor Author

是呀,这bug很长时间了,啥时候能修复好呢

要上线的话,只有先 build ,然后再 运行 start,然后再修改 umi.server 文件 加个 var LoadingComponent = null

 if (!routes) {
      // 主要为后面支持按需服务端渲染,单独用 routes 会全编译
var LoadingComponent = null
      routes = [{

然后搜索 const NODE_ENV = "development";改成

const NODE_ENV = "production"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type(ssr) UmiJS SSR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants