-
Notifications
You must be signed in to change notification settings - Fork 44
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 preprocess feature #62
Conversation
I saw the CI for node 8 also fails for |
There's some discussion of the Node version in #65 as well |
Thanks @benmccann for your comment. I guess both PR wont have conflict, but as you say, would be good to receive comments from other contributors in this package |
What's the status on this? |
@sarahscott I guess it'll be deprecated in favor of Svelte for VS Code extension + svelte-check package, please check this |
As far as I understand, |
efed8f5
to
e116804
Compare
i've tested this branch and this doesn't work yet unfortunately. code to test
used sample config from preprocess package readme |
@sdwvit I just updated the testing repo (https://github.com/NicoCevallos/eslint-svelte3-preprocess-test) and also I created a template repo with the latest version of svelte and related packages from the svelte template, you can check it here: https://github.com/NicoCevallos/svelte-template |
@NicoCevallos I tested your patches in my own project. works for me at the moment. |
@NicoCevallos have been using this in a new project for a few weeks and working also. Only thing we noticed is that the |
Just wanted to weigh in that this patch works for me as well. Would love to see this merged. |
Is this project still maintained? |
I installed your |
I had to change this setting to false to make it work, otherwise the editor was just preventing from saving the file. "editor.codeActionsOnSave": {
"source.fixAll": false
}, |
@jerriclynsjohn I'm experiencing the same issue. I did some debugging and found it was a problem coming from a combination of Running with
I did some (painful) console.log-ging and found it would freeze upon any await call (even something like Not sure what a course of action would be though, something hacky like spawning a new process for the compiler, having it write to disk, pinging the disk synchronously on the current process?. |
@jerriclynsjohn I've got mine to work, and have a utensil to share for it too (https://github.com/Sxxov/eslint-svelte3-preprocess). It's an ugly solution that very much shouldn't be used in anything serious (using Excited for how the final version of preprocessor support will look like. |
@sxxov Even with your fork, sometimes VSCode still doesn't overlay errors/warnings in the editor for EDIT: Upgrading ESLint from v6.8.0 to v7.15.0 seems to have fixed it. EDIT 2: When running through the CLI, it will hang and not finish the process. |
@gustavopch Hmm, interesting. I haven't tested this much, but I did notice some version problems somewhere (it working when i popped the test build straight in but not after i installed the required node_modules). Could it be that it's just slow? It takes around 3 seconds per lint task (vs ~30ms for pure typescript), and it runs on every keystroke. Normally you'd just add a sleep timer, or tolerance per key, but having everything single threaded makes that super difficult. This might be because it's building from scratch everytime instead of using caches (building svelte+typescript with snowpack is nearly instantaneous) For the CLI problem, I'm not sure for that either, as that was my known good. Could it be that you're running the global version instead of the project version, which may be 6.x.x? You could run with |
@sxxov At first, it seems to be slow, but that's just because there's an error here which makes the loop continue even after Regarding the CLI: no, it doesn't hang on the preprocessor step. It completes all the linting and even prints the errors/warnings to the console. It just happens that the process doesn't exit after that. It keeps running. I tried to force |
@gustavopch I'm not sure where the bug is, as that code is meant to break the loop when either The entire statement would evaluate to (the formatting on that statement is pretty wack though) The speed increase you're looking at might be the linter receiving The CLI part is interesting though. Maybe you could try with the original branch that i forked from and see if that would work? As I could only get the original branch to work on the CLI. Edit: it just clicked for me, and you're right, |
@gustavopch I think I've cracked the freezing! As well as improved performance ~10x (~300ms -> ~30ms per keystroke) according to some preliminary testing. Achieved by completely getting rid of Also, a lot of Check it out (https://github.com/Sxxov/eslint-svelte3-preprocess)
|
@sxxov Finally I've been able to try your last implementation. Thanks for sharing it with us! I have some suggestions:
I updated my gist with your improvements: https://gist.github.com/gustavopch/134513fa7c1f30050e968b5570c26994 (I'm a heavy TS user, but I think TS is not adding much value there, that's why I'm using vanilla JS in my gist). |
@gustavopch Heyo thanks for the free code review! Regarding the suggestions:
TS was mainly used because of the original repo xd. It helped a lot with prior implementations where I had to deal with Thanks again tho! I'll probably have commits up by today fixing the things |
@sxxov Thanks for the answers. 2. If you declare the worker inside the inner anonymous function, a new worker will be created for each file that's being linted (if ESLint is linting 10 files, you'll have 10 workers because the anonymous function is called once for each file). On the other hand, if you declare it inside the |
EDIT: Wait, I completely forgot I had to declare them outside so I could pass it into the worker instead, not because of performance at the end! I didn't wanna include the worker instantiation in |
@sxxov Forgot to mention that |
* housekeeping * clearer exports * clearer main thread executions * fixed ESM import.meta.url * not freeze in CLI sveltejs/eslint-plugin-svelte3#62 (comment)
@gustavopch Implemented most of your suggestions. The ones not implemented i have put some comments above them explaining why as well. Managed to figure out a way to get CLI's to not hang, while not needing to recreate the worker/rely on an actual timeout, too! |
@sxxov Great! Now, you mentioned those |
For those of you who participate in this PR because they want TypeScript support: With version 3.1.0, this plugin now supports TypeScript. |
Hi @dummdidumm , thanks for the good news but it doesn't cover scenarios where the user uses a custom preprocessing for other script languages. The intention of the preprocess feature is to allow the user to customize their preprocess as is done in the build process. |
I know, it's a solution specific to the TypeScript problem, not the general preprocessor problem. That's why I have written "for those of you who ... want TypeScript support". |
@sxxov & @gustavopch Thank you so much for your ideas to deal with the VS Code integration. I didn't know anything about workers and found your work very useful to deal with it. |
Understood, but... why not to move forward with this feature which allows to use the same configuration for this plugin, build process and IDE extensions like Svelte for VSCode? |
a85e9dd
to
1d03152
Compare
We chose to add support for specifically TypeScript first because it was easier to add support for and many people want it (more than those who want general preprocessor support I assume). The focus on a specific implementation also made for a nicer API and there's no need to use packages like |
With that said, I do see where you're coming from, since the scope of stable preprocessing is really big. I personally have encountered many nasty bugs while poking around (looking at you, prettier). Hope this feature makes it into the plugin one day! |
Considering the mild wackiness (it's not too bad now) of this async system, is it possible to just ship out-of-the-box support for everything that To be clear - I really want this merged, I use Stylus which is async. It's just that worker creation overhead adds some noticeable latency (last I checked), and it might be worth it to minimize that if possible. |
@dummdidumm I don't see any message saying "hey, can we find a solution without using |
@NicoCevallos I think the preference to avoid deasync was established here: #10 (comment) |
@Monkatraz If you haven't checked my previous comments, I've got some good news xd. I seemed to have cracked that with ~10ms of overhead on small files running on workers, instead of ~300ms to instantiate them everytime. Further benchmarking is required but I think this solution will be able to scale to medium/large sized files without an issue (been using it personally on files with hundreds of lines, don't ask why). The only bottlenecks I'm aware of atm is the 50mb fixed alloc for Your solution of using ""native"" sync solutions is interesting but I'm not sure what that would look like, any pointers? |
It would just be like the current TypeScript support, except with any other preprocessor. Although, with a 10ms instantiation latency, I seriously doubt it's worth doing sync. |
@aewing I didn't relate the "deasync" word with the |
I started copying the work done by @Conduitry in his/her fork and did some tests to fix it.
I created a package to use in the preprocessing returning the AST info for TypeScript and also a test project to show an example of how to use it.