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: always transform applicable requests #2041

Merged
merged 1 commit into from
Feb 15, 2021

Conversation

Rich-Harris
Copy link
Contributor

As shown in https://github.com/Rich-Harris/vite-repro-transformation, Vite only transforms files when they are imported, and not requested any other way, because transformMiddleware has the following check:

req.headers.accept?.includes('text/html')

This line was removed in #1496 so that it's possible to view transformed files in a new tab, but that change was reverted in 64fde38 due to #1507. I'm not sure what's happening in #1507 but it feels like the accept check might be masking the real issue?

The current behaviour does cause problems — as alluded to in #1496, it makes debugging harder, but it also means that you can't (for the example that motivated this PR) inject a <link> in SSR'd content that contains a stylesheet that was imported by a module loaded with ssrLoadModule.

More broadly, I'd argue it makes things less predictable. Unless there's a rationale for the current behaviour that I'm missing?

@yyx990803 yyx990803 merged commit 4fd61ab into vitejs:main Feb 15, 2021
@Rich-Harris Rich-Harris deleted the always-transform-requests branch February 15, 2021 21:11
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.

2 participants