Babel plugin that compiles ES2015 computed properties to ES5-compatible code
88
Build a utility that configures Babel to transform computed properties with different transformation strategies.
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.
The utility should support two distinct transformation modes:
Standard Mode:
Relaxed Mode:
The createBabelConfig function should:
'standard' or 'relaxed')createBabelConfig('standard') returns a configuration with the computed properties plugin using default settings @testcreateBabelConfig('relaxed') returns a configuration with the computed properties plugin using simplified transformation settings @testcreateBabelConfig('invalid') throws an error with a descriptive message @test@generates
/**
* 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 };Provides computed property transformation capabilities with configurable transformation strategies.
Install with Tessl CLI
npx tessl i tessl/npm-babel-plugin-transform-es2015-computed-propertiesdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10