tessl install tessl/npm-babel--runtime@7.28.0Babel'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%
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.
Implement a module that exports a function createPluginManager() which returns an object with the following methods:
addPlugin(name, options)addPreset(name, options)getPlugins()getPresets()getAll()plugins: array of all plugin configuration wrapperspresets: array of all preset configuration wrappersProvides JavaScript compilation and transformation APIs.
Create a test file plugin-manager.test.js to verify the implementation:
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');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');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');