Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use file urls for esm #342

Merged
merged 7 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/small-points-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@mcansh/remix-fastify": patch
---

use file urls for esm for windows compatibility
6 changes: 4 additions & 2 deletions packages/remix-fastify/src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from "node:path";
import url from 'node:url';
import fp from "fastify-plugin";
import type { ViteDevServer } from "vite";
import fastifyStatic from "@fastify/static";
Expand Down Expand Up @@ -70,6 +71,7 @@ export let remixFastify = fp<RemixFastifyOptions>(
let resolvedBuildDirectory = path.resolve(cwd, buildDirectory);

let SERVER_BUILD = path.join(resolvedBuildDirectory, "server", "index.js");
let SERVER_BUILD_URL = url.pathToFileURL(SERVER_BUILD).href;

// handle asset requests
if (vite) {
Expand Down Expand Up @@ -120,8 +122,8 @@ export let remixFastify = fp<RemixFastifyOptions>(
? () => {
if (!vite) throw new Error("we lost vite!");
return vite.ssrLoadModule("virtual:remix/server-build");
}
: () => import(SERVER_BUILD),
}
: () => import(SERVER_BUILD_URL),
});

return handler(request, reply);
Expand Down