-
-
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
Fix options caching when ts-loader is used in multiple rules #782
Conversation
Thanks @yyx990803 - I really appreciate the effort! I'm away right now. I'll take a look at this upon my return - hopefully this weekend. |
Looks great - thanks! This will go out with the next release. |
It looks like this change may have cause problems for vue users of the fork-ts-checker-webpack-plugin. See details here: vuejs/vue-cli#1399 (comment) See also: TypeStrong/fork-ts-checker-webpack-plugin#121 @yyx990803 would you be able to advise please? See my details against the vue-cli issue |
Found out the problem. Interestingly, this is because in Note vue-loader v15 and above does not have this issue. Unfortunately I can't think of a way to make this change completely backwards compatible for this scenario. We have a few options:
|
Hey @yyx990803 Thanks for the thorough investigation! I agree that option 3 is a bad idea. Given that the problem ts-loader 4.3.1 introduces only affects vue-loader 14, I'm inclined to do this:
Does that sound good to you? |
@johnnyreilly yeah, that sounds good to me. |
So this is strange; I bumped the fork-ts-checker-webpack-plugin tests to use vue-loader 15 but the issue still seems to be present. You can see here: https://travis-ci.org/Realytics/fork-ts-checker-webpack-plugin/jobs/387922073 Have I misunderstood something? |
vue-loader 15 has breaking changes in terms of usage. I think it should be fixable by simply adding the required plugin (see here) |
Great; all good now! In summary I've:
If there's anything else you think worth doing then do feel free to suggest it. Thanks again for all your efforts @yyx990803 - you're a champ! |
@johnnyreilly cool! No worries about the other PR, thanks! |
Thanks for this post, you saved my night... |
If you want to work with Vue loader 14 and ts-loader 4.3.1 you could use the approach @yyx990803 illustrates here: https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/122/files |
Thank you for the link! I like to be up to date for all modules I use and I prefer to update to v15 in the same time as ts-loader 4.3.1. |
In case it helps this link helped me update to vue-loader 15: https://vue-loader.vuejs.org/migrating.html#template-preprocessing See how I applied these here: https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/123/files |
Before try to switch to v15 and 4.4.0 (not 4.3.1 since today!), I tried to use your Fork module. I know the link to migrate v15, I will retry to set my webpack config... |
I just want to point out that requiring v15 is a breaking change. |
I'm sorry that this caused you problems. Rationale: the problem ts-loader 4.3.1 introduced only affected an older version of vue-loader. I figured that didn't quite merit the version bump. Again, my apologies for your wasted time. |
This is a bug we discovered in latest Vue CLI 3 beta (ref: vuejs/vue-cli#1399).
When the webpack config contains multiple rules that use
ts-loader
but with different options, the current option caching implementation will incorrectly always use the cached options from the first matched rule. This is because the caching is done by using only the webpack instance + theinstance
option as the key - it's not taking multiple rules into account.This PR fixes it by ensuring each webpack instance + ts instance combo gets its own cache which caches validated options using a WeakMap.
The added test would fail without this fix as the options in the second rule will be ignored and
appendTsxSuffixTo
will take no effect.