CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-babel-plugin-transform-eval

Babel plugin that transforms eval() calls containing string literals by parsing and compiling the string content at transform time

Overall
score

98%

Overview
Eval results
Files

task.mdevals/scenario-3/

Babel Configuration Resolver

Build a utility that resolves Babel configuration with environment-specific settings and conditional overrides.

Requirements

Implement a resolveConfig function that:

  1. Accepts a base configuration object containing Babel options (plugins, presets, etc.)

  2. Accepts an options parameter with optional fields:

    • env: Object mapping environment names (e.g., "development", "production") to configuration objects
    • overrides: Array of override objects, each containing configuration to conditionally apply
  3. Resolves environment-specific configuration: If options.env contains a key matching the current NODE_ENV, merge that configuration into the base

  4. Applies overrides: Merge all override configurations into the result

  5. Returns the resolved configuration object with all applicable settings merged

Test Cases

  • When given a base configuration with no options, it returns the base configuration unchanged @test

  • When NODE_ENV is set and options.env contains a matching key, it merges that environment's configuration @test

  • When options.overrides is provided, it merges all override configurations @test

  • When both env and overrides are provided, it merges them in correct order: base → env → overrides @test

Implementation

@generates

API

/**
 * Resolves Babel configuration with environment-specific overrides
 * @param {Object} baseConfig - Base Babel configuration object
 * @param {Object} [options={}] - Configuration options
 * @param {Object} [options.env] - Environment-specific configuration map (keys are environment names)
 * @param {Array} [options.overrides] - Array of override configuration objects
 * @returns {Object} Resolved Babel configuration object
 */
function resolveConfig(baseConfig, options = {}) {
  // Implementation
}

module.exports = { resolveConfig };

Dependencies { .dependencies }

@babel/core { .dependency }

Provides configuration loading and resolution APIs.

Install with Tessl CLI

npx tessl i tessl/npm-babel-plugin-transform-eval

tile.json