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

[Feature Request] Use gulp as ESM module #2445

Closed
eddyloewen opened this issue May 18, 2020 · 2 comments
Closed

[Feature Request] Use gulp as ESM module #2445

eddyloewen opened this issue May 18, 2020 · 2 comments

Comments

@eddyloewen
Copy link

What were you expecting to happen?

Run/Use gulp in a "type":"module" context

What actually happened?

Throws an error that require() of ES modules is not supported.

Please give us a sample of your gulpfile

import gulp from ‘gulp';

gulp.task(function () {

});

Terminal output / screenshots

require() of /../../gulpfile.js from /../../node_modules/gulp-cli/lib/versioned/^4.0.0/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.

Please provide the following information:

  • OS & version [e.g. MacOS Catalina 10.15.4]: MacOS Catalina 10.15.3
  • node version (run node -v): v14.2.0
  • npm version (run npm -v): 6.14.4
  • gulp version (run gulp -v): CLI: 3.9.1, local: 4.0.2

Additional information

I'm not sure if this is actually a bug report or rather a feature request since the ESM functionality is quite recent in nodejs. I know that I can use "import" statements by renaming the gulpfile.js to gulpfile.babel.js but I think it would be nice if it where possible to use imports natively now since node introduced the ESM functionality.

Is this something that would be possible with the current implementation of gulp?

@phated
Copy link
Member

phated commented May 19, 2020

Thanks for opening this report, but yeah, it falls under a feature request.

Unfortunately, this requires a massive rewrite of everything because only an esm module can import an esm module. We are tracking this work at gulpjs/interpret#65.

I'll keep this open but lock it so the discussion can happen over there.

@phated phated changed the title Use gulp as ESM module [Feature Request] Use gulp as ESM module May 19, 2020
@gulpjs gulpjs locked and limited conversation to collaborators May 19, 2020
@gulpjs gulpjs unlocked this conversation Jun 4, 2020
@phated
Copy link
Member

phated commented Jun 4, 2020

Good news! With some amazing work by @snoack in gulpjs/gulp-cli#214, gulp-cli version 2.3.0 has support for loading ESM modules with the .mjs extension!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants