Closed arcanis closed 5 years ago
I noticed that you added custom resolver support to flow:
https://github.com/facebook/flow/pull/6132
Does this help flow with PnP? If so, a mention on how to use Flow with PnP might be good too!
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).
@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
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
Do you run flow through yarn flow
? If so, I think this might be a side effect of https://github.com/yarnpkg/yarn/pull/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.
@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?
Nope, I don't think - is pnp.sh
executable (chmod +x pnp.sh
)?
@arcanis yes -rwxr-xr-x
Fixed by #907
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.
I think it's just a matter of waiting for the Algolia cache to catch up, no worry ☺️
Yep, the docs are crawled every 24h
We should document this to prepare for the 1.12 to move into stable.
require('pnpapi')
,resolveToUnqualified
,resolveQualified
,resolveRequest
)