-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fallback terser to main thread when function options are used (#…
…18987) Co-authored-by: Wout Mertens <[email protected]>
- Loading branch information
1 parent
d88d000
commit 12b612d
Showing
4 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { resolve } from 'node:path' | ||
import { fileURLToPath } from 'node:url' | ||
import { describe, expect, test } from 'vitest' | ||
import { build } from 'vite' | ||
import type { RollupOutput } from 'rollup' | ||
import type { TerserOptions } from '../../plugins/terser' | ||
|
||
const __dirname = resolve(fileURLToPath(import.meta.url), '..') | ||
|
||
describe('terser', () => { | ||
const run = async (terserOptions: TerserOptions) => { | ||
const result = (await build({ | ||
root: resolve(__dirname, '../packages/build-project'), | ||
logLevel: 'silent', | ||
build: { | ||
write: false, | ||
minify: 'terser', | ||
terserOptions, | ||
}, | ||
plugins: [ | ||
{ | ||
name: 'test', | ||
resolveId(id) { | ||
if (id === 'entry.js') { | ||
return '\0' + id | ||
} | ||
}, | ||
load(id) { | ||
if (id === '\0entry.js') { | ||
return `const foo = 1;console.log(foo)` | ||
} | ||
}, | ||
}, | ||
], | ||
})) as RollupOutput | ||
return result.output[0].code | ||
} | ||
|
||
test('basic', async () => { | ||
await run({}) | ||
}) | ||
|
||
test('nth', async () => { | ||
const resultCode = await run({ | ||
mangle: { | ||
nth_identifier: { | ||
get: (n) => { | ||
return 'prefix_' + n.toString() | ||
}, | ||
}, | ||
}, | ||
}) | ||
expect(resultCode).toContain('prefix_') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.