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

rewrite compiler_imports.ts::processImports to Rust #4068

Closed
bartlomieju opened this issue Feb 21, 2020 · 2 comments
Closed

rewrite compiler_imports.ts::processImports to Rust #4068

bartlomieju opened this issue Feb 21, 2020 · 2 comments

Comments

@bartlomieju
Copy link
Member

bartlomieju commented Feb 21, 2020

Since we already depend on SWC I think it might be good idea to try and leverage it's speed.

processImports from cli/js/compiler_imports.ts is used to preprocess TS files and get import specifiers, then specifiers are used to download source files. If I'm not mistaken this step requires to parse AST of each file, which means there could potentially be great speed improvement by using SWC.

I imagine that by doing that in Rust we could feed all of source files to TS compiler in a single op instead of doing 2 ops for each processed file (resolve, fetch)

CC @kitsonk

@kitsonk
Copy link
Contributor

kitsonk commented Feb 21, 2020

If I'm not mistaken this step requires to parse AST of each file

It doesn't, it only does effectively a pattern match for import like statements. Ergo why it is preprocess, and quicker.

In my mind the earlier steps were to produce the AST for deno ast/Deno.ast() and see how that goes. Doing the dependency analysis would be the logical next step.

Some thoughts I shared with Ry:

Thinking out loud. Looked at swc. The parser is based off of Babel and so the AST is Babel like. The types are parsed and are part of the AST, but transforming it into TS AST for type checking would be tough. But from a transform, emit perspective it has everything we need.

It does in theory make tree shaking possible, as the Babel AST is estree like.

I still think it would be good to start by exposing the parser and maybe the transformer in the runtime.

@bartlomieju
Copy link
Member Author

If I'm not mistaken this step requires to parse AST of each file

It doesn't, it only does effectively a pattern match for import like statements. Ergo why it is preprocess, and quicker.

That makes sense, thanks for explanation.

In my mind the earlier steps were to produce the AST for deno ast/Deno.ast() and see how that goes. Doing the dependency analysis would be the logical next step.

👍 in the light of above I agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants