CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-uglify-save-license

License detector for UglifyJS that identifies and preserves license comments during minification

Overall
score

98%

Overview
Eval results
Files

task.mdevals/scenario-3/

License-Preserving Minifier

Build a JavaScript minification utility that processes source files while automatically preserving license and copyright comments.

Requirements

Your utility should minify JavaScript code using a minification library while ensuring all license-related comments are preserved in the output.

Input Processing

  • Accept a JavaScript source string as input
  • Process the source through minification
  • Return the minified output with preserved license comments

Comment Preservation

The minifier must preserve comments that contain:

  • Copyright notices
  • License declarations (MIT, GPL, BSD, etc.)
  • Legal attributions
  • Standard preservation directives

Output Format

  • Return minified JavaScript code as a string
  • All license-related comments must remain in the output
  • Non-license comments should be removed during minification

Test Cases

  • Minifying code with an MIT license header preserves the license comment @test
  • Minifying code with copyright notices preserves the copyright @test
  • Minifying code without license comments removes all comments @test

Implementation

@generates

API

/**
 * Minifies JavaScript code while preserving license comments.
 *
 * @param {string} sourceCode - The JavaScript source code to minify
 * @returns {string} The minified code with preserved license comments
 */
function minify(sourceCode) {
  // IMPLEMENTATION HERE
}

module.exports = { minify };

Dependencies { .dependencies }

uglify-js { .dependency }

Provides JavaScript minification capabilities.

uglify-save-license { .dependency }

Provides license comment detection and preservation.

Install with Tessl CLI

npx tessl i tessl/npm-uglify-save-license

tile.json