-
-
Notifications
You must be signed in to change notification settings - Fork 247
WIP: Fix incremental api for vue files (#219) #220
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
Conversation
|
I noticed that this implementation has troubles with internal filenames on type errors. So I think a better approach would be to create the Host with allowNonTsExtensions and overwrite resolveModuleNames as VueProgram does, but I wasn't able to figure out how to set allowNonTsExtensions yet. I will take a closer look tomorrow so I'll mark this as WIP. |
|
Thanks so much for digging into this! Well done! 😄 Let me know when you think you're ready and I'll take a look. Thanks again! |
|
Hey @WolfspiritM, How's it going? Are you still working on this? |
|
@johnnyreilly Hi, Yes I'm working on it right now but having some problems. The problem I had was easily fixed by stripping the .ts extension from the diagnostics. That way upcoming tools like displaying the codeframe was able to find the file. But the main problem is the current way of "monkeypatching" getSourceFile won't work for the IncrementalApi as it creates the "real" CompilerHost "on the fly" and getSourceCode is a CompilerHost function. I got it working as expected by overwriting the hosts readFile and readDirectory but then was stuck with tsx support as typescript is checking the filename for that and without overwriting getSourceFile there is no way to let it know the scriptkind. So right now I'm overwriting readDirectory, fileExists and readFile of the host to let typescript think it's dealing with actual .ts and .tsx files. But the only way I can get it work is by reading the file on each access to figure out if it's a .vue.ts or .vue.tsx That should work but I'm not sure if that's a good approach. I wonder if it might be better to implement it similar to ts-loader and have loader properties: That way tsx code needs to go not in ".vue" but in ".vuex" for example and that way we can easily decide if to extend it with .ts or with .tsx. Any thoughts? |
740866c to
6d74947
Compare
|
This is what I came up with so far. There are still some tests failing which might all be related to a single error. The incremental API Version reports that error and I'm not sure why right now:
@johnnyreilly Could you take a look at it please and let me know what you think? |
According to Travis, all the tests are passing? 😊
It's an approach that seems to have served ts-loader well. What would be the implications of switching to this approach? Do you want to try it out and report back? |
|
ping @WolfspiritM 😄 According to Travis, all the tests are passing? ... Does this mean the approach works? Or is there a scenario the tests aren't covering? |
|
@johnnyreilly They pass cause it currently includes the check for vue that has been pushed to the master. So it's not using the incremental api for the vue tests. I won't have the time to look further into it until the weekend, sorry. 😕 |
|
Don't worry - take your time. We completely appreciate the help you're providing @WolfspiritM - there's no rush ❤️🌻 |
|
Heya @WolfspiritM I've just tweaked your branch so it runs the Vue tests when Also, reviewing some of your comments over the course of this PR I wonder if you might be interested in taking a look at some of the ideas in @phryneas PR here: #231 It has similar experimentation / thoughts around the module resolution which might be useful / interesting to you. (Or not - but there seems to be overlap and so I thought I'd draw your attention to it in case it's helpful) |
|
I will close it as there is no activity here, and I was able to release 5.0.0-alpha.1 version :) |
This is a first try to fix #219
As I'm new to the typescript compiler I'm not sure if it's the right way to do it.
Please let me know 😁
It adds ".ts" extension to all vue files by using the hooks.
It also hooks into getSourceFile of the program to return .vue.ts files as .vue so the linter is using the correct filename.
It is pretty similar to VueProgram which is not used in the Incremental API case (CompilerHost).
I also pushed the vue config down to the CompilerHost so any additional vue related code is only executed if vue is enabled.
This works as long as tsconfig does have "noEmitOnError" set to true.
Otherwise type errors don't seem to be reported correctly at all.
This seems to be like another issue so I'm going to open a new issue for that.