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

fix(astro): HMR not work in windows #3100

Merged
merged 1 commit into from
Sep 11, 2023

Conversation

Dunqing
Copy link
Member

@Dunqing Dunqing commented Sep 10, 2023

@Dunqing Dunqing requested a review from antfu as a code owner September 10, 2023 08:41
@netlify
Copy link

netlify bot commented Sep 10, 2023

Deploy Preview for unocss ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 4f03ce5
🔍 Latest deploy log https://app.netlify.com/sites/unocss/deploys/64fd813312fefd0009c62db4
😎 Deploy Preview https://deploy-preview-3100--unocss.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@userquin
Copy link
Member

userquin commented Sep 10, 2023

@Dunqing testing PR on my Windows laptop...

EDIT: since UnoCSS dependencies are linked we need to include vite.server.fs.strict = false in the example Astro config file: I'm getting 403 when resolving astro hmr JS module:

imagen

@userquin
Copy link
Member

@Dunqing still getting page reload:

imagen

@Dunqing
Copy link
Member Author

Dunqing commented Sep 10, 2023

@Dunqing still getting page reload:

Yes, I am not sure page reload In astro is expected. Can you use vite plugin to test it?

@Dunqing
Copy link
Member Author

Dunqing commented Sep 10, 2023

@Dunqing testing PR on my Windows laptop...

EDIT: since UnoCSS dependencies are linked we need to include vite.server.fs.strict = false in the example Astro config file: I'm getting 403 when resolving astro hmr JS module:

imagen

I tested it in this example, but I am not receiving any error. And looks like the error has nothing to do with the astro integration

@userquin
Copy link
Member

I have this on the Astro config file:

imagen

@userquin
Copy link
Member

@Dunqing adding the vite-plugin-inspect:

This is weird in SSR, there are a few /__uno.css virtual modules, one resolving to /__uno.css and another to the full path:

imagen

imagen

Then in the client, we have also 2 __uno.css (is there a missmatch? the HMR context is for /__uno.css and the virtual id for update, check also that id is resolved twice or 3 times):

imagen

imagen

@Dunqing
Copy link
Member Author

Dunqing commented Sep 10, 2023

@Dunqing adding the vite-plugin-inspect:

This is weird in SSR, there are a few /__uno.css virtual modules, one resolving to /__uno.css and another to the full path:

This full path is to align data-astro-dev-id and data-vite-dev-id.

You can look here

if (RESOLVED_ID_RE.test(id)) {
// https://github.com/withastro/astro/blob/087270c61fd5c91ddd37db5c8fd93a8a0ef41f94/packages/astro/src/core/util.ts#L91-L93
// Align data-astro-dev-id with data-vite-dev-id to fix https://github.com/unocss/unocss/issues/2513
return this.resolve(join(root, id), importer, { skipSelf: true })
}

This is strange, and we may need to return the full /__uno.css path in the vite plugin to solve the problem of resolving it twice!

@Dunqing
Copy link
Member Author

Dunqing commented Sep 10, 2023

If this PR does solve the problem of Windows hmr not working, I think it would be a good idea to merge this PR first to avoid Windows users not being able to use it for a long time. What do you think? @userquin

@Dunqing Dunqing added this pull request to the merge queue Sep 11, 2023
Merged via the queue into unocss:main with commit 332d61e Sep 11, 2023
10 checks passed
@Dunqing Dunqing deleted the fix/astro/hmr-not-work-windows branch September 11, 2023 00:35
@Dunqing
Copy link
Member Author

Dunqing commented Sep 13, 2023

Unocss doesn't work if it put it in the astro integration it only works when a put it as a vite plugin

Did you test it at this PR? The latest version does not include this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HMR with Astro + Uno
3 participants