Skip to content

Explore "transpile only" build  #150025

Closed
Closed

Description

For CI builds we should explore the use of a fast transpiler, like SWC or esbuild. This would enable use to run (blocking) transpile, then in parallel run tests and TS type checking.

SWC transpile command: npx swc --config-file .swcrc src --copy-files --out-dir out


The joh/swc-branch has some changes that explore to use SWC for this. TODOs

Activity

  1. kwonoj commented on May 20, 2022

    @kwonoj

    👋 Just want to say excited to see vscode explores swc as transpiler and happy to try to support as much. Please drop by swc repo if there's something to followup (Yes, saw one issue filed already)

  2. added
    engineering
    on May 23, 2022
  3. kwonoj commented on May 23, 2022

    @kwonoj
  4. jrieken commented on May 24, 2022

    @jrieken
    ContributorAuthor

    OJ Kwon (@kwonoj) Awesome. What's your release cycle like? We are now heading into endgame and I'll be able to pick this up early June again. Are those fixes published by then?

  5. kwonoj commented on May 24, 2022

    @kwonoj

    We should able to. Donny/강동윤 (@kdy1) , if we didn't publish new one can we do it for @swc/core?

  6. kdy1 commented on May 24, 2022

    @kdy1
    Contributor

    I triggered a publish of a new version

  7. jrieken commented on May 25, 2022

    @jrieken
    ContributorAuthor

    Donny/강동윤 (@kdy1) OJ Kwon (@kwonoj) Thanks so far. With 1.2.192 things are looking better but I ran into two further bugs with AMD's local require-function: swc-project/swc#4798 and swc-project/swc#4797. Let me know if you need further clarification or help. Thanks a ton!

  8. kwonoj commented on May 25, 2022

    @kwonoj

    Thanks, I'll try repro.

  9. kwonoj commented on May 25, 2022

    @kwonoj

    swc-project/swc#4800 is updated for 4798/4797.

  10. jrieken commented on May 25, 2022

    @jrieken
    ContributorAuthor

    Thanks - I am OOO for a bit and I'll pick this up again early June

  11. jrieken commented on Jun 10, 2022

    @jrieken
    ContributorAuthor

    Donny/강동윤 (@kdy1) OJ Kwon (@kwonoj) Any chance for releasing a new version of SWC with your latest fixes? We should be pretty close.. With 1.2.197 97% of our unit tests already pass

  12. kdy1 commented on Jun 10, 2022

    @kdy1
    Contributor

    Currently CI of swc is broken due to recent changes of github actions, but it's almost fixed by another team member.
    Once he sends a PR for fixing CI scripts, I'll publish a new verion.

  13. kdy1 commented on Jun 11, 2022

    @kdy1
    Contributor
  14. 8 remaining items

  15. kwonoj commented on Sep 1, 2022

    @kwonoj

    👋 Casually checking in (not urging or pushing anything), if there's some progress or if there are any blockers in upstream swc land we can try to fix forward?

  16. jrieken commented on Sep 2, 2022

    @jrieken
    ContributorAuthor

    OJ Kwon (@kwonoj) Great timing! Two days back I have merged #159300. For CI/CD we now use SWC to transpile our "client" bits (basically all of VS Code but not yet its builtin extensions). Look out for transpile-client-swc in our PR checks (random sample).

    Random observations and things that can be improved

    • I ended up with two separate config files (one for amd and one with no module system) because I couldn't figure out how to achieve this in one config file 🙈. We had discussed this but I couldn't get it working with a single file. Maybe you have more insights
    • Transpile is part of our ancient gulp pipeline but we don't use SWC as library- we simply shell out to swc-cli. That's good because we don't need to pipe files around but ideally we shell out to the native executable directly so that we don't use JS to write files. OJ Kwon (@kwonoj) Donny/강동윤 (@kdy1) Do you have any clue what the perf difference would be (write files from rust instead of JS)?
    • Along the way we also added a transpiler that uses TypeScript's transpileModule-API. We have this as fallback/alternative just in case something goes wrong (new TS version that SWC hasn't adopted yet, etc). SWC is faster but "only" twice as fast, do you think more could be gained with SWC? Like avoid swc-cli or swc-core and use the binaries directly?

    Donny/강동윤 (@kdy1) OJ Kwon (@kwonoj) With all that said: a very big "Thank You" for SWC and for the instant help and fixes. We are all very excited about this and hope to get involved more deeply (use SWC to watch-transpile on our dev machines etc)

  17. kwonoj commented on Sep 2, 2022

    @kwonoj

    I couldn't figure out how to achieve this in one config file

    Let's retry this. If you don't mind share some minimal repro you'd like to try (and not working), I'll try to peek.

    ideally we shell out to the native executable directly so that we don't use JS to write files

    Correct, native cli should be more performant. Not cause of writing performance, there are few things we may consider

    1. You don't need to cost spin node.js process: npx runs node.js script under npm's env, and then swc-cli itself runs with node.js again. Native cli won't need those bootstrap performance.

    2. Native cli can parallelize multiple inputs when performing transform, without back and forth v8's async event loop

    Currently, most of @swc/core native bindings ships with experimental native cli. You may give it a go, and if there's some missing features / bugs we can try to fix it forward.

    SWC is faster but "only" twice as fast, do you think more could be gained with SWC

    This sounds odd. When I tried transform performance with some large scale codes, even though it was compared with babel it was much visibly faster. I guess we could try to create some isolated cases to dig deeper, probably using either native cli / or node.js bindings api directly. It is totally possible js based cli's overhead cuts off some perf gains.

  18. kdy1 commented on Sep 2, 2022

    @kdy1
    Contributor

    There are some code which make handling of small files faster but have exponential time complexity.

    What's your target/.swcrc and input?

  19. jrieken commented on Sep 2, 2022

    @jrieken
    ContributorAuthor

    Let's retry this. If you don't mind share some minimal repro you'd like to try (and not working), I'll try to peek.

    Repos with a .swcrc-file that is an array, not object. I can file a real issue, the task I want to solve is that for one source file we need a different module system - all files should be compiled with AMD, except for vs/base/worker/workerMain.ts

    EDIT: created swc-project/swc#5720 to follow up on this

  20. jrieken commented on Sep 2, 2022

    @jrieken
    ContributorAuthor

    This sounds odd. When I tried transform performance with some large scale codes, even though it was compared with babel it was much visibly faster. I guess we could try to create some isolated cases to dig deeper, probably using either native cli / or node.js bindings api directly. It is totally possible js based cli's overhead cuts off some perf gains.

    Yeah, that's what I though. In all fairness, we have custom code around transpileModule which uses NodeJS worker threads and other perf tricks. I'll explore how to use the native cli directly. Does @swc/core come with an API that exposes the path of the actually binary? (so that this is easy across platforms)

  21. kwonoj commented on Sep 2, 2022

    @kwonoj

    Does @swc/core come with an API that exposes the path of the actually binary? (so that this is easy across platforms)

    No, but calculation is rather straightforward: https://github.com/swc-project/swc/blob/7a6a43576a3388cb07d6c8923b9118228b8e09f0/node-swc/src/run_swcx.ts#L39-L80

    You can try to copy-paste with small modifications, maybe. Or you could do npx swcx, but I do not recommend since it'll require spinning npm for the npx execution then it goes to another spawning to swc cli.

  22. jrieken commented on Sep 5, 2022

    @jrieken
    ContributorAuthor

    You can try to copy-paste with small modifications, maybe

    This looks promising: I am running /Users/jrieken/Code/vscode/node_modules/@swc/core-darwin-arm64/swc compile --config-file build/lib/swc/.swcrc-amd --out-dir out3 --source-root src/ src/**/*.ts. I do get output but it is rooted at out3/src/vs instead of out3/vs. Do I need to pass another value to source-root or how is that meant to work?

  23. kwonoj commented on Sep 6, 2022

    @kwonoj

    Do I need to pass another value to source-root or how is that meant to work?

    I believe it's simple lacks of features (after all, native cli is still not yet feature-complete). If you don't mind file an issue in upstream swc, I'll try to assign myself.

  24. jrieken commented on Sep 7, 2022

    @jrieken
    ContributorAuthor

    With #160274 we now have SwcTranspiler which we use to transpile the client and all extension bits. This transpiler can be used interchangeably with the TscTranspiler but is ~3 times faster.

  25. added
    feature-request
    on Sep 7, 2022
  26. added
    on-release-notes
    and removed
    feature-request
    on Sep 28, 2022
  27. locked and limited conversation to collaborators on Oct 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

engineeringon-release-notes

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions