jsheroes/community-help

brain picking about react architecture

paulbrie opened this issue ยท 7 comments

Since many smart Clujsers answered my previous question I decided to pick your brains once more. :) - I love this community! ๐Ÿ˜„

I'm working on a big React application. Users with different roles and rights can interact with the application. In an ideal world I would like to have one single code base with all the features that any user can access - so that the dev team can easily test any scenario -, but I also would like for my production that each user loads a bundle that contains features designed for his rights level only.

For example, a non-logged user will have a bundle that only contains enough code so that the user can login only. In case of success he will be redirected to the "logged" url where he will receive a new specific bundle.

Has any of you done something similar?

Thanks,
Paul

Webpack has something similar, you can include/exclude folders to bundle into the final JS, then you can have a folder structure based on user roles, but your codebase has to be very modular for this to work correctly.

Without upfront strict specs you will have a bunch of errors imho.

Or maybe Yeoman is a good candidate for this....

So user specific features can be achieved quite easily if you can manage to build them as micro-services, or something similar to that; you would then build a mediator to package those specific features (and maybe some core dependencies). Yeoman, webpack, gulp dare I say shell scripts... which can easily be called by a nodejs child process and then the result bundled with the page that's served to the user.

The only potential problem I see with this is latency. Serving the user a custom packaged file would be slower than serving the entire packaged app. Automatically building those files for all existing roles might be easier (you do that on deploy and every time you change the features assigned to a role);

The only potential problem I see with this is latency.

You need to prebuild those bundles... it's not very smart to bundle it on-the-fly

How is it going with this issue @paulbrie ? Did you find any viable solutions?

closing for lack of activity