GithubHelp home page GithubHelp logo

Comments (9)

robipop22 avatar robipop22 commented on June 4, 2024 3

Well that was fun to debug, but in the end I found it. I'm going to leave here my findings in case someone else comes across this.

I had a .ts route that was handling a POST and GET so it was exposing an action and loader.
But inside my action function I was calling a function (let's call it myFunction )
And myFunction was doing in the end something like :
return json({})

It seems that since the function was inside the same file it got treated like client code.

By moving myFunction to another file called myFunction.server.ts and importing it into my route with the action it all got treated on the server and the build is working now.

I tried to explain it the best I could. I'll close this. Thanks @TooTallNate for the quick response.

from remix.

TooTallNate avatar TooTallNate commented on June 4, 2024 1

Ya that makes sense. Nice explanation 👍

from remix.

TooTallNate avatar TooTallNate commented on June 4, 2024

What is the full error you are seeing? Can you share your code?

from remix.

robipop22 avatar robipop22 commented on June 4, 2024

`Error: [commonjs--resolver] Server-only module referenced by client

'./entry.server.js' imported by 'node_modules/@vercel/remix/dist/edge/index.js'

See https://remix.run/docs/en/main/future/vite#splitting-up-client-and-server-code

file: ../node_modules/@vercel/remix/dist/edge/index.js`

Happy to share any code that you think is helpful, or jump on a discord call or something similar.

from remix.

TooTallNate avatar TooTallNate commented on June 4, 2024

If you can share the code that would be the most helpful. Also note that entry.server is a special file name in Remix, so if you are trying to import it within one of your routes then it's probably improper usage.

from remix.

robipop22 avatar robipop22 commented on June 4, 2024

I'm using the defaults entry files. I deleted them so I make sure they won't interfere.

Tried a lot of workarounds, different vite configs.
different package managers.

Fails with the same node modules error everytime

from remix.

TooTallNate avatar TooTallNate commented on June 4, 2024

I mean, it's something in your app code. It's not related to Vite config nor package manager nor even Vercel. You can try working backwards from the starter template which does not exhibit this error. I'd be happy to help diagnose further if you want to share a reproduction.

from remix.

robipop22 avatar robipop22 commented on June 4, 2024

Feels like it, deleted the whole routes files then it failed again, then commented this file
../node_modules/@remix-run/dev/dist/config/defaults/entry.client.tsx
it worked after, so it seems that one of the route might be at fault. trying to find out which one

from remix.

clayton-kenney avatar clayton-kenney commented on June 4, 2024

@robipop22 thanks for documenting this.
Ran into this as well with some helper functions, and was just about to give up.

from remix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.