Skip to content

Commit

Permalink
fix: use file urls for esm (mcansh#342)
Browse files Browse the repository at this point in the history
* Use file urls for esm

Fixed mcansh#341

* Update packages/remix-fastify/src/plugin.ts

Co-authored-by: Logan McAnsh <[email protected]>
Signed-off-by: Marc <[email protected]>

* Update packages/remix-fastify/src/plugin.ts

Co-authored-by: Logan McAnsh <[email protected]>
Signed-off-by: Marc <[email protected]>

* Update plugin.ts

Signed-off-by: Logan McAnsh <[email protected]>

* Create small-points-teach.md

Signed-off-by: Logan McAnsh <[email protected]>

* Update plugin.ts

Signed-off-by: Logan McAnsh <[email protected]>

---------

Signed-off-by: Marc <[email protected]>
Signed-off-by: Logan McAnsh <[email protected]>
Co-authored-by: Logan McAnsh <[email protected]>
  • Loading branch information
VIEWVIEWVIEW and mcansh committed Jun 13, 2024
1 parent 75e1d0c commit 4d59e01
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
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

0 comments on commit 4d59e01

Please sign in to comment.