-
-
Notifications
You must be signed in to change notification settings - Fork 245
Add incremental compilation. #198
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
Thanks @0xorial - this is amazing work! We've got some failing tests:
Could you look into these please? Also, are we running the test pack with incremental watch API both on and with it off? Ideally we want to ensure we do this so there's no regressions to either mode going forwards. |
Very exciting by the way |
I had a quick look at the failing tests:
Both are failing as they're getting a
This one sounds more curious; it seems like a legitimate failure; 😢 |
Actually - I think all the failures came down to changes made in the https://github.com/Realytics/fork-ts-checker-webpack-plugin/blob/master/test/integration/project/src/index.ts file. We now have passing tests! I'll to give this a proper review soon. Thanks again for your work! |
src/CompilerHost.ts
Outdated
} | ||
|
||
public useCaseSensitiveFileNames(): boolean { | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this significant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks so; from a quick glance at usages of that function inside TypeScript I imagine it may cause some weird bugs on Linux. Glad that you noticed!
I tried running the standard integration test pack with
and the following tests failed:
Ideally we should look to get to a point where these would pass regardless of the mode. Obviously there's some nuance in this; |
A puzzle. Looking at the it('should find syntactic errors when checkSyntacticErrors is true', function(callback) {
var compiler = createCompiler({ checkSyntacticErrors: true }, true);
compiler.run(function(error, stats) {
expect(stats.compilation.errors.length).to.equal(2); // here we're expecting 2 errors
callback();
});
}); The equivalent test in it('should find syntactic errors when checkSyntacticErrors is true', function(callback) {
var compiler = createCompiler({ checkSyntacticErrors: true }, true);
compiler.run(function(error, stats) {
expect(stats.compilation.errors.length).to.equal(1); // here we're expecting 1 error
expect(stats.compilation.errors[0].rawMessage).to.contain('TS1005');
callback();
});
}); This is surprising - don't we want to expect the same number of errors regardless of mode? |
Thank you so much for your help with that PR! Just some of my story behind the tests....
Because of that I ended up extracting some helper code and creating a completely separate file, which only has cases which are relevant to the incremental compilation. Regarding the failing cases that you got, I am going to have a look at them, but at least some of those are probably due to differences in how incremental compilation works currently. |
Yep, that is the case that I was talking about. |
Cool - so this is actually the behaviour of the watch API I guess? In which case the difference makes sense.
Awesome - could we document the expected different behaviour in the tests somehow too please? Could be in comments, could be in the test name. I don't really mind but I just want it to be clear to anyone looking at the tests that there are expected differences in behaviour between the two approaches. |
Hey @0xorial! You're either going to love or hate my last commit. I've identified common tests and parameterised them to run with Does doing this torch your ability to debug? I'm open to changing this (or you changing this) to keep these tests debuggable. I place high value on debuggability. What say you? Also, question: the |
package.json
Outdated
@@ -88,7 +89,8 @@ | |||
"chokidar": "^2.0.4", | |||
"micromatch": "^3.1.10", | |||
"minimatch": "^3.0.4", | |||
"tapable": "^1.0.0" | |||
"tapable": "^1.0.0", | |||
"typescript-collections": "^1.3.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This dependency doesn't seems to be used, was it maybe included for the linked list at one point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right. removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your awesome work, I am looking forward to trying this feature out when it is merged :)
@johnnyreilly If the trade-off is between nicer code and simpler build/run/ide configuration, I would probably lean slightly to nicer code side. The main reason I didn't do anything like this myself was because I was not sure that changes so significant would be accepted :) But yeah, WebStorm does not recognize the cases as individual tests anymore, so there is no UI button to run them. On the other hand, I am a bit disappointed that mocha does not have any API to support tests with variable parameters - it seems like a rather essential feature. Personally, I would consider using a runner that does that (I don't know much about js test runners choices though :) ) |
Cool - I'll leave it as is for now then. It's pretty straightforward to unpick what I've done to make a test debuggable so I figure it's probably a good choice. It's pretty rare that you actually need to do that. (Though obviously super useful when the time comes 😁) Any thoughts on this:
|
Ah, sorry, missed that. I've quickly checked what is happening, and the checker finds syntactic error in 'syntacticError.ts', but it is ignored because checkSyntacticErrors is false. BTW, earlier I noticed that with {checkSyntacticErrors: false, tsLint: true}, syntactic errors are still shown because in that case linter starts producing them :) Or did I miss something? |
Really? 😄 No - haven't noticed that; maybe something to look into though!
I didn't quite follow what you meant here. Whilst // Semantic error
const x: number = '1'; So I'm puzzled this is not erroring at all. Or did I misunderstand your meaning? At the moment it looks like the incremental API is not surfacing semantic errors at all - which is obviously a big problem! 😄 |
Actually - I've dug into this myself. I follow what you meant. The project context includes a semantic error ( In fact even good.
|
vue projects supported? |
Yes - neither myself not @0xorial are vue users though, so all feedback on usage with vue will be appreciated! |
I've written another test @0xorial - this one is called Assuming CI passes I think we might be ready to merge! |
Okay let's merge this! I'll push this out as Please note that there's nothing to be scared about using To be clear, the I'll try and write a blog post this week to publicise this. |
Blogged about this here: https://blog.johnnyreilly.com/2019/01/typescript-and-webpack-watch-it.html |
#196