remix-run / remix

Build Better Websites. Create modern, resilient user experiences with web fundamentals.
https://remix.run
MIT License
29.4k stars 2.48k forks source link

Deployment to Vercel causes a build panic when using manual route configuration #9431

Open peterje opened 4 months ago

peterje commented 4 months ago

Reproduction

A public repo is available at peterje/remix-manual-route-config which was created by:

npx create-remix@latest --template vercel/vercel/examples/remix

Then updating vite.config.ts to use manual route configuration:

import { vitePlugin as remix } from "@remix-run/dev";
import { installGlobals } from "@remix-run/node";
import { defineConfig } from "vite";
import { vercelPreset } from '@vercel/remix/vite';
import tsconfigPaths from "vite-tsconfig-paths";

installGlobals();

export default defineConfig({
  plugins: [
    remix({
      ignoredRouteFiles: ["*"],
      routes(defineRoutes) {
        return defineRoutes((route) => {
          route("/", "routes/_index.tsx");
          route("/edge", "routes/edge.tsx");
        })
      },
      presets: [vercelPreset()]
    }
    ), tsconfigPaths()],
});

System Info

System:
    OS: macOS 14.2
    CPU: (8) arm64 Apple M3
    Memory: 340.77 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.20.1 - ~/.config/cache/fnm_multishells/64362_1715117864875/bin/node
    Yarn: 1.22.22 - ~/.config/cache/fnm_multishells/64362_1715117864875/bin/yarn
    npm: 10.5.0 - ~/.config/cache/fnm_multishells/64362_1715117864875/bin/npm
    pnpm: 9.0.5 - ~/.config/cache/fnm_multishells/64362_1715117864875/bin/pnpm
    bun: 1.1.4 - ~/.bun/bin/bun
  Browsers:
    Chrome: 124.0.6367.201
    Safari: 17.2
  npmPackages:
    @remix-run/dev: ^2.9.2 => 2.9.2
    @remix-run/eslint-config: ^2.9.2 => 2.9.2
    @remix-run/node: ^2.9.2 => 2.9.2
    @remix-run/react: ^2.9.2 => 2.9.2
    @remix-run/server-runtime: ^2.9.2 => 2.9.2
    vite: ^5.1.0 => 5.2.11

Used Package Manager

npm

Expected Behavior

After updating the Vite config, the Vercel deployment should be identical to the filesystem routing deployment.

Actual Behavior

The Vercel builder panics and fails the deployment with the unhelpful message:

An unexpected error happened when running this build. We have been notified of the problem. If you have any questions, please contact Vercel Support https://vercel.com/help.

Full logs:

[13:48:51.693] Running build in Washington, D.C., USA (East) – iad1
[13:48:51.886] Retrieving list of deployment files...
[13:48:52.440] Downloading 10 deployment files...
[13:48:55.774] Restored build cache
[13:48:55.862] Running "vercel build"
[13:48:56.314] Vercel CLI 34.1.10
[13:48:57.032] Warning: Detected "engines": { "node": ">=18.0.0" } in your `package.json` that will automatically upgrade when a new major Node.js Version is released. Learn More: http://vercel.link/node-version
[13:48:57.042] Installing dependencies...
[13:48:58.947] 
[13:48:58.948] up to date in 1s
[13:48:58.948] 
[13:48:58.948] 255 packages are looking for funding
[13:48:58.948]   run `npm fund` for details
[13:48:58.964] Detected `package-lock.json` generated by npm 7+
[13:48:58.965] Running "npm run build"
[13:48:59.213] 
[13:48:59.214] > build
[13:48:59.214] > remix vite:build
[13:48:59.215] 
[13:49:00.511] vite v5.2.11 building for production...
[13:49:00.561] transforming...
[13:49:02.044] ✓ 86 modules transformed.
[13:49:02.169] rendering chunks...
[13:49:02.256] computing gzip size...
[13:49:02.379] build/client/.vite/manifest.json                1.41 kB │ gzip:  0.35 kB
[13:49:02.383] build/client/assets/edge-asUEa6fM.js            0.28 kB │ gzip:  0.24 kB
[13:49:02.388] build/client/assets/_index-MPfO6gCD.js          0.76 kB │ gzip:  0.39 kB
[13:49:02.388] build/client/assets/root-DtjcHO0x.js            3.10 kB │ gzip:  1.59 kB
[13:49:02.390] build/client/assets/jsx-runtime-56DGgGmo.js     8.11 kB │ gzip:  3.05 kB
[13:49:02.391] build/client/assets/entry.client-BDSkmrgt.js   11.63 kB │ gzip:  4.09 kB
[13:49:02.391] build/client/assets/components-ULJOhd3c.js    224.04 kB │ gzip: 72.45 kB
[13:49:02.392] ✓ built in 1.84s
[13:49:02.561] vite v5.2.11 building SSR bundle for production...
[13:49:02.566] transforming...
[13:49:02.587] vite v5.2.11 building SSR bundle for production...
[13:49:02.591] transforming...
[13:49:02.655] ✓ 5 modules transformed.
[13:49:02.688] rendering chunks...
[13:49:02.698] ✓ 5 modules transformed.
[13:49:02.703] rendering chunks...
[13:49:02.709] build/server/edge-eyJydW50aW1lIjoiZWRnZSJ9/.vite/manifest.json  0.15 kB
[13:49:02.709] build/server/edge-eyJydW50aW1lIjoiZWRnZSJ9/index.js             3.74 kB
[13:49:02.711] build/server/nodejs-eyJydW50aW1lIjoibm9kZWpzIn0/.vite/manifest.json  0.15 kB
[13:49:02.711] build/server/nodejs-eyJydW50aW1lIjoibm9kZWpzIn0/index.js             4.54 kB
[13:49:02.713] ✓ built in 147ms
[13:49:02.713] ✓ built in 123ms
[13:49:06.448] Build Completed in /vercel/output [9s]
[13:49:06.575] Deploying outputs...
[13:49:07.164] An unexpected error happened when running this build. We have been notified of the problem. If you have any questions, please contact Vercel Support https://vercel.com/help.
[13:49:07.264] Injected preview comments middleware, you can disable this in your project settings.
[13:49:08.840] 
paterson1720 commented 4 months ago

Are you sure it is caused by the manual routing ? I deployed a project yesterday on Vercel using manual routing and it works perfectly. I even made a library out of the manual routing setup I came up with. @remix-breeze/router

brookslybrand commented 4 months ago

@peterje I just attempted this and it's working correctly

repo deployed site

Please let me know if you're still having trouble or if this is now working for you. I plan to close this issue in a few days unless there's a reproducible bug you can share