I would like to create a clean archtecture for my JavaScript project. The project consists of one Node.js server and two separate Angular.js front-ends with different purposes. For building the front-ends I use a custom grunt build each. The build results in one single HTML file per project and two minified/uglified CSS and JavaScript files. Each front-end is then running on a separate minimal version of a Node server (serves only the static files).
So far, so clear. The goal is now to make it possible to add plugin modules to each one of the three core projects. A module should extend the JavaScript of either one of the projects. This means e.g. in case of one front-end to add an additional angular module to the angular configuration. I already know where and how to add the angular module code into the core app.
The problem is now: How do you create a reasonable build process over multiple projects which is also depending on plugin modules? I came up with two solutions.
- I could add a plugin as an NPM dependency to one of the core projects. This has however the drawback, that every change in the module needs to be pushed to NPM and it is not very convenient to develop the plugin module like this. A plugin is not runnable on its own.
- I could have a list of plugins inside the Gruntfile of one of the core projects. This list would contain local file paths to the modules. In the build of the core module, the builds of the plugins will be executed. This would however include to watch changes of the built files of the plugins. It is an unclean solution.
- I could have another project which contains dependencies to the core project and all the plugins and builds it all together. The question of how to add the dependency remains (case 1 or 2)
How would you solve that problem?
"some-local-package": "file:./to/the/pkg/dir"
if I'm not mistaken. This way your local changes can be included but for a production / ci build you would need to publish those changes to whatever registry you are using. – Neela