transform.js 319 B

12345678910111213
  1. const { minify } = require("terser");
  2. const transform = (code, optionsString) => {
  3. const options = eval(`(${optionsString})`);
  4. const result = minify(code, options);
  5. if (result.error) {
  6. throw result.error;
  7. } else {
  8. return { result, nameCache: options.nameCache };
  9. }
  10. };
  11. exports.transform = transform;