Is there a standardized ES6 file extension? If so, what is it?
Asked Answered
S

2

38

I'm wondering if there's a standardized file extension for ES6 yet. So far I've seen .es6 and .es6.js as two options, but I'm curious if one is generally better supported by third party packages and tools. And if Mozilla is leaning a particular direction.

Staffard answered 16/7, 2015 at 17:41 Comment(5)
.js is all i've seen so far.. which makes sense. We didn't start using .4.cs when c# came out with await/async in .NET 4Cobby
Or, even more relevant, we don't use .es3.js, .es4.js, .es5.jsDoxology
Just use .js ES is the foundation of JS so it is JS. Options you have seen are most likely for IDEs to let them know that you are writing ES6 so it can provide auto completion and such.Busk
I can give an example: Mailspring will use .es6 as their ES6 JS files extension. You can check their GitHub: github.com/Foundry376/Mailspring/blob/master/app/src/…Arsine
I do use src/es6/filename.js and src/less/filename.less.Charger
Z
25

There's no formal ES6/JS extension, although majority of people seem to prefer .js. ECMAScript specific suffixes aren't common.

Mozilla is using two extensions within Firefox and FirefoxOS: .js and .jsm. No ECMA Script specific suffixes.

For Gecko (the layout engine written largely in JS), they use both .js and .jsm. Example: one of the DOM modules source code.

In some other subprojects, such as Gaia, they use .js only. Example: "system" app for Firefox OS.

Note: .jsm is something specific to Gecko - it's a Javascript module.

Note: ECMAScript 6 is a standard that is later implemented in Firefox as Javascript. So those two terms are closely related, and are almost synonyms (source).

Heads up: source code on the Gecko side has the syntax that is plain JS with some extensions - some of which ended up in ECMA Script 6, some not. In general, though, Mozillians tend to follow ECMA Script spec closely. Possible differences are listed here.

Zoophobia answered 16/7, 2015 at 17:45 Comment(9)
This answer doesn't address the OP's question at all. Hence, it should be a comment.Madriene
OP asked whether Mozilla is leaning in a particular direction. I fail to see how this is not an answer to that question.Cobby
Mozillians. Hah, I guess I am a Chromian then. =PMadriene
@AaditMShah - I added an answer to the first part of OP's question - which is simple - but you had a fair point it was missing. The Mozilla part is more interesting.Zoophobia
@DanPantry The OP asked whether Mozilla is leaning in a particular direction apropos ES6 and not apropos JavaScript extensions. That's the point that I am contesting.Madriene
I don't think you could split that hair any thinnerCobby
@AaditMShah hm, no, OP asked whether Moz is leaning in a particular direction when it comes to file extensions.Zoophobia
@Zoophobia File extension for ES6. To paraphrase the OP: I'm wondering if there's a standardized file extension for ES6 yet. So far I've seen .es6 and .es6.js as two options, but I'm curious if one is generally better supported by third party packages and tools. And if Mozilla is leaning a particular direction. Nowhere has the OP mentioned file extensions for JavaScript extensions/addons or anything more general.Madriene
@AaditMShah - not sure what your point is - but if your point is that ES6 != JS, than I agree, you couldn't split that hair any thinner ;) I added some note about that to make that extra clear.Zoophobia
C
-1

you can add ecmascript from extensions from compiler visual studio ex instate of word all component word by word you can write only rafc

Chapeau answered 14/2 at 22:33 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Preparatory

© 2022 - 2024 — McMap. All rights reserved.