Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(es/typescript): Reimplement TypeScript pass #7202

Merged
merged 11 commits into from
Sep 25, 2023

Conversation

magic-akari
Copy link
Member

@magic-akari magic-akari commented Apr 4, 2023

Description:

Bugfixes

  • Exported let/var declarations in TypeScript namespaces should be mutable.
  • Fix missing declaration of complex exported patterns in TypeScript namespaces.
  • Preserve concrete TS namespaces.

New Features

  • Introducing Verbatim Module Syntax.
  • Enum value will now be inlined whenever possible within a single module, optimizing runtime performance.
  • Constant enums will be automatically eliminated when feasible, This can reduce bundle size.
  • Added support for cross-referencing enum values.

Deprecated

TsEnumConfig is deprecated

  • The treat_const_enum_as_enum transform option is deprecated.
  • The ts_enum_is_readonly assumption option is deprecated.

BREAKING CHANGE:

TypeScript Config is changed.

Related issue:

@kdy1
Copy link
Member

kdy1 commented Apr 5, 2023

Making a visitor multi-pass may make it significantly slower

@magic-akari
Copy link
Member Author

Making a visitor multi-pass may make it significantly slower

I will run a performance benchmark after I finish this pull request.

@magic-akari magic-akari changed the title [WIP] refactor(es/typescript): split strip into multipass [WIP] refactor(es/typescript): Reimplement TypeScript strip May 26, 2023
@magic-akari magic-akari force-pushed the typescript branch 2 times, most recently from 9d72649 to 8c673e3 Compare June 26, 2023 09:15
@magic-akari magic-akari force-pushed the typescript branch 2 times, most recently from b75ecb7 to 26f43bc Compare July 21, 2023 10:10
@magic-akari magic-akari force-pushed the typescript branch 6 times, most recently from fb2b890 to a70631c Compare September 7, 2023 12:58
@magic-akari magic-akari changed the title [WIP] refactor(es/typescript): Reimplement TypeScript strip [WIP] refactor(es/typescript): Reimplement TypeScript pass Sep 7, 2023
@magic-akari magic-akari changed the title [WIP] refactor(es/typescript): Reimplement TypeScript pass refactor(es/typescript): Reimplement TypeScript pass Sep 7, 2023
@magic-akari magic-akari marked this pull request as ready for review September 7, 2023 15:17
@magic-akari
Copy link
Member Author

review request

@magic-akari magic-akari requested a review from kdy1 September 7, 2023 15:32
@magic-akari
Copy link
Member Author

magic-akari commented Sep 7, 2023

branch typescript c4ad213

test es/full/codegen/es3 ... bench:       19076 ns/iter (+/- 67)

test es/full/codegen/es5 ... bench:       19022 ns/iter (+/- 32)

test es/full/codegen/es2015 ... bench:       19061 ns/iter (+/- 30)

test es/full/codegen/es2016 ... bench:       19085 ns/iter (+/- 37)

test es/full/codegen/es2017 ... bench:       19066 ns/iter (+/- 33)

test es/full/codegen/es2018 ... bench:       19023 ns/iter (+/- 59)

test es/full/codegen/es2019 ... bench:       19050 ns/iter (+/- 32)

test es/full/codegen/es2020 ... bench:       19065 ns/iter (+/- 50)

test es/full/all/es3 ... bench:    87371719 ns/iter (+/- 281454)

test es/full/all/es5 ... bench:    83584655 ns/iter (+/- 663850)

test es/full/all/es2015 ... bench:    64777174 ns/iter (+/- 369595)

test es/full/all/es2016 ... bench:    64382368 ns/iter (+/- 365596)

test es/full/all/es2017 ... bench:    64091412 ns/iter (+/- 137335)

test es/full/all/es2018 ... bench:    63352586 ns/iter (+/- 324142)

test es/full/all/es2019 ... bench:    63037412 ns/iter (+/- 234525)

test es/full/all/es2020 ... bench:    60795876 ns/iter (+/- 361287)

test es/full/parser ... bench:      298452 ns/iter (+/- 243)

test es/full/base/fixer ... bench:        7128 ns/iter (+/- 13)

test es/full/base/resolver_and_hygiene ... bench:       29270 ns/iter (+/- 23)



branch main 4623b3e

test es/full/codegen/es3 ... bench:       19495 ns/iter (+/- 18)

test es/full/codegen/es5 ... bench:       19512 ns/iter (+/- 37)

test es/full/codegen/es2015 ... bench:       19530 ns/iter (+/- 175)

test es/full/codegen/es2016 ... bench:       19203 ns/iter (+/- 150)

test es/full/codegen/es2017 ... bench:       19159 ns/iter (+/- 26)

test es/full/codegen/es2018 ... bench:       19234 ns/iter (+/- 129)

test es/full/codegen/es2019 ... bench:       19140 ns/iter (+/- 24)

test es/full/codegen/es2020 ... bench:       19299 ns/iter (+/- 93)

test es/full/all/es3 ... bench:    91211451 ns/iter (+/- 1635318)

test es/full/all/es5 ... bench:    86797890 ns/iter (+/- 1611765)

test es/full/all/es2015 ... bench:    66687091 ns/iter (+/- 241201)

test es/full/all/es2016 ... bench:    66647273 ns/iter (+/- 779345)

test es/full/all/es2017 ... bench:    66789866 ns/iter (+/- 1685761)

test es/full/all/es2018 ... bench:    67106011 ns/iter (+/- 2013955)

test es/full/all/es2019 ... bench:    65829994 ns/iter (+/- 1515881)

test es/full/all/es2020 ... bench:    63258515 ns/iter (+/- 310431)

test es/full/parser ... bench:      300185 ns/iter (+/- 372)

test es/full/base/fixer ... bench:        7071 ns/iter (+/- 91)

test es/full/base/resolver_and_hygiene ... bench:       29314 ns/iter (+/- 30)


@magic-akari magic-akari force-pushed the typescript branch 2 times, most recently from 07d6736 to a007015 Compare September 13, 2023 06:29
@magic-akari
Copy link
Member Author

@kdy1 This pull request is ready for review.

- use `Visitmut` instead `Fold`
- support verbatim_module_syntax
@kdy1
Copy link
Member

kdy1 commented Sep 22, 2023

image

😄

Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

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

Thank you so much!!!



swc-bump:

  • swc_ecma_codegen
  • swc_ecma_transforms_base

@kdy1 kdy1 enabled auto-merge (squash) September 25, 2023 00:55
Copy link
Collaborator

@swc-bot swc-bot left a comment

Choose a reason for hiding this comment

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

Automated review comment generated by auto-rebase script

@kdy1 kdy1 added this to the Planned milestone Sep 25, 2023
@kdy1 kdy1 merged commit 9c9a538 into swc-project:main Sep 25, 2023
249 checks passed
@magic-akari magic-akari deleted the typescript branch September 25, 2023 06:54
@kdy1 kdy1 modified the milestones: Planned, v1.3.89 Sep 25, 2023
@mischnic mischnic mentioned this pull request Sep 26, 2023
1 task
@swc-project swc-project locked as resolved and limited conversation to collaborators Oct 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.