Skip to content
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

Support PnP in order to use with Yarn 2 #8292

Closed
kaushalyap opened this issue Feb 12, 2020 · 6 comments
Closed

Support PnP in order to use with Yarn 2 #8292

kaushalyap opened this issue Feb 12, 2020 · 6 comments

Comments

@kaushalyap
Copy link

Proposal

Getting rid of one of the blockers mentioned by @arcanis in here

Two blockers:

  • Flow is written in OCaml. This means that we cannot mount the zip file system on top of fs. Because of that, Flow has to have native support for zip archives. I pushed for it when I was at FB but it never happened, so I don't expect it to change anytime soon.
  • FB doesn't use PnP at the moment as they hit integration issues with their Buck setup, and noone really dared to confront it. As an unfortunate side effect, Flow silently removed support for the custom resolvers a few months ago (in 0.110, apparently).

Use case

Using Flow with Yarn 2

Related:

@AndrewPardoe
Copy link
Contributor

AndrewPardoe commented Feb 16, 2020

The Flow team has no plans to adopt support for Yarn 2 or PNP. The primary use case for Flow at Facebook is in support of React code. The React team has publicly stated that they have no immediate plans to support Yarn 2. There's a more thorough discussion here.

Edit: Note that the Twitter discussion linked contains members of both the React Native and React Core teams.

@kaushalyap
Copy link
Author

Thanks for the info, I'll keep this open since they may want to support it in the future when Yarn 2 is stable

@gaearon
Copy link
Contributor

gaearon commented Feb 21, 2020

To be clear, React itself has no opinions about PnP or Yarn 2. If it works for people, that's great. However, the React Native repository currently doesn't run with PnP, and we currently don't have plans to support that (because making a huge repository compatible is a lot of work).

@nicolo-ribaudo
Copy link
Contributor

I think that a solution is to add two options: module.resolver and module.loader. They would contain a command used to launch a third-party script to resolve/load modules.
I don't think that this command should be run for every file since it would kill performance: it should be spawned in background once and it should communicate with the flow process.

The module.resolver script would take two inputs (the specifier used in require/import, and the path of the file which contains the import statement) and output a resolved path. module.loader would take as input the resolved path, and output the file contents.


EXAMPLE

Consider this project, in the /project/ directory.

// index.mjs
import start from "./server";

start();
// server.mjs
import * as log from "logger";

export default function () {
  log.blue("Started!");
}
// "logger" (stored somewhere by Yarn)

export function blue(msg) {
  console.log(msg);
}

This is what would happen:

image

@jedwards1211
Copy link
Contributor

jedwards1211 commented Jan 5, 2021

@AndrewPardoe if import maps ever get standardized, do you think Flow would want to support them? As far as I understand the import maps would be static files, so resolution code could be implemented in OCaml instead of spawning node processes to call custom loaders.

And @gaearon same question about react-native, do you think react-native team would want to support import maps?

If so then this would be a good argument in favor of standardizing import maps to add to that linked discussion.

@SamChou19815
Copy link
Contributor

Closing for similar reason as #7014.

@SamChou19815 SamChou19815 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants