swc/crates/swc_ecma_minifier/scripts/next/evaluate.js
Donny/강동윤 57204e39cd
fix(es/minifier): Don't inline functions used as arguments (#3320)
swc_ecma_minifier:
 - Preserve a variable initialized with a function expression if it's used as an argument.
2022-01-20 16:06:23 +09:00

26 lines
682 B
JavaScript

const readline = require('readline');
const fs = require('fs').promises;
const path = require('path');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
rl.on('line', async (data) => {
try {
const { name, source } = eval(`(${data})`)
const targetPath = path.join(__dirname, '..', '..', 'tests', 'compress', 'fixture', 'next', 'raw', name.replace('.js', ''), 'input.js');
await fs.mkdir(path.dirname(targetPath), { recursive: true });
await fs.writeFile(targetPath, source, 'utf8');
} catch (e) {
console.log(`Code: (${data})`)
console.error(e);
}
})