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

fix(examples): 静态资源加载错误 #11980

Merged
merged 8 commits into from
Jan 1, 2024
Merged

Conversation

wangz-code
Copy link
Contributor

@wangz-code wangz-code commented Dec 21, 2023

mac m1 本地执行
info - dumi v2.2.16
info - Umi v4.0.89
"express": "^4.18.2"
node v18.10.0

如果先执行umi.server.js 会导致页面样式错误, 控制台提示:
Uncaught SyntaxError: Unexpected token '<'

mac m1 
info  - dumi v2.2.16
info  - Umi v4.0.89

如果先执行umi.server.js  会导致页面样式错误,  控制台提示:
```  Uncaught SyntaxError: Unexpected token '<' ```
Copy link

vercel bot commented Dec 21, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
umi ⬜️ Ignored (Inspect) Visit Preview Jan 1, 2024 0:58am

@fz6m
Copy link
Contributor

fz6m commented Dec 21, 2023

因为时间太久,这个 ssr-todos 示例我也不知道怎么用的了,里面需要启动一个 todo api 的服务,并且涉及到 isomorphic-unfetch 的关联上游 unfetch 导出错误,以及 node: 的替换问题,现在这个 example 是启动不了也构建不了的。

如有兴趣,可以重写一下这个 example ,把 vercel 的部分去掉,换成本地 express mock 的 todo api 服务,删除 isomorphic-unfetch

@wangz-code
Copy link
Contributor Author

因为时间太久,这个 ssr-todos 示例我也不知道怎么用的了,里面需要启动一个 todo api 的服务,并且涉及到 isomorphic-unfetch 的关联上游 unfetch 导出错误,以及 node: 的替换问题,现在这个 example 是启动不了也构建不了的。

如有兴趣,可以重写一下这个 example ,把 vercel 的部分去掉,换成本地 express mock 的 todo api 服务,删除 isomorphic-unfetch

简单改了一版, 不确定是否符合你的意思

  • 使用 axios 替换了 isomorphic-unfetch 主要用于 node环境下发起请求
  • dev 使用umi中间件mock api
    其他的基本保持一致
    我调试的时候发现 useServerLoaderData 加载数据时总是读取旧数据, 不确定是不是bug

examples/ssr-todos/.umirc.ts Outdated Show resolved Hide resolved
examples/ssr-todos/production-server.js Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jan 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7385a87) 28.77% compared to head (30178ed) 28.77%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #11980   +/-   ##
=======================================
  Coverage   28.77%   28.77%           
=======================================
  Files         489      489           
  Lines       14962    14962           
  Branches     3554     3554           
=======================================
  Hits         4305     4305           
  Misses       9891     9891           
  Partials      766      766           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fz6m
Copy link
Contributor

fz6m commented Jan 1, 2024

真感觉这里面以前写的历史代码一塌糊涂啊,我先简单改了改,真要写一个优雅的 todo list ,react-query 、loading 、组件库这些都不能少,先简单能用就行吧,感谢你的 PR 。

@fz6m fz6m merged commit a6d001e into umijs:master Jan 1, 2024
23 checks passed
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

Successfully merging this pull request may close these issues.

2 participants