-
Notifications
You must be signed in to change notification settings - Fork 79
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
feat: hot-update 文件生成放到 node_modules 下 #424
base: master
Are you sure you want to change the base?
Conversation
let to = self.context.config.output.path.join(filename); | ||
|
||
std::fs::write(to, content).unwrap(); | ||
let hmr_dir = self.context.root.join("node_modules/.mako/hot_update"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里用 node_modules/.mako,是不是 runtime 就不需要调整了,改动可以小一点。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好像是可以的,我再调整下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 如果用 node_modules/.mako,runtime 还是需要改的:不放到 output 目录下了,得把 requireModule.publicPath 去掉。
- 我这里还是保留 /hot_update 呢,感觉语义更清晰些
@stormslowly review 下。 |
@@ -147,7 +147,7 @@ function createRuntime(makoModules, entryModuleId) { | |||
invalidate () {}, | |||
check () { | |||
const current_hash = requireModule.currentHash(); | |||
return fetch(`${requireModule.publicPath}${current_hash}.hot-update.json`).then((res)=>{ | |||
return fetch(`/hot_update/${current_hash}.hot-update.json`).then((res)=>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里写死 会不会和用户的路由有冲突。业务有一个 hot_update/:id 的路由。这里可以参考下 umi 在 配置了 publicPath 这些资源是怎么 serve 的
原来 public_path 下 也可能定义 /:id
crates/mako/src/dev.rs
Outdated
@@ -102,35 +138,12 @@ impl DevServer { | |||
) | |||
} | |||
} | |||
_ if path.starts_with("hot_update") => { | |||
get_serve_response(static_serve_hmr.serve(req).await) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
之前 dev server 也写的仓促,有时间精力可以看下这部分有没有更加优雅的 crate 可以用。类似 express 一样 mout 。
f0d8463
to
edea548
Compare
这个 pr 先 hold,后续有冲突我来跟进。 |
这块周末我又调整了下,更新了下备注 |
7ca5fd6
to
d3c8cfe
Compare
验证:
e2e case:
rust server
okam node server(本地 umi 项目)