Skip to content

[@swc-node/register] - Request to add support for es2023 and es2024 targetsΒ #904

@shawnmcknight

Description

@shawnmcknight

In swc-project/swc#9700, support was added to swc for targets es2023 and es2024. swc-node/register does not appear to support those targets:

function toTsTarget(target: ts.ScriptTarget): Options['target'] {
switch (target) {
case ts.ScriptTarget.ES3:
return 'es3'
case ts.ScriptTarget.ES5:
return 'es5'
case ts.ScriptTarget.ES2015:
return 'es2015'
case ts.ScriptTarget.ES2016:
return 'es2016'
case ts.ScriptTarget.ES2017:
return 'es2017'
case ts.ScriptTarget.ES2018:
return 'es2018'
case ts.ScriptTarget.ES2019:
return 'es2019'
case ts.ScriptTarget.ES2020:
return 'es2020'
case ts.ScriptTarget.ES2021:
return 'es2021'
case ts.ScriptTarget.ES2022:
case ts.ScriptTarget.ESNext:
case ts.ScriptTarget.Latest:
return 'es2022'
case ts.ScriptTarget.JSON:
return 'es5'
}

It appears that if a target of es2023 or es2024 is used in the tsconfig then the toTsTarget function will return undefined which then will cause the swc transformation to revert to its default which appears to be es5.

This issue is a request to add support for tsconfig targets of es2023 and es2024 to match that of swc.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions