Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ export class JavaScriptOptimizerPlugin {
if (this.options.target) {
if (this.options.target <= ScriptTarget.ES5) {
target = 5;
} else if (this.options.target < ScriptTarget.ESNext) {
} else if (this.options.target === ScriptTarget.ESNext) {
target = 'next';
} else {
target = Number(
ScriptTarget[this.options.target].slice(2),
) as OptimizeRequestOptions['target'];
} else {
target = 2020;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export interface OptimizeRequestOptions {
/**
* Specifies the target ECMAScript version for the output code.
*/
target: 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020;
target: 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 'next';
/**
* Controls whether esbuild should only use the WASM-variant instead of trying to
* use the native variant. Some platforms may not support the native-variant and
Expand Down Expand Up @@ -105,7 +105,8 @@ export default async function ({ asset, options }: OptimizeRequest) {
asset.name,
esbuildResult.code,
options.sourcemap,
options.target,
// Terser only supports up to ES2020.
options.target === 'next' ? 2020 : options.target,
options.advanced,
);

Expand Down Expand Up @@ -208,7 +209,7 @@ async function optimizeWithTerser(
name: string,
code: string,
sourcemaps: boolean | undefined,
target: OptimizeRequest['options']['target'],
target: Exclude<OptimizeRequest['options']['target'], 'next'>,
advanced: boolean | undefined,
): Promise<{ code: string; map?: object }> {
const result = await minify(
Expand Down