Say goodbye to CommonJS and use ESM! 👋

Поделиться
HTML-код
  • Опубликовано: 15 июл 2024
  • CommonJS was a great invention but nowadays we have something better called ECMAScript Modules (ESM). Learn in this tutorial how to upgrade your TypeScript projects to ESM.
    My FREE programming apps:
    - apps.apple.com/app/id659282498
    - play.google.com/store/apps/de...
    My FREE TypeScript Course:
    - typescript.tv/
    Timeline:
    00:00 - Intro
    00:31 - Understanding Scripts and Modules
    01:38 - CommonJS: Exports and Imports
    03:31 - HTML: Exports and Imports
    06:14 - ESM: Exports and Imports
    08:56 - Asynchronous Loading
    10:08 - Enabling ESM in Node.js
    11:21 - New Module File Extensions
    12:25 - Network-based Module Loading
    13:15 - TypeScript with Node: Using ESM
    15:05 - TypeScript with Browsers: Using ESM
    15:58 - When to Use ESNext
    16:40 - When to Use NodeNext
    17:34 - Import Attributes in TypeScript
    18:00 - ESM Cheat Sheet Overview
    20:13 - Using the import.meta API
    20:36 - Why ESM is the Future
    #TypeScript #JavaScript #nodejs
  • НаукаНаука

Комментарии • 4

  • @TypeScriptTV
    @TypeScriptTV  Месяц назад

    For a mimic of __dirname and __filename, check out "desm" at: github.com/mcollina/desm

    • @TypeScriptTV
      @TypeScriptTV  27 дней назад

      One more reson to switch to ESM -> The CJS build of Vite got deprecated: vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated

  • @oblakus
    @oblakus Месяц назад +1

    Great video! 👍

    • @TypeScriptTV
      @TypeScriptTV  Месяц назад

      Thanks! If you want to migrate your project from CommonJS to ESM, give ts2esm a try: github.com/bennycode/ts2esm