swc/crates/swc_ecma_minifier/scripts/next/evaluate.js
Donny/강동윤 fa342a0067
fix(es/minifier): Fix bugs (#2779)
swc_ecma_minifier:
 - Don't optimize `1 / t == -1 / 0` as `!1`.
 - Don't optimize `e === -1 / 0` as false.
 - Don't inline string literals in arguments, if it's used multiple time. (https://github.com/vercel/next.js/issues/31291)
2021-11-20 17:06:18 +09:00

26 lines
685 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', 'issues', 'next', 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);
}
})