Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-timing

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-timing

Measure Babel compilation time

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.9K
decreased by-27.54%
Maintainers
1
Weekly downloads
 
Created
Source

Babel timing

Measure Babel compilation time file by file, plugin by plugin. See screenshot.

Note: this tool is in version 0, any minor release might introduce breaking changes.

Installation

Can be installed both as global or local dependency.

npm i babel-timing
yarn add babel-timing

Usage

CLI

babel-timing path/to/file-1.js path/to/file-2.js
babel-timing path/to/file-*.js
babel-timing path/to/entrypoint.js --follow-imports

Node

const babelTiming = require('babel-timing').babelTiming;
babelTiming(['path/to/file.js'], options);

Options

babelConfig / --babel-config

Type: string | false
Default: false

Path to a custom babel configuration file. By default Babel will try to load any existing valid configuration file.

followImports / --follow-imports

Type: bool
Default: false

Follow imported files/modules (using babel-collect-imports) and run babel-timing against them.

Currently only relative paths are considered.

importPatterns / --import-patterns

Type: string[] (cli accepts a string containing a comma-separated list)
Default: undefined

Include/exclude import paths according to the provided patterns.

output / --output

Type: string
Default: "return" ("console" when called via CLI)
Options: "return", "console", "json"

Make babel-timing results available as:

  • "return" return results' object
  • "console" render results in console
  • "json" save results as babel-timing-results.json

How it works

Compile files with Babel 7 and get collect compilation info through wrapPluginVisitorMethod Babel config option.

Optionally follow imports using babel-collect-imports.

Results

Compilation info are extracted into the following data structure:

type Results = {
  name: string,
  totalTime: number,
  data: {
    plugin: string,
    timePerVisit: number,
    time: number,
    visits: number,
  }[]
}[]

Notes

This tool started as an attempt of measuring the time taken by Babel while running transpiled tests or compiling applications with a bundler like Webpack.

I didn't find find a way of simply monitoring Babel while running the aforementioned tools, since I couldn't relate the wrapPluginVisitorMethod calls to the file actually being compiled.

Any further idea/contribution to get to a better Babel monitoring solution is welcome.

Manual tests :)

node cli.js __fixtures__/file-1.js
node cli.js __fixtures__/file-1.js __fixtures__/file-2.js
node cli.js __fixtures__/*.js
node cli.js __fixtures__/entry.js --follow-imports

Thanks to

Todo

  • Add csv output option
  • Expose wrapPluginVisitorMethod
  • Provide a way to consume babel-timing from other tools like webpack, jest, rollup, etc..
  • Unwrap and compile node_modules packages (absolute paths)
  • Prevent nested import discovery
  • Find a more stable solution for making available pending babel-collect-imports Babel v7 update
  • Consider using a bundler instead of babel-collect-import

Keywords

FAQs

Package last updated on 28 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc