I have a project with a separate interface (webpack) and backend (express / mongodb), which I would like to split into package.json, while I was going to share some logic / utility code between them. How can I organize my file structure so that I can appropriately separate their dependencies.
Right now this is my file structure, in which both frontend and backend use the same node_modules
app
|
| - frontend
| | - index.js
| | - src
|
| - backend
| | - index.js
| | - models
| | - api
| | - statics (webpack builds into here)
|
| - lib
| | - logic here (may require npm dependency)
|
|- package.json
|- webpack.config.js
I could easily split them into 2 npm projects if they both do not require the lib directory, but this essentially means that I have to copy the code to both folders. Is there a better way to achieve this?