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

Add swc transpilation behind a flag #11739

Closed
wants to merge 15 commits into from
Closed

Add swc transpilation behind a flag #11739

wants to merge 15 commits into from

Conversation

raix
Copy link
Contributor

@raix raix commented Dec 10, 2021

This pr swaps out babel and use swc for transpiling code building/testing

Overview:

  • Make start/build/test work with swc
  • fix any broken tests
  • enable browserlists support
  • Remove support for Flow (currently not supported in swc)
  • load project tsconfig/jsconfig and map into swc config
  • use ts-jest for jest ts/tsx file transformation (keeping an eye on stc) (keeping the scope of the pr to swc)
  • QA if project browserslist config is working
  • QA project tsconfig mapping works
  • QA project tsconfig is loaded in ts-jest
  • Add babel back
  • Move js/ts transformation out into separate files for swc and babel
  • Add and document SWC_TRANSFORM
  • QA both babel and swc configurations
  • Allow comments in jsconfig.json - we use this file to configure swc in non TypeScript projects
  • Cover by tests - reuse the kitchensink?

Notes:

  • Currently eslint use use babel parser (waiting for someone to write eslint in rust / swc ast or transform swc ast to espree ast?)

Dependency updates:

  • remove tar-pack seems to be unmaintained had a dependency on tar 2.x - we are now on tar 6.x
  • jest patch update to 27.4.4

BREAKING CHANGE:

@Bnaya
Copy link

Bnaya commented Dec 12, 2021

Will it land with CRA5? :)))

@raix
Copy link
Contributor Author

raix commented Dec 12, 2021

3 options as it removes support for Flow (on the short run) it's a breaking change - could be in v5, v6 or not at all 🙂

@raix raix added this to the 5.1 milestone Dec 12, 2021
@raix
Copy link
Contributor Author

raix commented Dec 12, 2021

We might add this behind a flag in 5.x to gather feedback for v6

@sshquack
Copy link

Thanks @raix It would fantastic to have this behind a FF for 5.x to benchmark on larger projects.

@raix raix changed the title Swap out babel with swc Add swc transpilation behind a flag Dec 13, 2021
@raix
Copy link
Contributor Author

raix commented Dec 17, 2021

Since we are adding json5 in this pr we should fix #7426 in the same go

Morten N.O. Henriksen added 2 commits December 19, 2021 07:43
Using JSON5 as projects with jsconfig.json might not have TypeScript installed - eg. VS Code reads the config + SWC is also configured via jsconfig.json in projects without TypeScript.
@raix
Copy link
Contributor Author

raix commented Dec 19, 2021

@mrmckeb regarding #7426 this pr adds support for comments in jsconfig.json - the pr uses jsconfig.json to configure swc language features - a project could then use jsconfig.json for configuring the IDE and swc without using TypeScript. I went for JSON5 as npm why json5 showed usage in multiple dependencies already.

@raix raix modified the milestones: 5.1, 5.0.1 Dec 19, 2021
@raix raix mentioned this pull request Dec 19, 2021
@kdy1
Copy link

kdy1 commented Jan 17, 2022

Hi. I'm the author of the swc project. I'm curious if there's something I can help.

Currently eslint use use babel parser (waiting for someone to write eslint in rust / swc ast or transform swc ast to espree ast?)

swc has code to convert swc AST into other estree AST, but it's not exposed as a js api just because there was no good usecase.

Does this still apply? I'm not sure if it's the case, and I'm also curious about tasks left.

@raix
Copy link
Contributor Author

raix commented Jan 17, 2022

Thanks @kdy1 this pr doesn't remove babel transform due to eslint, it sounds like it could be fairly trivial to create a swc-parser for eslint, if the espree ast is already in swc?

@kdy1
Copy link

kdy1 commented Jan 18, 2022

Yeah, I think so. It needs more testing about range fields of FunctionExpression, but it would not take so much time IMHO.

But I'm not sure about the API for it. Does parseAs sound good to you?

@iansu iansu modified the milestones: 5.0.1, 5.0.2 Apr 12, 2022
@krreet
Copy link
Contributor

krreet commented May 6, 2022

Hi @raix will it be possible to make some progress here and maybe land it in 5.0.2 ?

@raix
Copy link
Contributor Author

raix commented Aug 17, 2022

Would be awesome if anyone is up for taking over this pr - I'm currently out of time 🙏

@kdy1
Copy link

kdy1 commented Aug 20, 2022

@raix
Can you provide a list of plugins that require porting?

@raix
Copy link
Contributor Author

raix commented Sep 14, 2022

I think to remember that it was eslint only using babel - not sure if there's a eslint-swc parser. (It's along time ago since I did this work)

Congrats on you 25th b-day btw 🙂

@kdy1
Copy link

kdy1 commented Sep 15, 2022

Thank you!

@raix raix closed this by deleting the head repository Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants