Skip to content

Commit

Permalink
fix: make --minify work with es5 target, fix #653
Browse files Browse the repository at this point in the history
  • Loading branch information
EGOIST committed Jun 10, 2022
1 parent 58d0145 commit 8230221
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/plugins/es5.ts
Expand Up @@ -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: {
Expand Down
23 changes: 21 additions & 2 deletions test/index.test.ts
Expand Up @@ -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(),
Expand Down Expand Up @@ -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 () => {
Expand Down

1 comment on commit 8230221

@vercel
Copy link

@vercel vercel bot commented on 8230221 Jun 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

tsup – ./

tsup-git-main-egoist.vercel.app
tsup.egoist.sh
tsup.vercel.app
tsup-egoist.vercel.app

Please sign in to comment.