Babel's modular runtime helpers that provide transpilation support for modern JavaScript features
94
Build a utility that transforms JavaScript code and extracts specific fields from the transformation result object.
const x = () => {}; and return the code field from the result @test"" and verify the returned code is an empty string @testconst greeting = "hello"; with AST enabled and return the ast field from the result @testfunction add(a, b) { return a + b; } and verify the returned ast has a type property equal to "File" @testmetadata field from the result object @testconst z = 10; with sourceMaps enabled and return the map field from the result @test@generates
/**
* Transforms JavaScript code and returns an object containing
* specified fields from the transformation result.
*
* @param {string} code - The JavaScript code to transform
* @param {object} options - Babel transformation options (plugins, sourceMaps, etc.)
* @param {string[]} fields - Array of field names to extract from the result (e.g., ['code', 'ast', 'map'])
* @returns {object} An object containing the requested fields from the transformation result
*/
function transformAndExtract(code, options, fields) {
// IMPLEMENTATION HERE
}
module.exports = { transformAndExtract };Provides JavaScript code transformation functionality.
Install with Tessl CLI
npx tessl i tessl/npm-babel--runtimedocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10