CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-babel-plugin-transform-es2015-computed-properties

Babel plugin that compiles ES2015 computed properties to ES5-compatible code

88

1.07x
Overview
Eval results
Files

task.mdevals/scenario-5/

Babel Plugin Configuration Utility

Build a utility that configures Babel to transform computed properties with different transformation strategies.

Requirements

Create a module that exports a function createBabelConfig which generates Babel configuration objects for transforming computed property syntax. The function should accept a configuration mode parameter and return appropriate Babel plugin configurations.

Configuration Modes

The utility should support two distinct transformation modes:

Standard Mode:

  • Uses the default transformation strategy
  • Produces spec-compliant output
  • Suitable for environments requiring strict standards compliance

Relaxed Mode:

  • Uses a simpler transformation strategy
  • Produces more performant output
  • Suitable for modern runtime environments

Function Behavior

The createBabelConfig function should:

  • Accept a mode parameter ('standard' or 'relaxed')
  • Return a valid Babel configuration object with appropriate plugins array
  • Configure the computed properties plugin with the correct options for each mode
  • Throw an error if an invalid mode is provided

Test Cases

  • Calling createBabelConfig('standard') returns a configuration with the computed properties plugin using default settings @test
  • Calling createBabelConfig('relaxed') returns a configuration with the computed properties plugin using simplified transformation settings @test
  • Calling createBabelConfig('invalid') throws an error with a descriptive message @test
  • The returned configuration for standard mode produces spec-compliant output when transforming computed properties @test
  • The returned configuration for relaxed mode produces simplified output when transforming computed properties @test

Implementation

@generates

API

/**
 * Creates a Babel configuration for computed property transformation
 *
 * @param {string} mode - Transformation mode: 'standard' or 'relaxed'
 * @returns {object} Babel configuration object with plugins array
 * @throws {Error} If mode is not 'standard' or 'relaxed'
 */
function createBabelConfig(mode) {
  // IMPLEMENTATION HERE
}

module.exports = { createBabelConfig };

Dependencies { .dependencies }

@babel/plugin-transform-computed-properties { .dependency }

Provides computed property transformation capabilities with configurable transformation strategies.

Install with Tessl CLI

npx tessl i tessl/npm-babel-plugin-transform-es2015-computed-properties

tile.json