-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add missing dependency to apollo-engine-reporting
#3054
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f92e9b5
Add missing dependency to `apollo-engine-reporting`
27336bf
Merge branch 'master' into patch-1
squirly 4f37476
Merge branch 'master' into patch-1
squirly 8fe8b78
Merge branch 'master' into HEAD
abernix f3717c7
Update `package-lock.json` for #3054.
abernix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's a type that's only used within a
private
property on theexport
edEngineReportingAgent
class, would this be better categorized withindevDependencies
?:apollo-server/packages/apollo-engine-reporting/src/agent.ts
Lines 224 to 225 in 6f5769c
(i.e. Could you verify to see if having it as a dev-dep resolves the concern you identified?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not, as we are only use dependencies when packaging for deploy; and using
devDependencies
would not be correct per npm recommendations:~ See Specifying dependencies and devDependencies in a package.json file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be clear, I'm not saying that this dependency doesn't need to be added, but the rational for deciding whether types go into
devDependencies
ordependencies
is not as straightforward as those npm recommendations you've listed.Concretely, if we went by the npm standard that you're stating here — which I'm familiar with — we could arguably say that no types are necessary since normal dependencies since TypeScript is compiled to JavaScript before it runs in production and the type definitions are only used during development.
You're probably aware that typically,
@types/*
packages are installed asdevDependencies
, but I'm curious, did you test my suggestion or are you just trying to be educational? I'm not trying to be rude — and a reproduction of the problem or at least the error message would have made the solution more clear — but in the case of a library that provides typings (likeapollo-engine-reporting
, in this case!), it is important to put types intodependencies
if those types appear in the emitted definition files (i.e.*.d.ts
) since consuming packages need to be able to access those definitions during consuming application's compilation. However, in the case ofInMemoryLRUCache
withinapollo-engine-reporting
, again, its only used in aprivate
property on an exportedEngineReportingAgent
class declaration.That means that
InMemoryLRUCache
doesn't appear in the emitted types withinagent.d.ts
, which merely notes it as aprivate
property.Since it doesn't appear there, the
InMemoryLRUCache
type shouldn't be necessary.(Btw, if it were not
private
, you're absolutely correct that it should be independencies
, as it would be present in theagent.d.ts
file!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really, that's all to say, can you provide a reproduction or the error output? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Starting with the error:
The stacktrace points to the transpiled version of:
apollo-server/packages/apollo-engine-reporting/src/agent.ts
Line 16 in 6f5769c
The issue is with how npm handles version incompatibilities when building a package-lock.
We are in a situation where this dependency is not inlined in the
package-lock
but the other dependency we use that requiresapollo-server-caching
is inlined not allowing this package to access the inlined version ofapollo-server-caching
.Since npm does not install
devDependencies
in this case, adding todevDependencies
does not cause the package to get installed in the correct place.I do not want to include my entire
package-lock.json
so I created a paired down example based on it, https://gist.github.com/squirly/1452f6f1dbec894da41293b0b3713e06. It is contrived but exposes the issue.If you run
npm ci
; then try to require this module,node -r apollo-server-caching
, you will get the above error.This example also exposed that
graphql
should be adependency
orpeerDependency
.