Skip to content

Commit

Permalink
fix: normalize away base in imported URLs (#5065)
Browse files Browse the repository at this point in the history
* fix: normalize away `base` in imported URLs

This fixes hot-reloading issues reported in #5063.

* Update importAnalysis.ts

Co-authored-by: Evan You <[email protected]>
  • Loading branch information
fwouts and yyx990803 authored Sep 24, 2021
1 parent 8b77a4f commit 9164da0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/vite/src/node/plugins/importAnalysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
str().prepend(importsString)
str().overwrite(expStart, endIndex, exp)
imports.forEach((url) => {
url = url.replace(base, '/')
importedUrls.add(url)
if (isEager) staticImportedUrls.add(url)
})
Expand Down Expand Up @@ -411,10 +412,11 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {

// record for HMR import chain analysis
// make sure to normalize away base
importedUrls.add(url)
const urlWithoutBase = url.replace(base, '/')
importedUrls.add(urlWithoutBase)
if (!isDynamicImport) {
// for pre-transforming
staticImportedUrls.add(url)
staticImportedUrls.add(urlWithoutBase)
}
} else if (!importer.startsWith(clientDir) && !ssr) {
// check @vite-ignore which suppresses dynamic import warning
Expand Down

0 comments on commit 9164da0

Please sign in to comment.