-
-
Notifications
You must be signed in to change notification settings - Fork 945
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
issue with ApolloProvider types on monorepo #1928
Comments
This is probably some bug with how pnpm creates the flat |
The issue is that currently I have found 2 solutions for your problem: 1. fixing the dependencies of apollo-clientThere are a few issues with apollo-client because it misses some deps. Create the following module.exports = {
hooks: {
readPackage (manifest) {
switch (manifest.name) {
case 'react-apollo':
manifest.dependencies['apollo-client'] = '^2.6.3' // taken from apollo-boost
manifest.peerDependencies['@types/react'] = '*'
break
}
return manifest
}
}
} Run 2. Don't use shared-workspace-lockfileAdd |
two solution working perfectly fine. which one is better |
The one with pnpmfile
…On Sun, 28 Jul 2019, 14:56 SydAmir, ***@***.***> wrote:
two solution working perfectly fine. which one is better
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1928?email_source=notifications&email_token=AAOWTG2RIAXQ2EPHGDEGNZDQBWCOXA5CNFSM4IGZLEJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD265EII#issuecomment-515756577>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAOWTG3V5OJY7BPWD7CA3BTQBWCOXANCNFSM4IGZLEJA>
.
|
|
* Add an optional peer dependency to react-apollo `@types/react` should be an optional peer dependency of react-apollo. Related issue pnpm/pnpm#1928 * Add `@types/react` peer dep to all entry points * Remove support for yarn only features * Changelog update
Hi @zkochan! Sorry for raising this (old) issue. I'm encountering the exact same problem with pnpm With both I tried the "solution 1" you gave here (using Did I miss anything? Ready to try something else, if it can help diagnosing the issue. Thanks! EDIT - I understood the problem. It happes when a package has declared @types/react as a dev dependency but not as a peer dependency. const readPackage = (package, context) => pipe(
fixPnpmModulesFlattening(context),
)(package);
module.exports = {
hooks: {
readPackage
}
}
const composerReducer = (f, g) => (arg) => g(f(arg));
const pipe = (...fns) => fns.reduce(composerReducer);
const fixPnpmModulesFlattening = (context) => (package) => {
const addMissingPeerDependenciesTo = copyDevDependencyToPeerDependencies(context);
return pipe(
addMissingPeerDependenciesTo('@types/react', ['next', 'ink-table']),
addMissingPeerDependenciesTo('ink', ['ink-testing-library']),
)(package);
}
const copyDevDependencyToPeerDependencies = (context) => (dependencyName, targetPackages) => (currentPackage) => {
if (
!targetPackages.includes(currentPackage.name) ||
!currentPackage.devDependencies ||
!currentPackage.devDependencies[dependencyName] ||
(currentPackage.peerDependencies && currentPackage.peerDependencies[dependencyName])
) {
return currentPackage;
}
context.log(`[pnpm fix] Add ${dependencyName} as a peer dependency of ${currentPackage.name}`);
currentPackage.peerDependencies = {
...currentPackage.peerDependencies,
[dependencyName]: '*', // currentPackage.devDependencies[dependencyName],
};
currentPackage.peerDependenciesMeta = {
...currentPackage.peerDependenciesMeta,
[dependencyName]: { optional: true },
};
return currentPackage;
} |
pnpm version:
Code to reproduce the issue:
the actual file address on git repo is this :
./packages/sefood-tracing-fr/src/index.ts
the issue is it as say typescript :
Expected behavior:
detect the true type for ApolloProvider
Actual behavior:
Additional information:
I create a github repo to see the error in action
node -v
prints:v8.11.2
OS X
The text was updated successfully, but these errors were encountered: