What does it take to support Node.js ESM?

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • Scout APM - Less time debugging, more time building
  • SonarLint - Deliver Cleaner and Safer Code - Right in Your IDE of Choice!
  • OPS - Build and Run Open Source Unikernels
  • GitHub repo plugins

    🍣 The one-stop shop for official Rollup plugins (by rollup)

    The only workaround to have an isomorphic __dirname or __filename to be used for both "cjs" and "esm" without using build-time tools like @rollup/plugin-replace or esbuild "define" would be using a library like filedirname that does a trick inspecting error stacks, it's clearly not the cleanest solution.

  • GitHub repo TypeScript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    Until this issue TypeScript#33069 is closed, TypeScript doesn't have complete support for it, fortunately, there are 2 workarounds:

  • Scout APM

    Less time debugging, more time building. Scout APM allows you to find and fix performance issues with no hassle. Now with error monitoring and external services monitoring, Scout is a developer's best friend when it comes to application development.

  • GitHub repo bob

    Build tool used in libraries maintained by The Guild (by kamilkisiela)

    In The Guild we use this method using tooling that creates the temporary package.json automatically. See bob-the-bundler & bob-esbuild

  • GitHub repo bob-esbuild

    Building and Running TypeScript projects efficiently with rollup + esbuild

    In The Guild we use this method using tooling that creates the temporary package.json automatically. See bob-the-bundler & bob-esbuild

  • GitHub repo tsup

    The simplest and fastest way to bundle your TypeScript libraries.

    The best solution for this is to have ESM examples in a monorepo testing firsthand if everything with the logic included doesn't break, using tools that output both CommonJS & ESM like tsup might become very handy, but that might not be straightforward, especially for big projects.

  • GitHub repo ts-jest

    A Jest transformer with source map support that lets you use Jest to test projects written in TypeScript.

    There are workarounds, but nothing actually works in 100% of the possible use-cases (see for example, ts-jest issue), and for that reason, we recommend tooling that enables this type of building without needing any workaround, usually using Rollup and/or esbuild.

  • GitHub repo Stack

    Tech Stack developed by The Guild (by the-guild-org)

    In The Guild we use this method using tooling that creates the temporary package.json automatically. See bob-the-bundler & bob-esbuild

  • SonarLint

    Deliver Cleaner and Safer Code - Right in Your IDE of Choice!. SonarLint is a free and open source IDE extension that identifies and catches bugs and vulnerabilities as you code, directly in the IDE. Install from your favorite IDE marketplace today.

  • GitHub repo Rollup

    Next-generation ES module bundler

    There are workarounds, but nothing actually works in 100% of the possible use-cases (see for example, ts-jest issue), and for that reason, we recommend tooling that enables this type of building without needing any workaround, usually using Rollup and/or esbuild.

  • GitHub repo esbuild

    An extremely fast JavaScript and CSS bundler and minifier

    There are workarounds, but nothing actually works in 100% of the possible use-cases (see for example, ts-jest issue), and for that reason, we recommend tooling that enables this type of building without needing any workaround, usually using Rollup and/or esbuild.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts