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-8/

Plugin Configuration Manager

Build a utility that programmatically creates and manages transformation configurations for a JavaScript compiler. The utility should provide a way to validate and normalize plugin configurations before they are used in compilation.

Requirements

Implement a module that exports a function createPluginManager() which returns an object with the following methods:

1. addPlugin(name, options)

  • Accepts a plugin name (string) and optional configuration options (object)
  • Creates a validated configuration wrapper for the plugin
  • Returns a unique identifier for the added plugin
  • The plugin should be marked as a plugin type (not a preset)

2. addPreset(name, options)

  • Accepts a preset name (string) and optional configuration options (object)
  • Creates a validated configuration wrapper for the preset
  • Returns a unique identifier for the added preset
  • The preset should be marked as a preset type (not a plugin)

3. getPlugins()

  • Returns an array of all registered plugin configuration wrappers
  • Each wrapper should maintain its plugin type designation

4. getPresets()

  • Returns an array of all registered preset configuration wrappers
  • Each wrapper should maintain its preset type designation

5. getAll()

  • Returns an object with two properties:
    • plugins: array of all plugin configuration wrappers
    • presets: array of all preset configuration wrappers

Implementation Notes

  • The configuration wrappers should be properly validated and normalized
  • Use appropriate APIs to ensure plugin and preset items are correctly typed
  • Store configuration items internally for retrieval
  • Handle both plugins and presets correctly according to their types

Dependencies { .dependencies }

@babel/core { .dependency }

Provides JavaScript compilation and transformation APIs.

Test Cases

Create a test file plugin-manager.test.js to verify the implementation:

@test Test 1: Add and retrieve plugins

const { createPluginManager } = require('./plugin-manager');

const manager = createPluginManager();
const id1 = manager.addPlugin('@babel/plugin-transform-arrow-functions');
const id2 = manager.addPlugin('@babel/plugin-transform-block-scoping', { spec: true });

const plugins = manager.getPlugins();
console.assert(plugins.length === 2, 'Should have 2 plugins');
console.assert(plugins[0].name, 'Plugin should have a name');
console.log('Test 1 passed');

@test Test 2: Add and retrieve presets

const { createPluginManager } = require('./plugin-manager');

const manager = createPluginManager();
const id1 = manager.addPreset('@babel/preset-env', { targets: { node: 'current' } });
const id2 = manager.addPreset('@babel/preset-react');

const presets = manager.getPresets();
console.assert(presets.length === 2, 'Should have 2 presets');
console.assert(presets[0].name, 'Preset should have a name');
console.log('Test 2 passed');

@test Test 3: Retrieve all configurations

const { createPluginManager } = require('./plugin-manager');

const manager = createPluginManager();
manager.addPlugin('@babel/plugin-transform-classes');
manager.addPreset('@babel/preset-typescript');

const all = manager.getAll();
console.assert(all.plugins.length === 1, 'Should have 1 plugin');
console.assert(all.presets.length === 1, 'Should have 1 preset');
console.log('Test 3 passed');