Server-only paths config #3451
nakleiderer
started this conversation in
Proposals
Replies: 1 comment
-
I created a patch that adds support for server folders. Just append |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Remix's automatic server vs. client code-splitting is amazing. However, when learning Remix it can be a bit of a foot gun. New and experienced devs might end up accidentally shipping server-only code to the client. Depending on the code, it might not cause an error in development and may potentially leak information about business logic, database structures, or other information that's best kept secret.
The
.server.ts
file extension is a great way to prevent code getting to the client, but it's a bit verbose to sprinkle everywhere. It would be convenient to be able to mark server-only modules in bulk.Proposals:
Here's a few ways Remix could help:
.server
will signal that all files contained inside should be ignored. ie./app/models.server/user.ts
remix.config.js
. Maybe a glob of files could be marked as server only. ie:{ serverOnlyPaths: ["app/models/**", "app/sensitive-stuff/**"] }
Possible Workarounds:
index.server.ts
file in the folder intended for server-only use and re-export any subfiles. Make sure to only use theindex.server
in imports. This has similar problems because the sub-modules can still be directly imported, but maybe a linting rule could be made to enforce with for a team.Thanks to @kiliman for helping me think this through in Discord.
Beta Was this translation helpful? Give feedback.
All reactions