jarslab / babel-maven-plugin

Babel transcription plugin for Maven
MIT License
25 stars 8 forks source link

Ability to change the file's extension when transpiling #21

Open glebfrank opened 4 years ago

glebfrank commented 4 years ago

Some of the source files that one uses Babel on have extensions other than .js. For example, Typescript files end with .ts, and you can also have .jsx and .tsx. These extensions are expected by the IDEs, which use them to determine the language of the file.

However, without special setup, these extensions are not associated by the web server with the text/javascript MIME type, so when you try to put them into a script tag on your web page, you get an error: "blocked because of a disallowed MIME type."

Therefore, it would be very convenient if the plugin could allow renaming the translated files such as myFile.ts to myFile.js.

I have submitted a pull request (#20) that provides one way of doing this - not sure if it's the best way, but can hopefully be a start.

milpol commented 4 years ago

Interesting, wouldn't that broke the overall script? I mean how strict Babel is if it comes to file extensions? Could you provide some tests for this? Thanks for contribution!