-
-
Notifications
You must be signed in to change notification settings - Fork 431
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
Don't include appended TS extension in webpack dependencies. #497
Don't include appended TS extension in webpack dependencies. #497
Conversation
Thanks for the PR - we really appreciate it! Just waiting to see if the tests pass.. |
Think the failure might just be flakiness. Have restarted the associated test pack |
Okay we're good to merge insofor that existing functionality is not impacted. My 1 reservation is we have no test that will prevent regression in future. My feeling is that a comparison test would cover this. Have a read of the readme under comparison tests for a proper run through of how these work. Essentially these tests use watch mode. The presence of a The output that would result (specifically If you'd like an example of what a test that works like this looks like then take this one: https://github.com/TypeStrong/ts-loader/tree/master/test/comparison-tests/aliasResolution Notice https://github.com/TypeStrong/ts-loader/tree/master/test/comparison-tests/aliasResolution/patch0/common/components which is applied 5 secs after initial compilation. Notice https://github.com/TypeStrong/ts-loader/tree/master/test/comparison-tests/aliasResolution/expectedOutput-2.2 which is the output Notice https://github.com/TypeStrong/ts-loader/blob/master/test/comparison-tests/aliasResolution/expectedOutput-2.2/output.txt which is the Any questions then shout - I'm aware it's a little complicated. It's the price we pay for preventing regressions... |
I had a go at writing a comparison test. 'Output.txt is generated from the
stats output which details all bundles, not just the ones built or
individual resources loaded.
Any ideas would be appreciated!
…On Fri, 10 Mar 2017 at 6:14 pm, John Reilly ***@***.***> wrote:
Okay we're good to merge in that existing functionality is not impacted.
My 1 reservation is we have no test that will prevent regression in future.
My feeling is that a comparison test would cover this. Have a read of the
readme under comparison tests for a proper run through. Essentially these
tests use watch mode. The presence of a patch0 directory allows for the
simulation of updating a file during watch mode. This is exactly what you
want to test. The output that would result (specifically output.txt after
the file update) should indicate that, with your PR, less files are being
recompiled. You should be able to repurpose your example repo into a
comparison test and I'll be happy to advise. BTW, we only need to generate
test output for the latest version of TypeScript; 2.2.1.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#497 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA8NUZAYgs1fFjc-pvheXCdlgz-zRlw7ks5rkRSBgaJpZM4MZE_A>
.
|
I think that's okay though isn't it? Isn't the important bit the I think a good illustration of this is the issue372 (shocking name) test. Here's the initial output:
Here's the patch0 output :
So the verification that your change works correctly is the number of modules that are listed with |
Cool thanks I'll take a look. |
BTW I'm curious why the loader needs to manually add all dependencies and not just declaration files? |
I didn't write that so I'm not sure. I'd speculate it's because webpack receives the JavaScript not the TypeScript. So if there's an import statement for an interface then webpack won't know about it unless you tell it explicitly. But as I say; I didn't write that so I'm not totally sure. |
It was because Webpack had no way to remove dependencies other than clearing them which also messed with dependencies that webpack itself added. So the loader had to take over adding those dependencies back as well. At least that's my recollection. That was like 2 years ago though so things could have changed since then, esp. with the release of webpack 2. The reason that you need to clear (instead of just being additive) is that it's possible for the source to remove dependencies. |
@jbrantly thanks for the info!
What exactly does that mean? If typescript is removing dependencies, wouldn't the import statement be missing from the transpiled JS and therefore not be picked up by webpack? Cheers! |
I guess the test is still a work in progress? |
Also, didn't you want to use the patch approach to test dependencies are built in the manner you hope? |
@WearyMonkey See #471 for more details on clearDependency/addDependency. Fairly, what needed here is just adding declaration file to watch list and re-checking the whole program once a watchee is changed. The same approach is adopted by atl. |
If you're having problems then feel free to post the issues you're experiencing. I'm happy to be on hand to provide advice as you work on this. |
Cheers! I'll take another look at this tonight.
…On Mon, 13 Mar 2017 at 8:15 pm, John Reilly ***@***.***> wrote:
If you're having problems then feel free to post the issues you're
experiencing. I'm happy to be on hand to provide advice as you work on this.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#497 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA8NUU9mKaGsXTekMijuP2JTiVk29WSRks5rlSU7gaJpZM4MZE_A>
.
|
The difficulty I encounter is non deterministic stats. I cannot even make test pass on the master branch. |
Yeah - I'm open to this. I inherited the the comparison test pack; the grunt work was done by @jbrantly. It has become progressively less strict in the time that I've been looking after ts-loader. Take a look at the functions starting here for examples of the sorts of differences in output that the pack now allows. If it makes sense to take this further than that's totally on the table. |
@johnnyreilly the latest test failures are due to |
It could also explain some the of the flakiness in other tests. |
Actually that's an interesting point. @jbrantly - would you be able to advise on this?
Is there any reason that we always increment versions here? There's no test to see if there is a difference from the previous version which would seem like a reasonable thing to do. Can you recall why this was? I'm guessing the implicit assumption is that if a file is supplied then it has changed. Hence this implementation; but I don't actually know. If you can recall that would be handy info. |
FWIW we didn't use |
@johnnyreilly What did work for me was manually tracking timestamps for changes, e.g.:
|
You're quite right; it was and there's a story behind it 😉 Essentially it was re-added as deprecated to avoid breaking ts-loader / atl etc. We can't rely upon it and need to stick with
I rather suspect we should switch to use this approach in place of what we have at present. |
Well here's my PR: #500 :) |
Thanks! I've commented there. Just going offline for now... |
Just merged #500 and published v2.0.2 - just realised I'd forgotten all about the original PR! |
@johnnyreilly sorry for being unresponsive, have been travelling. Is there a way to trigger a CI build of this branch off the new master? |
I've just retriggered a build. I think that runs off the new master.... |
@johnnyreilly so I guess this is good to merge? |
Yes - it will be. I've got a lot going on right now for my wife's birthday. But yes it will be! |
No worries :) happy b'day to your wife! |
ts-loader incorrectly includes the appended '.ts' suffix of files matching the appendTsSuffixTo option in the dependency path, e.g.
addDependency('styles.css.ts')
.As webpack is unable to find these files on the filesystem it appears to mark the module as dirty when ANY file in the entry point's dependency tree changes. The end result is any change will cause all modules to be re-compiled.
As the bug affects watch mode, I could not find a way to verify the fix in the current test infrastructure.
I did however create a sample project here:
https://github.com/WearyMonkey/ts-loader-dependencies-bug
fixes #496