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

cannot find index.ts in production #83

Closed
2 tasks done
stregouet opened this issue Jun 30, 2022 · 1 comment
Closed
2 tasks done

cannot find index.ts in production #83

stregouet opened this issue Jun 30, 2022 · 1 comment

Comments

@stregouet
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

3.29.0

Plugin version

3.0.0-beta.23

Node.js version

16.15.0

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

archlinux

Description

hi,

I'm using fastify-vite with typescript, and after building for production (with command vite build --outDir dist/server --ssr /index.ts) I get the following error:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/me/mon-app/client/dist/server/index.ts' imported from /home/me/mon-app/node_modules/.pnpm/fastify-vite@3.0.0-beta.23/node_modules/fastify-vite/mode/production.js

To fix it I made a quick and dirty fix in mode/production.js

@@ -49,7 +49,7 @@
 
   // Loads the Vite application server entry point for the client
   async function loadClient () {
-    const serverFile = join('server', basename(config.clientModule))
+    const serverFile = join('server', basename(config.clientModule).replace('.ts', '.js'))
     const serverBundle = await import(resolve(config.bundle.dir, serverFile))
     return serverBundle.default ?? serverBundle
   }

maybe I miss some configuration step.

Steps to Reproduce

to reproduce use any example and rename client/index.js to client/index.ts then run

vite build --outDir dist/server --ssr /index.ts

Expected Behavior

No response

@stregouet
Copy link
Author

fixed in 4efd884
thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant