Skip to content

Commit

Permalink
chore: do not error on failed load
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 23, 2021
1 parent 8693c36 commit c30f6d7
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/vite/src/node/server/transformRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,16 @@ export async function transformRequest(
}
}
if (code == null) {
const msg = checkPublicFile(url, root)
? `This file is in /public and will be copied as-is during build without ` +
`going through the plugin transforms, and therefore should not be ` +
`imported from source code. It can only be referenced via HTML tags.`
: `Does the file exist?`
throw new Error(`Failed to load url ${url} (resolved id: ${id}). ${msg}`)
if (checkPublicFile(url, root)) {
throw new Error(
`Failed to load url ${url} (resolved id: ${id}). ` +
`This file is in /public and will be copied as-is during build without ` +
`going through the plugin transforms, and therefore should not be ` +
`imported from source code. It can only be referenced via HTML tags.`
)
} else {
return null
}
}

// ensure module in graph after successful load
Expand Down

0 comments on commit c30f6d7

Please sign in to comment.