Registry / web-framework / babel-register-esm

babel-register-esm

JSON →
library1.2.5jsnpmunverified

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-esm
INSTALL
IMPORT
SIG · BABEL-REGISTER-ESM
B
babel-register-esm
web-frameworkjavascriptv1.2.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import {} from 'babel-register-esm'
import babelRegisterEsm from 'babel-register-esm'
Module has no default export; it's a side-effect loader. Import the module for side effects only.

Shows how to install, configure, and run a JSX file with on-the-fly transpilation using the ESM loader.

// Install: npm install babel-register-esm @babel/core // Create babelrc.json with plugins, e.g.: // { // "plugins": ["@babel/plugin-transform-react-jsx"] // } // a-file-with-jsx.js import React from 'react'; console.log((<button>Hi</button>).type); // Run with: // node --loader babel-register-esm a-file-with-jsx.js // For Mocha: // mocha --loader=babel-register-esm some-test.js
Debug
Known issues
gotchaMust run Node.js with --loader babel-register-esm flag. Running without it will not transpile.
fix
node --loader babel-register-esm your-file.js
affects: >=0.0.0
gotchaPeer dependency @babel/core must be installed separately. If missing, loader will fail.
fix
npm install @babel/core
affects: >=0.0.0
gotchaTypeScript imports must use .js extension even when importing .ts files. Using .ts extension will fail.
fix
import './file.js' instead of './file.ts'
affects: >=0.0.0
Errors
Common errors & fixes
Error [ERR_MODULE_NOT_FOUND]: Cannot find module
Importing a .ts file with .js extension but the loader fails to resolve it because Babel plugin for TypeScript is not configured.
fix
Ensure babelrc.json includes @babel/plugin-transform-typescript plugin and isTSX option if needed.
Upgrade
Version history
1.2.5latest on npm
Audit
Dependencies
@babel/corerequiredpeer dependency required for Babel transpilation
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
babel-register-esm — npm install babel-register-esm · libregistry