An ESM loader for Babel that transpiles files on-the-fly based on Babel configuration, similar to @babel/register but for ES modules. Current version 1.2.5 is stable with moderate release cadence. It supports importing .ts and .tsx files by resolving .js imports to TypeScript files, a unique feature for TypeScript ESM projects. Requires @babel/core as a peer dependency. Actively maintained, with TypeScript type definitions shipped.
npm install babel-register-esmVerified import paths — ran on the pinned version, not inferred.
Shows how to install, configure, and run a JSX file with on-the-fly transpilation using the ESM loader.
node --loader babel-register-esm your-file.js
npm install @babel/core
import './file.js' instead of './file.ts'
Ensure babelrc.json includes @babel/plugin-transform-typescript plugin and isTSX option if needed.