Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support named exports in mjs files #2634

Closed
perrin4869 opened this issue Sep 25, 2021 · 5 comments · Fixed by #2760
Closed

Support named exports in mjs files #2634

perrin4869 opened this issue Sep 25, 2021 · 5 comments · Fixed by #2760
Projects

Comments

@perrin4869
Copy link

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?

@phated
Copy link
Member

phated commented Sep 25, 2021

Tangentially related to gulpjs/rechoir#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.

@phated phated added this to Nice to Have in v5 Oct 24, 2021
@noraj
Copy link

noraj commented Jul 20, 2022

My workaround for gulpfile.mjs

import gulp from 'gulp';
const { series, parallel, src, dest, task } = gulp;

@perrin4869
Copy link
Author

Well of course that's the way to get this done for now.
Actually, this is trivially easy to add using the technique: gulpjs/vinyl#152
Without a whole ESM rewrite...

@Haringat
Copy link

@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.

@gulpjs gulpjs deleted a comment Mar 19, 2024
@gulpjs gulpjs deleted a comment Mar 19, 2024
@phated phated moved this from Nice to Have to To do in v5 Mar 23, 2024
@phated
Copy link
Member

phated commented Mar 25, 2024

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.

@phated phated moved this from To do to In progress in v5 Mar 25, 2024
v5 automation moved this from In progress to Done Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
v5
  
Done
Development

Successfully merging a pull request may close this issue.

4 participants