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

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.

主站蜘蛛池模板: 玉门市| 洱源县| 什邡市| 公安县| 安徽省| 玉田县| 威海市| 融水| 茂名市| 南宫市| 玉环县| 墨脱县| 浮山县| 阳江市| 定兴县| 承德市| 平定县| 民权县| 蕲春县| 永州市| 噶尔县| 长海县| 忻城县| 敦煌市| 尚义县| 错那县| 曲周县| 怀远县| 兴城市| 武宣县| 磐安县| 古浪县| 祁阳县| 宝应县| 综艺| 嵩明县| 临沂市| 大埔区| 南丹县| 丰镇市| 科技|