简体   繁体   English

是否有标准化的ES6文件扩展名?如果是这样,它是什么?

[英]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. 我想知道ES6是否有标准化的文件扩展名。 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. 到目前为止,我已经看到.es6.es6.js作为两个选项,但我很好奇是否通常更好地支持第三方软件包和工具。 And if Mozilla is leaning a particular direction. 如果Mozilla倾向于特定的方向。

There's no formal ES6/JS extension, although majority of people seem to prefer .js . 虽然大多数人似乎更喜欢.js ,但没有正式的ES6 / JS扩展。 ECMAScript specific suffixes aren't common. ECMAScript特定的后缀并不常见。

Mozilla is using two extensions within Firefox and FirefoxOS: .js and .jsm . Mozilla在Firefox和FirefoxOS中使用了两个扩展名: .js.jsm No ECMA Script specific suffixes. 没有ECMA脚本特定的后缀。

For Gecko (the layout engine written largely in JS), they use both .js and .jsm . 对于Gecko(主要用JS编写的布局引擎),他们使用.js.jsm Example: one of the DOM modules source code . 示例: DOM模块之一源代码

In some other subprojects, such as Gaia , they use .js only. 在一些其他子项目中,例如Gaia ,它们仅使用.js Example: "system" app for Firefox OS . 示例: Firefox OS的“system”应用程序

Note: .jsm is something specific to Gecko - it's a Javascript module . 注意: .jsm是Gecko .jsm的东西 - 它是一个Javascript模块

Note: ECMAScript 6 is a standard that is later implemented in Firefox as Javascript. 注意: ECMAScript 6是一种标准,后来在Firefox中作为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. 抬头:Gecko方面的源代码具有普通JS的语法,带有一些扩展 - 其中一些最终出现在ECMA Script 6中,有些则没有。 In general, though, Mozillians tend to follow ECMA Script spec closely. 但总的来说,Mozillians倾向于密切关注ECMA Script规范。 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. 另外,我的理解是.mjs正在考虑使用.mjs又名Michael Jackson Script文件扩展名,类似于上面提到的.jsm文件扩展名。

A link to the apparently official discussion: https://github.com/nodejs/node-eps/issues/13 显示官方讨论的链接: 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. 我还要声明我个人的偏见是.js应该引用没有模块的文件,而.es应该引用带有模块的文件。

I intended this to be a comment to the above rather than a standalone response 我打算将此作为对上述内容的评论,而不是单独的回复

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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