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

improve: duplicate git exec in hmr of git changelog plugin #207

Open
northword opened this issue May 12, 2024 · 3 comments
Open

improve: duplicate git exec in hmr of git changelog plugin #207

northword opened this issue May 12, 2024 · 3 comments
Labels
bug Something isn't working help wanted Extra attention is needed pkg/git-changelog Related to @nolebase/vitepress-plugin-git-changelog

Comments

@northword
Copy link
Member

HMR 中重复的 Git 请求。

当前在 changelog.vue 中和 contributors.vue 中分别 send 了一次,这导致 Git 实际上被运行了两次(即使有设置的缓存,但是似乎因为两次执行的太近了,导致两次都是实际运行了 Git 的,从下面这个日志可以看出:

image

@nekomeowww
Copy link
Member

不知道配合 VueUse 的 useMounted + watch 能不能做一个更好的 store 共享一下。

@nekomeowww nekomeowww added bug Something isn't working pkg/git-changelog Related to @nolebase/vitepress-plugin-git-changelog labels May 14, 2024
@northword
Copy link
Member Author

刚刚试了试在 client throttle ,似乎不可行。

也许可以在 vite 端做 throttle ;

或者做一个更大的组件,把 Changelog 和 Contributor 都放进来,这样就只需要在这个更大的组件里 import.meta.hot.send ,这样就可以避免两个组件都发送。

useMounted + watch 这种我不太清楚怎么实现。

@northword
Copy link
Member Author

(I'm not sure I'm understanding this correctly)

In addition to Git running twice, Vue component reloads were performed 4 times:

Changelog.vue and contributors.vue each resulted in 1 Git run

Each Git run resulted in the following two events:

  • nolebase-git-changelog:updated
  • virtual:nolebase-git-changelog

We might need to wrap these two components into one big component and control whether or not to show separate ones via props/options. Importing on demand might be possible with asynchronous components?

Then on the hmr related logic part, maybe

  • On the vite side, just send data, don't touch the value of the virtual module, and let the client side receive the sent data and re-assign the value.
  • No more sending data on the vite side, accept(virtual:nolebase-git-changelog) on the client side seems to be sufficient.

may related: #245 (comment)

@nekomeowww nekomeowww added the help wanted Extra attention is needed label Jul 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed pkg/git-changelog Related to @nolebase/vitepress-plugin-git-changelog
Projects
None yet
Development

No branches or pull requests

2 participants