-
Notifications
You must be signed in to change notification settings - Fork 3
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
Hot Reload Vue on shared/ changes #240
Conversation
Yeah
I'm not so sure about that one. It's very cool that you got it to work, but it would be sad if there wasn't a nicer way that just works. |
So I don't feel too strongly about this point compared to the first one. However, my thought process is that
Indeed! I'll need some help though - I've tried quite a few ways with very little luck 😞 |
Okay actually, I think I got the absolute imports figured out. Using Not sure why |
Okay, I think I actually got this in a place that's publishable. Summary of changes since earlier conversation:
I didn't come up with a solution to depend on the |
</script> | ||
|
||
<template> | ||
<main> | ||
<h2>Welcome to Go variants!</h2> | ||
<h2>Welcome to {{ SITE_NAME }}!</h2> |
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.
This was mainly for testing. I can remove it before merging, but want to make sure we landed on an agreeable configuration first.
} | ||
, | ||
"verbatimModuleSyntax": false, |
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.
I think verbatimModuleSyntax
off makes it so I don't need to put type { SomeImport }
everywhere in shared/
. I'm not opposed to it, but it would be quite a large change, and I wanted to keep this diff to config-only as much as possible.
@@ -4,9 +4,14 @@ | |||
"exclude": ["src/**/__tests__/*"], | |||
"compilerOptions": { | |||
"composite": true, | |||
"baseUrl": ".", | |||
"baseUrl": "..", |
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.
This puts us in the packages
directory, so we can look at packages/shared
@@ -3,6 +3,14 @@ | |||
"include": ["vite.config.*", "vitest.config.*", "cypress.config.*"], |
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.
I'm pretty sure the changes were required in all 3 tsconfig files (excluding tsconfig.vitest.json). Maybe there is a way to dedupe using the "extends" field. But I don't quite understand the difference in intent behind app
and config
anyway... Maybe we can remove them and just keep tsconfig.json?
@@ -9,6 +9,12 @@ export default defineConfig({ | |||
resolve: { | |||
alias: { | |||
"@": fileURLToPath(new URL("./src", import.meta.url)), | |||
"@ogfcommunity/variants-shared/src": fileURLToPath( | |||
new URL("../shared/src", import.meta.url), |
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.
@ogfcommunity/variants-shared/src
is to support imports like "@ogfcommunity/variants-shared/src/time_control"
@ogfcommunity/variants-shared/src
is to support imports like "@ogfcommunity/variants-shared".
Importantly, the /src version needs to come first, else the latter will overtake it.
Trying to figure out #28 (hot reload when shared/ changes)
While this was the one way I found to get hot reload to work, I don't think this solution is great for a couple of reasons.
"@/../../shared"
- it's pretty hacky to use relative imports. It means we'll need to change a ton of files if we change the directory structure."@shared"
or somethingdist
instead ofsrc
watch.ignored
andoptimizeDeps
(see https://github.com/govariantsteam/govariants/tree/attempt-at-hot-reload) but wasn't able to turn on hot reloadThat said, I am well beyond the limit of my TS and Vue/Vite knowledge, I am hoping someone might see a better path now that we have a "working" path
Hot Reload Demo
Notice I am editing a variable in
shared/src/index.ts
!!!Screen.Recording.2024-04-19.at.6.09.36.PM.mp4