TrueCar / gluestick

GlueStick is a command line interface for quickly developing universal web applications using React and Redux.
MIT License
361 stars 43 forks source link

SSR middleware #560

Closed zamotany closed 7 years ago

zamotany commented 7 years ago

The task involve refactoring/writing middleware for server side rendering. Middleware will be used in: src/renderer/index.js. The first set will be to make MVP and ensure everything works (webpack configs) as expected. Then progressively add new stuff to it, since we need that ASAP, not to block other issues. The old middlewere is located in src/lib/srerver/expresss-middleware.js, it would be a good idea to investigate that first and maybe use it as a base. Lot of code from it, is now deprecated and should not be expected to work in v2. To make development easier use watch command from gluestick-cli that will copy files from gluestick development version to gluestick dependency inside project's node_modules then webpack will detect change and rebuild server bundle. Files for new middleware should be created inside src/renderer not in src/lib.

zamotany commented 7 years ago

We should decide what structure of generated project should look like. @dratwas suggested:

src
│   Index.js
└───config
│   │   entries.js
│   │   ...
└───entries
    │   home.js
    │   ...

I suggest:

gluestick/ // here we have some gluestick kind of 'internal' but customizable stuff
src/
|   Index.js // entry components should live at top level in src
|   entries.js // file when with entrypoint definition also
|---actions/
|---components/
|---config/ // files in this folder specifies how gluestick should behave, no business logic here
|---containers/
|---reducers/
|---routes/ // define routes for bundles here

I someone is wondering why we need to change strucure is that we can't define entrypoints inside webpack-additions anymore due to the way how universal-webpack works and how we handle SSR stuff.

What do you think?? @mike866 @ferrannp and others

toddw commented 7 years ago

How crazy would it be if we moved toward a structure more like Django or Elixir Umbrella projects? https://elixirschool.com/lessons/advanced/umbrella-projects/

gluestick/
src/
|---config
|---shared/
|---components/
|---containers/
|---actions/
|---reducers/
|---apps/
|------appName1/
|---------Index.js
|---------routes.js
|---------components/
|---------containers/
|---------reducers/
|---------actions/
|------appName2/
|---------Index.js
|---------routes.js
|---------components/
|---------containers/
|---------reducers/
|---------actions/

I realize this would be a really big change but I do think it is worth discussing.

In this proposal I'm not sure I love how the shared folder works but I do think we should have a place where shared code between apps would live.

This proposal might make the entire concept of "entrypoints" easier to understand.