mirror of
https://github.com/danbulant/oxc
synced 2026-05-21 21:29:01 +00:00
Changed the mangler to reuse variable names where possible. This will reduce the code size as shorter variable names can be used in more places. But requires global information and limits parallelism in a single file and requires more memory. --------- Co-authored-by: Boshen <boshenc@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
34 lines
927 B
TypeScript
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 a;a(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',
|
|
});
|
|
});
|
|
});
|