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

Document Yarn Plug'n'Play #869

Closed
10 tasks
arcanis opened this issue Oct 4, 2018 · 12 comments
Closed
10 tasks

Document Yarn Plug'n'Play #869

arcanis opened this issue Oct 4, 2018 · 12 comments

Comments

@arcanis
Copy link
Member

arcanis commented Oct 4, 2018

We should document this to prepare for the 1.12 to move into stable.

  • Short summary of what is Plug'n'Play
  • A page describing high-level effects
  • A page describing the Plug'n'Play interfaces
    • The API (require('pnpapi'), resolveToUnqualified, resolveQualified, resolveRequest)
    • The command line interface (+ "daemon" mode)
    • References build-pnm
@empyrical
Copy link

I noticed that you added custom resolver support to flow:

facebook/flow#6132

Does this help flow with PnP? If so, a mention on how to use Flow with PnP might be good too!

@arcanis
Copy link
Member Author

arcanis commented Nov 13, 2018

Hey! Yes, Flow is supported out of the box - you just have to set the module.resolver option to your .pnp.js file (possibly using <PROJECT_ROOT> if you want) and you're good to go (note that you also need to make sure you're using the haste resolution).

@langri-sha
Copy link

@arcanis thanks for all the awesome work! Do you have a sample repository where Flow works?

I'm trying to setup a simple repository, but the Flow server seems to crash while starting up:

Dec 20 13:53:01.359 [info] argv=/home/filip/.cache/yarn/v4/npm-flow-bin-0.89.0-6bd29c2af7e0f429797f820662f33749105c32fa/node_modules/flow-bin/flow-linux64-v0.89.0/flow start --flowconfig-name .flowconfig --from parent cmdline: /home/filip/.config/yarn/global/node_modules/node-8/bin/node /home/filip/.cache/yarn/v4/npm-flow-bin-0.89.0-6bd29c2af7e0f429797f820662f33749105c32fa/node_modules/flow-bin/.bin/flow --temp-dir /tmp/flow /home/filip/work/yarn-pnp-flow-typed
Dec 20 13:53:01.359 [info] Creating a new Flow server
Dec 20 13:53:02.272 [error] Closing connection 'server #1' due to uncaught exception in read loop: End_of_file
Dec 20 13:53:02.272 [error] backtrace:
Dec 20 13:53:02.272 [error] Raised by primitive operation at file "src/unix/lwt_unix.cppo.ml", line 1549, characters 50-67
Dec 20 13:53:02.272 [error] Called from file "src/unix/lwt_unix.cppo.ml", line 563, characters 17-28
Dec 20 13:53:02.272 [error] 
Dec 20 13:53:02.287 [error] Flow server (pid 14374) exited with code Unknown_error (110)
Dec 20 13:53:02.288 [info] Monitor is exiting (Dying along with server)
Dec 20 13:53:02.288 [info] Broadcasting to threads and waiting 1 second for them to exit

@goodmind
Copy link

goodmind commented Dec 29, 2018

Have problems with flow too:

Cannot resolve module
/Users/goodmind/Library/Caches/yarn/v4/npm-react-16.7.0-b674ec396b0a5715873b350446f7ea0802ab6381/node_modules/react/index.js.

Flow version: 0.89.0
Yarn version: 1.12.3

# .flowconfig
[options]
module.system=haste
module.resolver=<PROJECT_ROOT>/.pnp.js

@arcanis
Copy link
Member Author

arcanis commented Dec 29, 2018

Do you run flow through yarn flow? If so, I think this might be a side effect of yarnpkg/yarn#6629 - Node is bootstrapped with the hook preloaded (before process.mainModule is ready), and since Node never loads the same file twice it never gets executed in a context where process.mainModule is ready - meaning that it exits here instead of spawning the process.

I'll see to fix that; in the meantime, a simple workaround is to make a bash script as resolver, that contains something like this:

#!/usr/bin/env bash
NODE_OPTIONS='' node ./.pnp.js

This will prevent the resolver from being injected.

@goodmind
Copy link

@arcanis Unfortunately, still doesn't seem to work

[options]
module.system=haste
module.resolver=<PROJECT_ROOT>/pnp.sh
#!/usr/bin/env bash
NODE_OPTIONS='' node ./.pnp.js

Can this be related to workspaces?

@arcanis
Copy link
Member Author

arcanis commented Dec 30, 2018

Nope, I don't think - is pnp.sh executable (chmod +x pnp.sh)?

@goodmind
Copy link

@arcanis yes -rwxr-xr-x

@arcanis
Copy link
Member Author

arcanis commented Jan 24, 2019

Fixed by #907

@arcanis arcanis closed this as completed Jan 24, 2019
@Billy-
Copy link

Billy- commented Jan 24, 2019

I notice the new documentation is now available at https://yarnpkg.com/en/docs/pnp (:tada:) and has a card/link on the docs homepage to it. But I can't get the "search documentation" box to return any results.

@arcanis
Copy link
Member Author

arcanis commented Jan 24, 2019

I think it's just a matter of waiting for the Algolia cache to catch up, no worry ☺️

@Haroenv
Copy link
Member

Haroenv commented Jan 24, 2019

Yep, the docs are crawled every 24h

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

6 participants