babel / babel/gulp-babel

Do not change the original file extension

Open
#211 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.3k
Forks
113
PR merge metrics
No merged PRs in 30d

Description

**DISCLAIMER:** I know that this issue has already been [proposed and rejected different times](https://github.com/babel/gulp-babel/issues?q=is%3Aissue+sort%3Aupdated-desc+is%3Aclosed+extension).

`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:
- `.js`
- `.cjs`
- `.mjs`

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`](https://babeljs.io/docs/en/babel-cli#set-file-extensions)
2. (breaking) Do not support changing the extension, and let users use [`gulp-rename`](https://www.npmjs.com/package/gulp-rename)

I am aware that there is the [`gulp-revert-path`](https://www.npmjs.com/package/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*

Contributor guide

No contributing guide indexed for this repository

Research direction

Review the prior rejected proposals and the Babel PR #12820 context before choosing a direction. Compare the proposed keepFileExtensions option with the breaking behavior change, and consider how each relates to gulp-rename and gulp-revert-path; done means an agreed solution for preserving .js, .cjs, and .mjs semantics.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.