-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
feat(remix-dev): add support for Yarn 3 PnP #1316
Conversation
I chose to not further go down the path of getting the While copying all those files into a sub-directory could still work, I think it's easier to just accept that you'll need to import most things directly from I'm working on extending the create-remix package with an option for selecting the package manager. The resulting projects will then include all required dependencies to make Remix work with PnP, as well as changing all the imports from the |
b9ebb6b
to
a65c869
Compare
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳 |
35b097a
to
4afa342
Compare
Quick update: I'll continue working on this PR once the next yarn version is released. |
is there a chance these changes can get merged anyway. for people who are using yarn 3.2.0? |
Yarn 3.2.0 has just been released! 🎉 |
4afa342
to
f461671
Compare
From my tests with Yarn (with and without PnP enabled), almost everything appears to be working fine. |
I'm going to close this for the time being. We may revisit this down the road but we have some other priorities we need to focus on before we overhaul our repo tooling, as Yarn 3 is a pretty big shift from how we're doing things at the moment. |
Thank you for your response! It's mainly about declaring all direct and indirect (peer-)dependencies in all packages in order for yarn to stop complaining. The only actual changes to Remix features are
If you think that adding a yarn option to |
@cmd-johnson Thanks for clarifying, I must have misunderstood the intent here! Re-opened 👍 |
@cmd-johnson now that this is reopen do you plan to fix the conflicts and get this merged? |
They seem to change quite a few things around in the past couple of weeks. I just did that 4 days ago! 😄 Also I think I'd rather go the route of just adding a yarn example over adding an option for it to |
@cmd-johnson we made a pretty big impactful change by updating our prettier config. A simple way to reduce a lot of the merge conflicts might be to copy/paste the new config and run |
f461671
to
20361e3
Compare
There we go! |
will this be merged soon? |
@cmd-johnson would you mind fixing conflicts and applying @MichaelDeBoey suggestions? 🙏🏼 |
Thanks for all the hard work on this! I plan on discussing the optional dependency stuff with the team this week. |
After talking with the team, here is what we envision:
I think that means we can just add One hesitation I had about simply always including the esbuild pnp plugin is if we will need to conditionally use different resolutions/plugins for different package managers, e.g. Is there a good way to automatically detect if Yarn PnP is being used? If not, I think we'd prefer some config setting over detecting the presence/absence of I also had a couple questions about the code, but I'll leave those as comments on the code rather than within this higher level feedback. |
"@remix-run/serve": "1.5.1", | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2", | ||
"~": "link:./app" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this line do? I was expecting to see an import {...} from "~/...";
somewhere in the example codebase that exercises this, but maybe I'm misunderstanding the purpose of ~
and link:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, link:
protocol aliases the ./app
directory to ~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PnP doesn't know or care about tsconfig.json
files. In order to use the ~
alias that the other examples all provide through their tsconfig.json
, we can use the link:
protocol that yarn supports to remedy this issue. (See also https://yarnpkg.com/features/protocols#why-is-the-link-protocol-recommended-over-aliases-for-path-mapping)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok that makes sense, but I still can't find anywhere in the examples/yarn-pnp
code where the ~
is actually used.
If its not used at all, could we remove this alias from the example to keep things minimal?
The way esbuild-plugin-pnp does it is by checking if
As far as |
Good news, as this means we can put |
5f3f174
to
0a77f14
Compare
0a77f14
to
9ec397b
Compare
9ec397b
to
2bb697b
Compare
@cmd-johnson : changes to the Remix compiler look good! I think there are two main things left to do: (1) address @MichaelDeBoey 's comments for the example and (2) write an integration test that successfully builds a Yarn PnP / Remix app. ...then I think we should be good to merge this after. |
2bb697b
to
d800581
Compare
d800581
to
2631fec
Compare
@pcattori I've included the change requests and rebased on the Re: integration tests: any pointers how I should go about implementing them? |
2631fec
to
895a05c
Compare
@cmd-johnson : good point, figuring out how to test this is tricky. I'll think more about this today and get back to you. |
Going to merge this as-is without a test since its relatively simple / low-risk. If for whatever reason other changes break Yarn PnP support more than once or twice, we can revisit how to add a test. Thanks for everyone who participated in this PR and special thanks to @cmd-johnson for the work (and patience!). |
🤖 Hello there, We just published version Thanks! |
Yarn 3 has a feature called Plug'n'Play (or PnP), which, among other things, gets rid of the
node_modules
directory.Unfortunately, the way Remix modifies the
remix
package when runningremix setup node
is not compatible with PnP, because it tries to add/edit files in thenode_modules
directory.PnP also enforces that all dependencies by a package are included in their respective
package.json
file, even when the package already indirectly depends on them. Additionally,esbuild
doesn't work with PnP out of the box.I have made a few changes that should enable Remix to work with projects that are using PnP, which I have outlined in #683.
Builds using yarn 3.2.0 (which is currently in the canary stage) now work without having to disable the PnP feature.
What doesn't work though, is using the
remix
package. As far as I can tell, there's no easy way to change this.For now, you can work around this by importing from the
@remix-run/node
,@remix-run/server-runtime
,@remix-run/react
, ... packages directly.What could work, is to include everything the
remix
package does into the project directory. This could also be automated by e.g. adding a flag to theremix setup
command. That way, you would only have to change theimport {} from "remix";
imports toimport {} from "./remix";
. In TypeScript projects, the auto-generated files could also be added to thepaths
property in thetsconfig.json
, which means you wouldn't have to change the imports at all.I'm open for suggestions regarding the
remix
package issues with PnP and happy to implement them, if that will get PnP support added to Remix.