Open gotjoshua opened 6 months ago
Before finding your (very nice!) plugin, i hacked together an env var based solution in vite config, but it doesn't update with HMR.
wondering if you are willing to add HMR support. I guess it needs to use handleHotUpdate, but i don't have all the details worked out. Just wanted to reach out to see if you are open to collaborate.
Thank you for your kind words and interest in the plugin! I'm glad to hear it's been useful for you.
Currently, the plugin is designed to operate during the build process. As you might have noticed in the source code, it generates git information during the build and incorporates this into the compiled code.
Regarding your query about HMR, the plugin doesn't directly interact with the HMR process since it operates statically at build time. If you make a new git commit and then trigger a rebuild, the git information will indeed update according to the latest commit.
Could you elaborate on how you envision HMR working with this plugin? Understanding your specific needs and the details of your implementation could help explore possible enhancements or alternatives.
So the idea is to support remote teams to know if the local repo is ahead and or behind from the remote branch
It seems pretty often that I forget to fetch when starting a vite dev session and then small merge conflicts can arise or, I just don't have all my colleagues latest code
I got a pretty decent MVP working now: Plugin: https://gitlab.com/wovin/wovin/-/blob/main/apps/note3/vite-git-plugin.ts?ref_type=heads
Consumer component https://gitlab.com/wovin/wovin/-/blob/main/apps/note3/src/components/bars/TopBar.tsx?ref_type=heads#L35
Aha, now I understand your goal! It's really useful to know in real-time if there are new commits on the remote branch during your coding sessions. I saw the MVP code you shared on GitLab—it's a clever implementation that fits your needs, effectively detecting differences between the local and remote repositories during coding time (ingeniously using HMR) and integrating this information directly into the component.
also,you might consider using the Git CLI command like this :
git log -1 $(git rev-parse --abbrev-ref --symbolic-full-name @{u}) --pretty=format:"%h - %an, %ad : %s"
This command retrieves the latest commit hash, author name, commit date, and commit message, which could be helpful.
As for my plugin, its purpose is to track the version in the production environment, so it is designed to be used in local builds or CI builds, not suitable for HMR.
I also have a few suggestions that might help you further:
Hope these suggestions help!
Very generous reply, many thanks !
I kinda figured that your plugin wasn't a great fit for hmr but thanks for entertaining the question anyway.
Cheers!
Before finding your (very nice!) plugin, i hacked together an env var based solution in vite config, but it doesn't update with HMR.
wondering if you are willing to add HMR support. I guess it needs to use handleHotUpdate, but i don't have all the details worked out. Just wanted to reach out to see if you are open to collaborate.