Babel plugin that transforms ECMAScript object rest and spread syntax into ES5-compatible code.
85
Quality
Pending
Does it follow best practices?
Impact
85%
1.06xAverage score across 10 eval scenarios
Pending
The risk profile of this skill
Build a command-line tool that converts JavaScript modules between different module formats (ES Modules, CommonJS, AMD, UMD).
Your tool should accept JavaScript source code as input and convert it to a target module format. The tool must:
Accept two command-line arguments:
commonjs, amd, umd, or esmRead the source file and transform it to the target module format
Output the transformed code to stdout
Handle syntax errors gracefully by printing an error message to stderr and exiting with code 1
Support modern JavaScript syntax including ES2015+ features
node converter.js input.js commonjsGiven an input file input.js:
export const greeting = "Hello";
export function sayHello(name) {
return `${greeting}, ${name}!`;
}When run with target format commonjs, should output:
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.greeting = void 0;
exports.sayHello = sayHello;
const greeting = "Hello";
exports.greeting = greeting;
function sayHello(name) {
return `${greeting}, ${name}!`;
}@generates
/**
* Transforms JavaScript code to the specified module format
*
* @param {string} code - Source code to transform
* @param {string} format - Target format: 'commonjs', 'amd', 'umd', or 'esm'
* @returns {string} Transformed code
*/
function transformModule(code, format) {
// Implementation here
}
module.exports = { transformModule };Provides JavaScript transformation capabilities.
Transforms ES modules to CommonJS format.
Transforms ES modules to AMD format.
Transforms ES modules to UMD format.
docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10