-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
deno fmt is slow #2490
Comments
Is it preferable/faster to do something ourselves rather than shell out to prettier? I was wondering if this is feasible to port: |
It would be great to use the built-in TS formatter (as that one you linked to does) but it doesn't support wrapping |
I looked into adding wrapping before, in addition to the TypeScript formatter, and it gets a bit ugly, and essentially you need to do an AST parse to make sure you are wrapping properly. It is non-trivial. I am not aware of something that effectively does that without a full AST parse. |
If we take this path, can we still depend on deno_std to use glob and walk functions? Or should we perform |
Importing deno_std stuff is a problem... We should solve that somehow. I wonder if we can use "deno bundle" for the main bundle now? |
Not sure. We would need to embed the loader in there, and we don't have source map support yet, so errors thrown in the bundle would be obscure. The main bundle would be easier than the compiler, with having to include TypeScript. It is worth trying to get to a point where we would be happy. Having even part of our bundles be build with Deno itself would be a good thing. |
I would advocate for that. This would allow people to format code in flaky or no network situations. For example, I downloaded |
@catastrop not very constructive feedback to be honest. Building a JavaScript/TypeScript formatter from scratch in Rust is a lot of work (with little value?). Unless you are aware of one that exists, than the suggestion isn't very practical. |
Consider using Then this js file is released with
|
We have a faster and established way of doing this with V8 snapshots. There are two issues
|
I feel like working on 1 first, and falling back to 2 if it simply doesn't match up to what is wanted, is probably a good way to move forward, since even if it doesn't work 100%, it would improve all deno code in general in terms of speed. Personally, it also feels a little odd to embed the formatter in the main deno executable, since it's a bit of a mixing of concerns (deno being the main runtime, and the formatter being purely a dev tool, not reliant on any of the internals). |
Personally, I like that Deno has common dev tooling out-of-the-box (like |
Speaking of formatting being slow... Last year, I implemented a small wrapper around Prettier called |
I'm not against having the subcommand (it's nice to have a common standard, although I'm not a massive fan of the formatting options :p), just embedding the tool directly in deno. The go CLI has |
If we were able to easily include prettier in the compiler snapshot without increasing the executable size massively, I'd totally go for it. I suspect when we try to do that experiment, that it might add 10MB ... that would be unfortunate. |
For the curious, here's the current size of prettier's dist:
|
Are these gzipped over the wire? Is deno using Accept-Encoding="gzip"? |
No, actually that is an interesting point, something we should consider when fetching remote modules, supporting both gzip and brotli for module transfer. Most of the servers support it and it would speed up fetching remote modules. I will open another issue for it. |
Actually I already did in #1533. Doh! I think we should still do that. |
I thought maybe #2477 would fix this, but it seems not. On investigating I think it's not the downloads which are slow(est): it's compilation. You can see this when passing -D. One thought is bundling but atm bundle doesn't support args (I don't think). The bundle is 12.4MB. It'd be great to see some flamegraphs/something to see what is taking the time here... |
I did some investigation into the slowness of "deno fmt" on first run. It appears to hang during TypeScript parsing of Ideally we'd be able to opt-out of TypeScript trying to parse that file... Maybe we should turn off |
@ry I believe this file is imported from other .ts file ( |
Would providing a |
I guess it should, I'm experimenting with it right now, but I found 2 nasty bugs along the way. Will get back EDIT: Yep, it's super fast when using type definitions. I'll write up issues and starting writing fixes for the bugs to get this working. |
No description provided.
The text was updated successfully, but these errors were encountered: