CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-escodegen

ECMAScript code generator that transforms Mozilla's Parser API ASTs back into executable JavaScript code

95

1.07x
Overview
Eval results
Files

task.mdevals/scenario-3/

Code Minifier

Build a JavaScript code minifier that takes Abstract Syntax Tree (AST) nodes and generates compact JavaScript code with optimized number representations. The minifier should produce code without unnecessary whitespace, indentation, or optional formatting characters.

Capabilities

Generate minified code from AST

Your minifier should convert AST nodes into compact JavaScript code that minimizes file size while maintaining functionality.

  • It generates compact code from a simple binary expression AST node @test
  • It generates compact code from a function declaration AST node @test

Optimize numeric literals

The minifier should optimize number representations to reduce code size by removing unnecessary characters and using shorter formats.

  • It removes unnecessary leading zeros from decimal numbers (e.g., 0.5 becomes .5) @test
  • It converts large integers to hexadecimal when the hex representation is shorter @test

Implementation

@generates

API

/**
 * Generate minified JavaScript code from an AST node
 * @param {Object} node - Mozilla Parser API compatible AST node
 * @returns {string} Minified JavaScript code
 */
function minify(node) {
  // IMPLEMENTATION HERE
}

module.exports = { minify };

Dependencies { .dependencies }

escodegen { .dependency }

Provides AST to JavaScript code generation with optimization support.

Install with Tessl CLI

npx tessl i tessl/npm-escodegen

tile.json