Currently, I am working on a project that involves a separate frontend (webpack) and backend (express/mongodb). My goal is to separate the dependencies in the package.json
file while still being able to share certain logic/utility code between them. How can I restructure my files in such a way that allows for proper separation of dependencies?
At present, both the frontend and backend components share the same node_modules
directory.
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
If it were not for the necessity of the lib directory being shared by both projects, I could easily split them into two separate npm projects. However, this would lead to duplicating the code in each folder. Is there a more efficient approach to achieving this separation?