or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@babel/runtime@7.28.x
tile.json

tessl/npm-babel--runtime

tessl install tessl/npm-babel--runtime@7.28.0

Babel's modular runtime helpers that provide transpilation support for modern JavaScript features

Agent Success

Agent success rate when using this tile

94%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.19x

Baseline

Agent success rate without this tile

79%

task.mdevals/scenario-4/

Custom Babel Plugin with Transformation Tracking

Build a Babel plugin that tracks transformations and modifies parsing behavior based on configuration.

Requirements

Your plugin should:

  1. Accept a configuration option trackStats (boolean) that enables/disables statistics tracking
  2. Before any code transformation begins, initialize a statistics object that tracks:
    • Total number of function declarations found
    • Total number of arrow functions found
  3. During transformation, count all function declarations and arrow function expressions in the code
  4. After all transformations complete, if trackStats is enabled, attach the statistics to the result metadata under the key transformStats
  5. Modify the parser configuration to enable parsing of JSX syntax regardless of the file extension

Test Cases

  • Given a file with 2 function declarations and 3 arrow functions, when trackStats is true, the metadata should contain { transformStats: { functionDeclarations: 2, arrowFunctions: 3 } } @test
  • Given a file with JSX syntax (<div>Hello</div>), the plugin should successfully parse and transform it without errors @test
  • Given a file with 1 function declaration, when trackStats is false, the metadata should not contain transformStats @test

Implementation

@generates

API

/**
 * Babel plugin that tracks transformation statistics and enables JSX parsing
 *
 * @param {object} api - The Babel API object
 * @param {object} options - Plugin options
 * @param {boolean} options.trackStats - Whether to track and report statistics
 * @returns {object} Plugin object with visitor and lifecycle methods
 */
module.exports = function customPlugin(api, options) {
  // Plugin implementation
};

Dependencies { .dependencies }

@babel/core { .dependency }

Provides the Babel transformation API and plugin infrastructure.