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

import { routes } from "~/routes" causes client-side error #10227

Open
gregory-j-baker opened this issue Nov 14, 2024 · 1 comment
Open

import { routes } from "~/routes" causes client-side error #10227

gregory-j-baker opened this issue Nov 14, 2024 · 1 comment

Comments

@gregory-j-baker
Copy link

gregory-j-baker commented Nov 14, 2024

Reproduction

  1. Clone https://github.com/gregory-j-baker/remix-route-config-error and run
  2. Open browser devtools and navigate to http://localhost:5173/
  3. Observe the error:
    polyfills.js:3 Uncaught ReferenceError: process is not defined
        at node_modules/graceful-fs/polyfills.js (polyfills.js:3:15)
        at __require2 (chunk-RJLA2AWL.js?v=e39b33cd:21:50)
        at node_modules/graceful-fs/graceful-fs.js (graceful-fs.js:2:17)
        at __require2 (chunk-RJLA2AWL.js?v=e39b33cd:21:50)
        at node_modules/fs-extra/lib/fs/index.js (index.js:5:12)
        at __require2 (chunk-RJLA2AWL.js?v=e39b33cd:21:50)
        at node_modules/fs-extra/lib/index.js (index.js:5:6)
        at __require2 (chunk-RJLA2AWL.js?v=e39b33cd:21:50)
        at node_modules/@remix-run/dev/dist/cli/commands.js (@remix-run_route-config.js:89228:15)
        at __require2 (chunk-RJLA2AWL.js?v=e39b33cd:21:50)
    

The problematic file is app/routes/_index.tsx (the import at the top).

System Info

System:
    OS: Linux 6.11 Fedora Linux 41 (Workstation Edition)
    CPU: (8) x64 Intel(R) Core(TM) i5-10310U CPU @ 1.70GHz
    Memory: 2.49 GB / 15.29 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 22.11.0 - /usr/bin/node
    Yarn: 1.22.22 - /usr/bin/yarn
    npm: 10.9.0 - /usr/bin/npm
    pnpm: 9.0.6 - /usr/bin/pnpm
  npmPackages:
    @remix-run/dev: ^2.14.0 => 2.14.0 
    @remix-run/node: ^2.14.0 => 2.14.0 
    @remix-run/react: ^2.14.0 => 2.14.0 
    @remix-run/route-config: ^2.14.0 => 2.14.0 
    @remix-run/serve: ^2.14.0 => 2.14.0 
    vite: ^5.1.0 => 5.4.11

Used Package Manager

npm

Expected Behavior

I need to be able to import { routes } from "~/routes" so I can iterate over the routes and find specific routes by their IDs.

I do this because my application has multilingual URLs and I need to use the route ID to find the correct path to render when generating links.

Actual Behavior

import { routes } from "~/routes" doesn't work client-side because of an error in the graceful-fs module.

@gregory-j-baker
Copy link
Author

Not sure if it's relevant, but I have a small RR7-pre.5 proof-of-concept application that does the same thing and it doesn't have this error.

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

1 participant