create-mern-ts-app icon indicating copy to clipboard operation
create-mern-ts-app copied to clipboard

how to keep as a framework within other apps?

Open dcsan opened this issue 5 years ago • 3 comments

hi - so quite like this "boilerplate" as it's shaping up as a basis for a few projects, but wondering if you had any thoughts how to keep the "framework" separate from apps?

I would ideally like to keep the app framework as a separate repo and keep improving it over time, but still use it as the basis for a few different apps.

that's really hard with generators but may work with some other structuring...

i think the server side might be possible, using something like a git submodule for the project, and then putting a number of components into an 'app' directory... and registering them at startup?

but not sure how the client could be extended.

dcsan avatar Jun 30 '19 06:06 dcsan

@dcsan you mean keeping frontend and backend in separate repos? If that's the case you can simply create two separate repos for the server and the client and maintain them separately, it should be easy enough. This repo here uses a monorepo approach.

Fabianopb avatar Jul 01 '19 18:07 Fabianopb

no, I meant more when building on top of this as a framework, but being able to push any changes made to the framework while working on an app back "upstream" to the framework repo.

I guess that wasn't your intention as you've built it more as a one-way generator. but for example if there was a way to keep this whole app as a git subrepo, or to develop your app within a subrepo, and just have one register call from the main app to any routes or projects below.

for example

/tern
  main.ts
  /utils/

  /app
    /modules
       /cats
       /dogs

main.ts would remain part of tern (ts-mern framework) /utils is part of the tern stack and new stuff / improvements can be added here.

tern might have a method register that would be called from your app

/app is where your app goes any routes here would call Tern.register('/app/dogs', handler)

so I think this would be possible for server stuff, but the way the skeleton is split as

/frontend
/backend

make it pretty hard to do more. you need a top level separation between front and back so more like:

/tern
  /front
  /back

/app
  /front
  /back

and some way to wire them together.

I'm not sure how much you really would need "client side" for a framework, except for demo pages to show how to wire things together, share types etc. maybe out of the box auth and material-ui is nice to get going quickly, some of that is just examples.

another way is like an Inversion of control approach and plug the Tern app/framework inside the /app folder as a gitsubrepo... it's the opposite of how i usually think though it makes sense as a library/driver for your app...

dcsan avatar Jul 01 '19 22:07 dcsan

Oh I see, this is what create-react-app does, they provide a generator which is upgradable. So whenever they release new improvements you can upgrade your application to use those latest improvements.

That is possible because they have split this upgradable configuration to a subpackage in the repo (managed with lerna) so the configuration is "hidden" within the node modules. An example of that is the webpack config of create-react-app, which is hidden within react-scripts (the subpackage) in the node modules.

So I think you're looking for that kind of approach. I've actually decided to keep it simple here at first and in fact I'm using create-react-app in this generator's frontend.

Fabianopb avatar Jul 02 '19 06:07 Fabianopb