I’m using Gulp 5, and I converted my Gulpfile to use modules instead of CommonJS. It mostly works but I’m having trouble with the merge-stream
package. Here’s the minimal version of my original code:
const mergeStream = require('merge-stream');
function js() {
let stream1 = src('example.js');
let stream2 = src([/* multiple files */])
.pipe(concat('global.js'));
return mergeStream(stream1, stream2)
.pipe(terser())
.pipe(rev())
.pipe(dest(jsPath))
.pipe(rev.manifest('rev-manifest.json'))
.pipe(dest(jsPath));
}
exports.js = js;
I converted it to use modules like so:
import mergeStream from 'merge-stream';
// same js() function as above
export {js};
It should output example-abc123.js
and global-def456.js
files, and a rev-manifest.json
file listing both of those. The build runs without errors, but only the first file is processed (example.js). So it doesn’t appear to be merging the streams.
I’ve also tried doing this which I saw in another question, but it’s no different:
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const mergeStream = require('merge-stream');