supply resolveTypeReferenceDirective to ts-loader#10
supply resolveTypeReferenceDirective to ts-loader#10arcanis merged 4 commits intoarcanis:masterfrom johnnyreilly:master
Conversation
|
Looks good to me! I guess the easiest to test is probably to use a git url in the package.json, right? I can also publish a release in rc state if you'd like. |
|
Don't worry about publishing an RC. I was just going to test locally using the file protocol: https://docs.npmjs.com/files/package.json#local-paths But now you mention it, git is a fine alternative. 😁 |
|
I haven't forgotten about this - I just want to get a response from the TypeScript team on this question first: TypeStrong/ts-loader#934 |
|
I think we're safe to merge now that @andrewbranch has kindly fixed up ts-loader 😄 |
|
Hey @arcanis, I wanted to pick your brains. I've been working away on putting together some examples of how to use ts-loader with yarn PnP. I've got 2 examples in place: yarn PnP with ts-loaderThis works just fine as far as I can tell. yarn PnP with ts-loader and fork-ts-checker-webpack-pluginThis second example errors out with errors that suggest that It should be reproducible by doing the following: git clone https://github.com/TypeStrong/ts-loader.git
cd ts-loader
git checkout yarn-pnp-broken-example
cd examples/yarn-fork-ts-checker-webpack-plugin
yarn install
yarn buildThe code here is heavily inspired your PR to add PnP support to create-react-app with the fork-ts-checker-webpack-plugin: https://github.com/facebook/create-react-app/pull/6856/files Do you have any idea why this might not be working? side questionDo you think it would it make sense for What do you think? const {resolveModuleName} = require('ts-pnp');
exports.resolveModuleName = (typescript, moduleName, containingFile, compilerOptions, resolutionHost) => {
return resolveModuleName(moduleName, containingFile, compilerOptions, resolutionHost, typescript.resolveModuleName);
};
exports.resolveTypeReferenceDirective = (typescript, moduleName, containingFile, compilerOptions, resolutionHost) => {
return resolveModuleName(moduleName, containingFile, compilerOptions, resolutionHost, typescript.resolveTypeReferenceDirective);
}; |
You need to bump
Maybe, yep. My concern was mostly that it's a quite fork-ts-checker-webpack-plugin-specific plugin, but at the same time if the DevX is improved with only a few lines it's probably worth it 👍 |
[Face hits desk] Thanks - you're my idiocy linter 😄
Cool - should I add it to this PR or raise a different one? (I don't mind either way) |
|
Let's add it to this one! I guess we can use a similar API? Something like: module.exports.forkTsCheckerOptions = (options = {}) => pnp ? Object.assign({}, options, {
// ...
}); |
|
Oh I hadn't thought about it like that! Yeah I guess that makes sense 😁 Let me have a play and report back - might not get to do this immediately; about to go on hols |
|
No worry! Happy holidays 🍹🌴 |
|
Got this working using my original approach. (See linked PR) I've just noticed you've implemented the suggested options - good work! I'll try out the new API and report back 🤗 |
|
I've swapped to the new API. Take a look at this commit; mostly I just deleted code: TypeStrong/ts-loader@e59e4fa 😄 I think this means that dev-wise we're good to merge. We should probably update the |
|
So if there are yarn 2 t-shirts are there also pnp-webpack-plugin t-shirts too? 😉 BTW I've started work on a blog post about using ts-loader / fork-ts-checker-webpack-plugin with PnP. I want to publish it after we get this merged / released. I was going put reference in to the GitHub issues that, if resolved, will make yarn PnP more of a "default" node experience. Are these the ones to mention would you say?
|
|
Awesome! I added a note in the README about
Yep! Another one (and I'm afraid it's more a repo than one particular issue) would be the nodejs/module repository, which debates amongst other things how to properly integrate loaders with Node. It would be nice because:
We don't, but given how helpful you were I'd be happy to send you a Yarn tshirt 😊 Feel free to send me your contact info / tshirt size by mail and I'll see what I can do! |
Awesome 😘
Great work! That gives me an excuse to finish my blog post 😊 If it's cool with you I'll quote the following in some way in the blog post:
Happy to take updates on the post when it's done BTW. Most of my posts have patch releases 😀 |
|
Hey @arcanis, I've written usage of this up as this blog post: Are there any tweaks you'd suggest? I haven't publicised it yet... |
|
Nice post! Some more info:
|
|
Awesome points - thanks for adding! |
Now this is ballsy - I haven't tested this yet. But I'm guessing this is what we're going to need. Happy to report back when I've actually had chance to test this 😄