oxc/napi/minify/test/minify.test.ts
sapphi-red 86b6219d26
feat(mangler): use characters in the order of their likely frequency (#8771)
Just noticed that we can use a static list here. I think this has no downsides. To have better compression, we can actually count the characters, but I guess there won't be much difference normally.
2025-01-29 02:20:44 +00:00

34 lines
927 B
TypeScript

import { describe, expect, it } from 'vitest';
import { minify } from '../index';
describe('simple', () => {
const code = 'function foo() { var bar; bar(undefined) } foo();';
it('matches output', () => {
const ret = minify('test.js', code, { sourcemap: true });
expect(ret).toStrictEqual({
'code': 'function foo(){var e;e(void 0)}foo();',
'map': {
'mappings': 'AAAA,SAAS,KAAM,CAAE,IAAIA,EAAK,SAAc,AAAE,CAAC,KAAK',
'names': [
'bar',
],
'sources': [
'test.js',
],
'sourcesContent': [
code,
],
'version': 3,
},
});
});
it('can turn off everything', () => {
const ret = minify('test.js', code, { compress: false, mangle: false, codegen: { whitespace: false } });
expect(ret).toStrictEqual({
'code': 'function foo() {\n\tvar bar;\n\tbar(undefined);\n}\nfoo();\n',
});
});
});