Babel Timing
raw JSON → 0.9.1 verified Sat Apr 25 auth: no javascript
Measure Babel compilation time per file and per plugin. Version 0.9.1 (beta). Use it to profile Babel when applications or tests take ages to build. Supports CLI, Node API, Webpack plugin, and Jest transformer/reporter. Ships TypeScript types. Distinct from generic profilers by focusing specifically on Babel's transform pipeline, breaking down time by file and by plugin. Active development; minor releases may include breaking changes.
Common errors
error Error [ERR_REQUIRE_ESM]: require() of ES Module from babel-timing ↓
cause Using require() on an ESM-only package version >=0.9.0.
fix
Use import { babelTiming } from 'babel-timing'; or downgrade to <0.9.0.
error Cannot find module 'babel-timing/webpack/plugin' ↓
cause Importing from a subpath that is not exported in older versions or using wrong path.
fix
Ensure you use babel-timing >=0.9.0 and import using the exact subpath.
error BabelTimingPlugin is not a constructor ↓
cause Using default import when the export is named.
fix
Use import { BabelTimingPlugin } from 'babel-timing/webpack/plugin'; instead of default import.
Warnings
breaking Version 0.9.0 migrated to ESM-only. CJS require() will fail. ↓
fix Use import syntax or upgrade to a CJS-compatible version (<0.9.0).
gotcha When using Webpack integration, babel-loader cache must be deleted for profiling to be accurate. ↓
fix Delete ./node_modules/.cache/babel-loader/ before running Webpack.
deprecated CLI option --babelConfig with value false disables Babel config file loading. In future versions, use --no-babel-config instead. ↓
fix Use --no-babel-config flag instead of --babel-config false.
gotcha Jest transformer requires --no-cache flag to avoid stale results. ↓
fix Run Jest with --no-cache flag.
breaking Subpath exports (e.g., 'babel-timing/webpack/plugin') were introduced in v0.9.0. Older versions expect different import paths. ↓
fix Update imports to use subpath exports syntax.
Install
npm install babel-timing yarn add babel-timing pnpm add babel-timing Imports
- babelTiming wrong
const babelTiming = require('babel-timing');correctimport { babelTiming } from 'babel-timing'; - BabelTimingPlugin wrong
const BabelTimingPlugin = require('babel-timing/webpack/plugin');correctimport { BabelTimingPlugin } from 'babel-timing/webpack/plugin'; - BabelTimingReporter wrong
import BabelTimingReporter from 'babel-timing/jest/reporter';correctimport { BabelTimingReporter } from 'babel-timing/jest/reporter';
Quickstart
import { babelTiming } from 'babel-timing';
async function main() {
const results = await babelTiming(['src/**/*.js'], {
babelConfig: './babel.config.js' || false,
followImports: true,
include: ['**'],
exclude: ['**/node_modules/**'],
resolveMainFields: ['browser', 'module', 'main'],
resolveExtensions: ['.js', '.jsx', '.ts', '.tsx']
});
console.log(JSON.stringify(results, null, 2));
}
main().catch(console.error);