I'm working on a set of projects sitting on GitHub and I want to share the Gulp build pipeline between these. Everything uses Babel, including the Gulp tasks themselves. The common Gulpfile I want to share requires Babel and then all the tasks sitting in a folder - the common file looks like this:
require("babel-core/register");
require("require-dir")("gulp/tasks");
I then tried to package the common pipeline into an NPM package and add it as a devDependency to the other project. Then my gulpfile for the project depending on the common setup looks like this:
require("./node_modules/cratis.client.javascript.setup/gulpfile");
When I run this it seems to load Babel and then starts loading my tasks, but fails immediataly with:
(function (exports, require, module, __filename, __dirname) { import gulp from "gulp";
^^^^^^
SyntaxError: Unexpected token import
at Object.exports.runInThisContext (vm.js:53:16)
Which would indicate Babel didn't load, which I find weird - as I would then expect to see a load error related to the first require.
Couldn't really figure out anything about what was going on here, so I decided to try a different path; Git sub modules. I added the common pipeline project as a Git sub module to the project and included the gulpfile relative to the location of the sub module. This does not seem to work at all - basically not finding files.
What are others doing? I haven't really found any good examples.
If the Git sub module path is the right way, I'd like to see that "node_modules" are shared as well and an easy way to maintain it.