Skip to content

Commit

Permalink
fix: stricter html fallback check in transformRequest
Browse files Browse the repository at this point in the history
ref #2051
  • Loading branch information
yyx990803 committed Feb 18, 2021
1 parent cb83b95 commit d0eac2f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/vite/src/node/server/transformRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ export async function transformRequest(
const loadStart = isDebug ? Date.now() : 0
const loadResult = await pluginContainer.load(id, ssr)
if (loadResult == null) {
// if this is an html request and there is no load result, skip ahead to
// SPA fallback.
if (options.html && !id.endsWith('.html')) {
return null
}
// try fallback loading it from fs as string
// if the file is a binary, there should be a plugin that already loaded it
// as string
try {
code = await fs.readFile(file, 'utf-8')
isDebug && debugLoad(`${timeFrom(loadStart)} [fs] ${prettyUrl}`)
} catch (e) {
// if this is an html request and there is no load result, skip ahead to
// SPA fallback.
if (options.html) {
return null
}
if (e.code !== 'ENOENT') {
throw e
}
Expand Down

0 comments on commit d0eac2f

Please sign in to comment.