diff --git a/src/plugins/es5.ts b/src/plugins/es5.ts index 756e1abb..a689b741 100644 --- a/src/plugins/es5.ts +++ b/src/plugins/es5.ts @@ -29,6 +29,7 @@ export const es5 = (): Plugin => { const result = await swc.transform(code, { filename: info.path, sourceMaps: this.options.sourcemap, + minify: Boolean(this.options.minify), jsc: { target: 'es5', parser: { diff --git a/test/index.test.ts b/test/index.test.ts index 9e426547..107deaab 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -250,6 +250,25 @@ test('minify', async () => { expect(outFiles).toEqual(['input.js']) }) +test('minify with es5 target', async () => { + const { output, outFiles } = await run( + getTestName(), + { + 'input.ts': ` + export function foo() { + return 'foo' + } + `, + }, + { + flags: ['--minify', '--target', 'es5'], + } + ) + + expect(output).toContain(`return"foo"`) + expect(outFiles).toEqual(['input.js']) +}) + test('env flag', async () => { const { output, outFiles } = await run( getTestName(), @@ -435,8 +454,8 @@ test('onSuccess', async () => { } ) - expect(logs.includes("hello")).toEqual(true) - expect(logs.includes("world")).toEqual(true) + expect(logs.includes('hello')).toEqual(true) + expect(logs.includes('world')).toEqual(true) }) test('custom tsconfig', async () => {