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

Application files are not built when AppConfig.server is set in remix.config.js #8526

Closed
gregory-j-baker opened this issue Jan 16, 2024 · 3 comments

Comments

@gregory-j-baker
Copy link

gregory-j-baker commented Jan 16, 2024

Reproduction

https://stackblitz.com/edit/remix-run-remix-zwfcbj

  1. Run npm run-script build

Files of interest: remix.config.js and server.ts

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.14.0 - /usr/local/bin/pnpm
  npmPackages:
    @remix-run/css-bundle: ^2.5.0 => 2.5.0 
    @remix-run/dev: ^2.5.0 => 2.5.0 
    @remix-run/express: ^2.5.0 => 2.5.0 
    @remix-run/node: ^2.5.0 => 2.5.0 
    @remix-run/react: ^2.5.0 => 2.5.0 

Used Package Manager

npm

Expected Behavior

According to these docs re AppConfig.server:

server
A server entrypoint, relative to the root directory that becomes your server's main module. If specified, Remix will compile this file along with your application into a single file to be deployed to your server. This file can use either a .js or .ts file extension.

Actual Behavior

When I look in my build/ directory, I only see a single server.js file with no application files, so my application doesn't work.

@pcattori
Copy link
Contributor

pcattori commented Jan 19, 2024

The server field in remix.config.js was designed to ease single-file deploys for tools like wrangler. It looks like you are instead using it to compile your server.ts to JS. Instead of using the server field to do this, you should use a tool like tsx or node --loader tsm to run your TS server.

Additionally, you are using a custom server so you should be using the -c flag for remix dev and running your custom server directly in start script: tsx ./server.ts

Here's your example with a couple changes to remix.config.js, package.json, and server.ts to get it all working: https://stackblitz.com/edit/remix-run-remix-oxtxcj?file=remix.config.js

@gregory-j-baker
Copy link
Author

Thanks @pcattori, that's exactly what I did, and I acknowledge there are numerous examples available for custom servers.

Perhaps the docs can be amended to add another sentence explaining that the server field in remix.config.js is not meant for a custom server.?s file. I showed the docs to a couple of colleagues and neither of them suggested that the server config setting was for tools like wrangler, so I feel like my confusion was somewhat justified.

@pcattori
Copy link
Contributor

We're reworking how our integration with CF works (see #8531) and this will no longer be an issue since with the Remix Vite plugin there is no server field for the Remix config.

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

No branches or pull requests

3 participants