官术网_书友最值得收藏!

Module formats

Modules feature in JavaScript as part of ES6, which is great. However, lots of code exists in other popular module formats that came before this standardization. TypeScript allows us to write our code using ES6 modules, which can then transpile into another module format if specified.

Here is a brief description of the different module formats that TypeScript can transpile to:

  • Asynchronous Module Definition (AMD): This is commonly used in code targeted for the browser and uses a define function to define modules.
  • CommonJS: This format is used in Node.js programs. It uses module.exports to define modules and require to define dependencies.
  • Universal Module Definition (UMD): This can be used in both browser apps and Node.js programs.
  • ES6: This is the native JavaScript module format and uses the export keyword to define modules and import to define dependencies.

In the following sections (and, in fact, this whole book), we'll write our code using ES6 modules.

主站蜘蛛池模板: 西丰县| 根河市| 昭通市| 黄山市| 武夷山市| 宾川县| 菏泽市| 汾阳市| 平凉市| 阿克苏市| 壶关县| 灵寿县| 那曲县| 宁强县| 江津市| 张家港市| 嘉荫县| 怀柔区| 和田市| 和平县| 清水河县| 哈尔滨市| 大宁县| 库尔勒市| 怀化市| 敦化市| 青龙| 水富县| 四平市| 盐山县| 昌乐县| 南陵县| 敖汉旗| 南陵县| 中牟县| 临西县| 潍坊市| 甘孜县| 白沙| 汾阳市| 吉木萨尔县|