-
Notifications
You must be signed in to change notification settings - Fork 56
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
Ideas on how to combine ttypescript with Yarn's PnPify? #87
Comments
Ideally, ttypescript should be pnp compatible. So one reason it is not compatible now is it using of |
The
Note that Yarn doesn't have a user-facing "custom TypeScript compiler". We patch the |
I close this issue because it works with pnp properly |
The one area where it doesn't totally work is with the custom VSCode support through custom TSDK, since Yarn's PnPify and ttypescript provide different tsdk files. I'm hoping VS Code will just adopt zip reading soon though so this custom tsdk from yarn is no longer necessary. |
Seems like it would be a big effort to get both tsdk files to work together and not sure it's really worth the effort. |
Context
I'm working on a tool for managing typescript monorepos. Kind of like Lerna, but it includes auto-generation of TypeScript project references + other quality of life improvements aimed specifically at typescript projects.
I've landed on making the tool a Yarn v2 (Berry) plugin, because Yarn's Plug n Play dependency system provides error-free hoisting unlike Lerna (packages' source within a PnP monorepo may only depend on what is in the package's package.json and cannot import hoisted deps depended on by other packages in the monorepo, and also packages are only installed once unlike node_modules which may install the same version of a packages nested multiple times which causes problems with libraries such as graphql-js which has instanceof checks which inadvertently breaks the symlink strategy used by Lerna).
Similar to ttypescript, Berry offers a package pnpify; it's a tool which creates an alternative
tsc
command to add PnP module resolution support for vscode and direct compiling: documented here. The tool modifiestypescript.tsdk
to point to a PnPify directory that contains its own implementations oftsc
&tsserver
.In addition to the pnpify tool which is offered, @arcanis from Yarn offered some additional guidance on how to add PnP support directly to a TypeScript compiler host itself. See here.
The Request
I want to continue using ttypescript which adds transformer support to typescript along with PnP which replaces typescript's module resolution algorithm, so I was hoping you could
provide some documentation on how to install ttypescript directly into a custom TypeScript compiler via the Compiler API.
Looking at the ttypescript source itself, it seems you are using the Compiler API, I just don't know if the ttypescript packages are modular enough right now to be used in this way I'm looking for.
I was hoping I could do something like this:
I haven't been able to figure out though if using the patched createProgram method from ttypescript will be enough though.
Also I'm open to other suggestions for solving this problem.
An alternative route I'm evaluating is just using Webpack 5 which has built-in PnP module resolution support, then using the ttypescript compiler w/ ts-loader.
The text was updated successfully, but these errors were encountered: