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

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.

主站蜘蛛池模板: 西乌| 宁明县| 来安县| 昌宁县| 安顺市| 辰溪县| 即墨市| 蚌埠市| 平顺县| 威海市| 盘锦市| 阳曲县| 两当县| 雷山县| 克什克腾旗| 兴和县| 临洮县| 柘荣县| 泽库县| 西乌珠穆沁旗| 东乡族自治县| 即墨市| 楚雄市| 扎赉特旗| 呼伦贝尔市| 增城市| 固安县| 荥阳市| 白朗县| 阿合奇县| 泰顺县| 禹城市| 遂平县| 利辛县| 公安县| 东平县| 永定县| 太康县| 东至县| 达州市| 天水市|