question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add new moduleResolution option: `yarn-pnp`

See original GitHub issue

Search Terms

yarn pnp plug’n’play plug

Suggestion

Yarn has released a new feature for using modules without having a node_modules directory present: plug’n’play. Some community tooling is available for customizing the TypeScript compilerHost so that it can use plug’n’play modules, but this does not work for users of tsc.

My suggestion is to add a new "moduleResolution": "yarnpnp" option.

Use Cases / Examples

I want to be able to use yarn plug-n-play in my typescript projects. My projects are typically yarn monorepos where common libraries are basic node packages using tsc for compilation. This would allow the basic projects to continue using tsc, but with an alternative module resolution scheme.

Some community tooling has been created here for augmenting the CompileHost with a slightly updated moduleResolution strategy, but using it in basic projects would probably require a forked tsc.

https://github.com/arcanis/ts-pnp

Checklist

My suggestion meets these guidelines:

  • This wouldn’t be a breaking change in existing TypeScript / JavaScript code
  • This wouldn’t change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn’t a runtime feature (e.g. new expression-level syntax)

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:298
  • Comments:42 (6 by maintainers)

github_iconTop GitHub Comments

85reactions
jeysalcommented, Mar 20, 2019

Sorry if this is kind of a “+1” comment, but it looks like there are already solutions proposed and this is in a state where all that’s needed is commitment from the TypeScript team. We’ve tried to use Yarn PnP in the Jest repo before and post migration from Flow to TypeScript, and this is currently the biggest blocker, the other somewhat big one being ESLint’s import rules. I think this is really essential to helping PnP gain traction, because it enables other large projects that depend on TypeScript for their type checking / build process to use PnP, helping it mature and become more visible as a practical alternative to node_modules 🚀

77reactions
arcaniscommented, Mar 7, 2019

For what it’s worth the PnP runtime is now decoupled into its own package, which should solve one of the main concerns the TS team had (they can now simply read the PnP data without executing any third-party code). I’d be more than happy to finally meet and discuss how to make this happen, but I don’t feel like the ball ever was in my camp.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Plug'n'Play | Yarn - Package Manager
An overview of Plug'n'Play, a powerful and innovative installation strategy for Node.
Read more >
get rid of node_modules with Yarn Plug'n'Play - Medium
With Yarn PnP, you: say bye to node_modules, reduce installation time ... Just append the --use-pnp option to the create-react-app command ...
Read more >
VS Code and Yarn PnP - typescript - Stack Overflow
4 fixes it: yarn remove typescript; rm -rf .yarn/sdks/typescript; yarn add -D typescript@4.4.4; yarn dlx @yarnpkg ...
Read more >
ts-loader - npm
yarn add ts-loader --dev ... The recommended way to integrate is using the pnp-webpack-plugin. ... baseUrl / paths module resolution.
Read more >
Yarn Plug'n'Play: Getting rid of node_modules | Hacker News
So best of luck to make Node + NPM + Yarn to agree on a new path ... fall back to Node's module...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found