npmmodular-design

Modular cross project design / Create re-usable extensible base


Context:

We're creating a new solution consisting of multiple app portals (for lack of a better term), each portal will need to leverage off of a base project that will already include some of my employed proprietary code, as well as any new features pertaining to that portal. Our current app leaves much to be desired, and as we're getting a fresh start, we'd like to go at it the right way. (Thus I'd like to rubberduck my thoughts somewhat)

enter image description here

enter image description here

I've thought of a few possible ways to solve this. Each with it's pro' and cons.

1. GIT Fork A Base Project:

This seems like the most straight forward way. Have a PortalCore project, then have each project fork it in a downstream only fashion.

The flow would be:

Fork PortalCore > Core will be kept up to date via updating via GIT master

2. Base Project NPM Package:

This seems like an ideal route, as with each deployment the latest version of our base package/project will be installed with each portal.

The flow would be:

New Project > Add Portal Core npm > Make custom build task, or grab from some central repo > Will be kept up to date via npm install > Gulp Build

3. Combination of the above

Have a git project only containing our base npm modules, & build config. The build can then handle things like moving files to the right location (example. node_modles -> root)

The flow would be:

Fork PortalCore > Core will be kept up to date via npm install > Gulp Build


Questions:

  1. Is there a way to have an npm package (or another package manager) install files to a specific location? (I have checked the npm forum, and this seems like a dead end. But I thought I'd try my luck here)
  2. Are we frankensteining it? We don't want to create a new monster. Does this logic make sense ITO creating something that should be somewhat modular by design, but allows for easier maintenance. How do the big boys do this... if they do this?

Solution

  • The answer to this ended up being much simpler than I expected: