gulp
gulp copied to clipboard
Support named exports in mjs files
Using gulpfile.esm
I can do:
import { src, dest, series, parallel } from "gulp";
When using gulpfile.mjs
, this doesn't work because doesn't officially export the properties src
, dest
, etc.
Was wondering if there is any interest to support this, maybe in v5?
Tangentially related to https://github.com/gulpjs/rechoir/issues/43 - the idea is that our rechoir
library needs to be updated to support mjs files otherwise we need to rely on the transpiled export format.
My workaround for gulpfile.mjs
import gulp from 'gulp';
const { series, parallel, src, dest, task } = gulp;
Well of course that's the way to get this done for now. Actually, this is trivially easy to add using the technique: https://github.com/gulpjs/vinyl/pull/152 Without a whole ESM rewrite...
@phated Node supports having different entrypoints for import and require. Thus you could have an index.mjs for import and an index.cjs for require (backward compatibility). See https://nodejs.org/dist/latest-v19.x/docs/api/packages.html#package-entry-points for reference.
I've added this in #2760 but I have an outstanding question on if something special needs to happen to support the bin
field. If someone has knowledge of this, please let me know so we can wrap this up.