Open steida opened 5 years ago
I think the issue is here:
https://github.com/facebook/relay/blob/master/gulpfile.js#L119
Relay compiler is bundled by webpack into bin/relay-compiler
. I think the intention of the externals
regex was to exclude any third party modules from the bundle, but it does not match @babel/polyfill
.
So that package is inlined into relay-compiler
but it's imports from core-js
are not. Now to yarn pnp it looks like relay-compiler is importing core-js
directly without specifying it as a dependency.
Fixed by adding missing dependencies to packageExtensions
:
packageExtensions:
babel-plugin-relay@*:
dependencies:
"@babel/runtime": ^7.12.5
relay-compiler@*:
dependencies:
relay-compiler-language-typescript: ^13.0.2
relay-config: ^10.1.3
We're open to PRs to extend Relay to support PnP, but this isn't something we will likely prioritize ourselves until PnP is widely adopted.
The problem is that the language server is loaded through a direct require call, so it relies on the specific hoisting layout (if a sibling dependency simply happens to depend on the language plugin, relay-compiler may not find the root one anymore).
Since the plugin is loaded from the cwd
a few lines above, I believe an improvement would be to do the same for the plugin resolution, using the paths
option from require.resolve
:
const req = eval('require');
languagePlugin = req(req.resolve(requirePath, {
paths: [process.cwd()],
}));
In the meantime, and as a workaround, you can use packageExtensions
to force-declare a dependency on relay-compiler-language-typescript
(or any other language) to relay-compiler
.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
How prevalent is PNP in 2021? Is the feature being considered for continued promotion?
I am evaluating whether to use PnP in my Relay project.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Can I use pnpm
as an alternative?
I am playing with Yarn PnP and it seems, that relay-compiler needs to update its dependencies. Am I correct?