faceyspacey/redux-first-router-demo

Sharing code between client and server

chapati23 opened this issue · 1 comments

Hey :)
wanted to pick your brain on something. Any opinion on good ways to share code between client and server using this approach?

My use case is this:

I have a form i want to validate on the client (better UX 😺) as well as on the server (more secure 🔒). I already extracted my validations into a validations.js but the server obviously can't reach into the client code (under src/pages/FormPage/validations.js). In dev-mode that works, thanks to webpack i guess. But in prod-mode, with everything transpiled this fails naturally.

My only idea so far was to create another directory at /build/shared or something but I'm a little unclear whether that would actually resolve this issue or just open up another one.

Any thoughts?

shared modules is perfectly valid. only modules actually imported get bundled into either build. share as much code as possible between both builds.