Skip to content

Commit

Permalink
fix(vite): fix errors for non-existent index.html importer (#8353)
Browse files Browse the repository at this point in the history
  • Loading branch information
pcattori authored Dec 21, 2023
1 parent 6adaee8 commit 66adc8f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/curly-coats-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@remix-run/dev": patch
---

Vite: Fix errors for non-existent `index.html` importer

8 changes: 7 additions & 1 deletion packages/remix-dev/vite/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,13 @@ export const remixVitePlugin: RemixVitePlugin = (options = {}) => {
serverFileRE.test(resolved!.id) || serverDirRE.test(resolved!.id);
if (!isDotServer) return;

if (!importer) throw Error(`Importer not found: ${id}`);
if (!importer) return;
if (viteCommand !== "build" && importer.endsWith(".html")) {
// Vite has a special `index.html` importer for `resolveId` within `transformRequest`
// https://github.com/vitejs/vite/blob/5684fcd8d27110d098b3e1c19d851f44251588f1/packages/vite/src/node/server/transformRequest.ts#L158
// https://github.com/vitejs/vite/blob/5684fcd8d27110d098b3e1c19d851f44251588f1/packages/vite/src/node/server/pluginContainer.ts#L668
return;
}

let vite = importViteEsmSync();
let pluginConfig = await resolvePluginConfig();
Expand Down

0 comments on commit 66adc8f

Please sign in to comment.