简体   繁体   中英

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

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.

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 .

The response above is good advice. In addition, my understanding is that NodeJS are contemplating the use of the .mjs aka the Michael Jackson Script file extension, similar to the .jsm file extension mentioned above.

A link to the apparently official discussion: https://github.com/nodejs/node-eps/issues/13

I will also declare my personal bias is that .js should refer to files without modules, and .es should refer to files with modules.

I intended this to be a comment to the above rather than a standalone response

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM