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

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.

主站蜘蛛池模板: 锡林郭勒盟| 沈阳市| 芦山县| 富民县| 宁津县| 钟祥市| 缙云县| 台东市| 桃江县| 济宁市| 台北县| 普宁市| 邢台市| 岳阳县| 安西县| 怀远县| 新宁县| 离岛区| 南江县| 云南省| 山丹县| 河北区| 阿城市| 宣武区| 桐乡市| 嘉定区| 醴陵市| 绿春县| 汽车| 阿鲁科尔沁旗| 临澧县| 张家界市| 喀什市| 综艺| 积石山| 南川市| 玛沁县| 望谟县| 玛曲县| 合江县| 德化县|