-
Notifications
You must be signed in to change notification settings - Fork 71
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
Add tslib to installation instructions #253
Conversation
This isn't Yarn PnP specific, it's required for all package managers, PnP just enforces it |
What happens currently? Does typescript pull its own version of tslib and plugin pulls in its own? |
✨ This is an old work account. Please reference @brandonchinn178 for all future communication ✨ Currently, because However, this is actually relying on incorrect behavior on npm's part, and yarn v2 fixes this by using a scheme called Plug'n'Play, where it doesn't use Because |
Hm, the plugin actually uses tslib at runtime here rollup-plugin-typescript2/src/tslib.ts Line 12 in 8d0d49c
Will that cause problems? Should we add tslib to both peer dependencies and dependencies? |
✨ This is an old work account. Please reference @brandonchinn178 for all future communication ✨ Interesting! Ok, then let's move it back to dependencies. I think, maybe, the @merceyz do you have any thoughts on this? |
9b5afc4
to
e27ff4b
Compare
This reverts commit 9b5afc4.
@ezolenko When you enable To illustrate this problem without PnP imagine for a moment there is no hoisting and you haven't added package.json
src
-> index.ts
node_modules
-> typescript
-> rollup
-> rollup-plugin-typescript2
-> node_modules
-> tslib Now when TypeScript has to import a helper from
@brandon-leapyear The solution here is for the user to add |
✨ This is an old work account. Please reference @brandonchinn178 for all future communication ✨ @merceyz Thanks! My question is more, is the "correct" solution to get |
Hm, this shouldn't be a problem unless typescript is used directly. Plugin resolves tslib itself, so when typescript tries to import it, it will generate import statement in js code (because of Does it break somehow? |
The correct solution is for the user to add
As I said, TypeScript will check if it's installed before injecting it, so the plugin changing it later doesn't matter. |
✨ This is an old work account. Please reference @brandonchinn178 for all future communication ✨
Would this be solved if TypeScript's check for |
That would still make you responsible for adding it as a dependency, it's not whether or not typescript can find it, it's if your project can. |
✨ This is an old work account. Please reference @brandonchinn178 for all future communication ✨ What do you mean? Isn't this error coming about when |
I think he is saying typescript itself will try to find tslib by its own means before generating import statement when transpiling ts. So it works if ts either doesn't check and just generate import (plugin will handle it), or it checks and finds it. |
PR is just a readme change now, I can merge it unless somebody things something else needs to be done? |
✨ This is an old work account. Please reference @brandonchinn178 for all future communication ✨
Version 2 of yarn uses Plug'n'Play, which means that the user's installed
typescript
(which is used becausetypescript
is set as a peer dependency for this plugin) won't have access to thetslib
marked as a dependency for this plugin.yarnpkg/berry#2140
People using version 2 of yarn have to manually install
tslib
indevDependencies
. This PR makes it so that everyone would need to manually installtslib
as well, which is what should actually happen.