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

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.

主站蜘蛛池模板: 察隅县| 新干县| 南宁市| 景洪市| 武邑县| 盐源县| 长泰县| 浙江省| 黑龙江省| 灵石县| 民县| 龙江县| 澄江县| 山阴县| 兖州市| 松江区| 芦山县| 肃宁县| 衡阳县| 陇川县| 白河县| 沁水县| 双鸭山市| 斗六市| 新龙县| 九江县| 娱乐| 淄博市| 丰县| 鲁甸县| 三河市| 顺昌县| 乌兰县| 舒城县| 永定县| 桂东县| 安多县| 乌鲁木齐县| 龙岩市| 东丰县| 金沙县|