-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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(hmr): add timestamp for assets in dev #13371
Conversation
Run & review this pull request in StackBlitz Codeflow. |
Expected various break of existing test on the exact matching of path. I will fix them once we agree on the fix! |
@@ -179,7 +179,7 @@ export function assetPlugin(config: ResolvedConfig): Plugin { | |||
|
|||
id = id.replace(urlRE, '$1').replace(unnededFinalQueryCharRE, '') | |||
const url = await fileToUrl(id, config, this) | |||
return `export default ${JSON.stringify(url)}` | |||
return `export default ${JSON.stringify(`${url}?t=${Date.now()}`)}` |
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.
We shouldn't do this for public files, no?
I'm thinking we may also need to wait for Vite 5 to apply this change 🤔
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 need to test how this behaves for public files. But I think this currently marked as deprecated to import public files in source code so I would not worry too much about this.
What are you afraid it will break apart from test suite that are using exact match for paths?
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 would think that projects shouldn't break as having a ?t=
is expected. It still feels like a non-trivial change. Maybe we could move with it during the 4.4 beta and we see if some projects have issues with this.
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.
But I think this currently marked as deprecated to import public files in source code so I would not worry too much about this.
I don't think it's deprecated (see https://vitejs.dev/guide/assets.html#the-public-directory). But nevertheless I don't see much harm if we add the timestamp for them either.
I think however we should only add the timestamp in dev.
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
SvelteKit and Vitest are new failures in the ecosystem-ci run above. It is getting a bit difficult to work with so many reds in the results. But maybe better to check these two before merging. |
Maybe merging main and re-run could also be a good idea. |
Totally related:
|
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.
The tests should be updated to match instead of to be equal. I'm hesitant about doing this change in 4.4, I'll let others comment here. We could try it out and revert, or directly move this one to Vite 5.
I think it's a bit borderline a breaking change that it would be safer to move it to Vite 5. Some user apps who used |
Ok, let's move it to Vite 5 👍🏼 |
7a45597
to
1e07df1
Compare
Fixes: #13379