Skip to content

Commit 71d0797

Browse files
authored
refactor!: remove import.meta.hot.accept resolution fallback (#21382)
1 parent 30f48df commit 71d0797

2 files changed

Lines changed: 6 additions & 18 deletions

File tree

docs/guide/migration.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ The following options are deprecated and will be removed in the future:
340340

341341
## Removed Deprecated Features [<Badge text="NRV" type="warning" />](#migration-from-v7)
342342

343+
- Passing an URL to `import.meta.hot.accept` is no longer supported. Please pass an id instead. ([#21382](https://github.com/vitejs/vite/pull/21382))
344+
343345
**_TODO: This change is not implemented yet, but will be implemented before stable release._**
344346

345347
## Advanced

packages/vite/src/node/plugins/importAnalysis.ts

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,6 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
318318
const importedBindings = enablePartialAccept
319319
? new Map<string, Set<string>>()
320320
: null
321-
const toAbsoluteUrl = (url: string) =>
322-
path.posix.resolve(path.posix.dirname(importerModule.url), url)
323321

324322
const normalizeUrl = async (
325323
url: string,
@@ -788,22 +786,10 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
788786
}
789787
normalized = mod.url
790788
} else {
791-
try {
792-
// this fallback is for backward compat and will be removed in Vite 7
793-
const [resolved] = await moduleGraph.resolveUrl(toAbsoluteUrl(url))
794-
normalized = resolved
795-
if (resolved) {
796-
this.warn({
797-
message:
798-
`Failed to resolve ${JSON.stringify(url)} from ${importer}.` +
799-
' An id should be written. Did you pass a URL?',
800-
pos: start,
801-
})
802-
}
803-
} catch {
804-
this.error(`Failed to resolve ${JSON.stringify(url)}`, start)
805-
return
806-
}
789+
this.error({
790+
message: `Failed to resolve ${JSON.stringify(url)} from ${importer}.`,
791+
pos: start,
792+
})
807793
}
808794
normalizedAcceptedUrls.add(normalized)
809795
const hmrAccept = normalizeHmrUrl(normalized)

0 commit comments

Comments
 (0)