resolveTypeReferenceDirective support for yarn PnP#921
Conversation
|
Awesome 👍 |
|
First question: The PnP docs point you here: https://github.com/arcanis/pnp-webpack-plugin#ts-loader-integration Which suggests you should use the const PnpWebpackPlugin = require(`pnp-webpack-plugin`);
module.exports = {
module: {
rules: [{
test: /\.ts$/,
loader: require.resolve('ts-loader'),
options: PnpWebpackPlugin.tsLoaderOptions(),
}],
},
};In fact
So it looks like we should be using That being the case, It looks like a tweak may be required here: module.exports.tsLoaderOptions = (options = {}) => pnp ? Object.assign({}, options, {
resolveModuleName: require('ts-pnp').resolveModuleName,
}) : options;To add in Does that sound right? Also, I'm guessing using Otherwise you would have to manually supply this option to Do I have this about right? |
Yep - although my warning in The wording is mostly intended for average users, which don't really care much about the setup of TS and PnP and just want something that work out of the box. In their case they can just use |
|
Hey @arcanis, I've implemented what I think makes sense based on our conversation. Do you want to take a quick glance and let me know if I'm headed roughly in the right direction? There's a bit of noise in the |
arcanis
left a comment
There was a problem hiding this comment.
Looks good to me from an implem standpoint!
| trace: log.log, | ||
| log: log.log, | ||
|
|
||
| /* Unclear if this is useful |
There was a problem hiding this comment.
I know, right? How could I imagine a comment like that wouldn't come back to bite me 😄
This PR should (when completed) add
resolveTypeReferenceDirectivesupport to ts-loader to complement the existingresolveModuleNameadded by @arcanis in #862 which was added to support yarn PnP.Other inspiration: TypeStrong/fork-ts-checker-webpack-plugin#250
I've a number of questions which I'm hoping people can advise on. I'd like to use this PR to go through these as I think the answers to them will be a generally useful resource in future.
Heads up: I have never used PnP before, but I'm excited the possibilities it may provide. I think it's somewhat useful that I don't know tons about it as the questions I ask will likely be the sorts of things that others wonder about too.
I hope this is cool with you @arcanis?
So this PR should be a combination of discussion and then implementation informed by the discussion.