babel / gulp-babel

Gulp plugin for Babel
https://babeljs.io
MIT License
1.32k stars 120 forks source link

Do not change the original file extension #211

Open nicolo-ribaudo opened 3 years ago

nicolo-ribaudo commented 3 years ago

DISCLAIMER: I know that this issue has already been proposed and rejected different times.

gulp-babel always renames the file to .js, regardless of the input extension. This was the most reasonable behavior until a few years ago: .js was the only extension for JavaScript.

However, now there are three "official" (supported by Node.js) JavaScript extensions:

and renaming them to .js is undesirable, since they are not interchangeable. I think that this is a good reason to reopen the discussion, and we have two options:

  1. Add a keepFileExtensions option, that matches @babel/cli's --keep-file-extensions
  2. (breaking) Do not support changing the extension, and let users use gulp-rename

I am aware that there is the gulp-revert-path plugin that undoes Babel's extension change, but it is a workaround and not a proper solution: while a workaround made sense when .js was the only reasonable extension, I think we need a real solution now.

Context: https://github.com/babel/babel/pull/12820