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

build: remove codemirror dependency from lsp #1998

Merged
merged 1 commit into from
Nov 7, 2021

Conversation

ferm10n
Copy link
Contributor

@ferm10n ferm10n commented Nov 4, 2021

CodeMirror.Token is identical to ContextTokenForCodeMirror

see graphql/vscode-graphql#335 (comment)


this will allow updating the vscode-graphql to update to the latest packages from this project without having to add codemirror as a dependency

@changeset-bot
Copy link

changeset-bot bot commented Nov 4, 2021

🦋 Changeset detected

Latest commit: 500520d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
graphql-language-service-interface Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

`CodeMirror.Token` is identical to `ContextTokenForCodeMirror`.
see graphql/vscode-graphql#335 (comment)
@codecov
Copy link

codecov bot commented Nov 4, 2021

Codecov Report

Merging #1998 (500520d) into main (2d91916) will increase coverage by 0.70%.
The diff coverage is 67.79%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1998      +/-   ##
==========================================
+ Coverage   65.70%   66.40%   +0.70%     
==========================================
  Files          85       86       +1     
  Lines        5106     5153      +47     
  Branches     1631     1643      +12     
==========================================
+ Hits         3355     3422      +67     
+ Misses       1747     1727      -20     
  Partials        4        4              
Impacted Files Coverage Δ
...ervice-interface/src/getAutocompleteSuggestions.ts 78.00% <ø> (ø)
...raphql-language-service-parser/src/onlineParser.ts 87.23% <16.66%> (-3.14%) ⬇️
...ackages/graphiql-toolkit/src/create-fetcher/lib.ts 51.78% <46.66%> (-7.79%) ⬇️
packages/graphiql/src/utility/HistoryStore.ts 62.26% <62.26%> (ø)
...kages/graphql-language-service-parser/src/Rules.ts 96.80% <75.00%> (-0.97%) ⬇️
packages/graphiql/src/components/QueryHistory.tsx 73.91% <76.47%> (+6.69%) ⬆️
...iql/src/components/DocExplorer/MarkdownContent.tsx 100.00% <100.00%> (ø)
packages/graphiql/src/components/GraphiQL.tsx 58.34% <100.00%> (+0.83%) ⬆️
...ql-language-service-server/src/MessageProcessor.ts 66.58% <100.00%> (+6.30%) ⬆️
...hql-language-service-server/src/findGraphQLTags.ts 67.64% <100.00%> (+7.00%) ⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 672aadf...500520d. Read the comment docs.

@acao acao requested review from yoshiakis and imolorhe November 4, 2021 13:14
@acao
Copy link
Member

acao commented Nov 4, 2021

I'm trying to recall exactly why we made this change before, but it doesn't seem like we need to import all of @codemirror/types just for one token type. @yoshiakis is this going to be an issue for codemirror-graphql consumers, to keep the duplicate type in sync?

@ferm10n
Copy link
Contributor Author

ferm10n commented Nov 4, 2021

Is there a best practice for a typescript lib (like this one) that is expected to integrate with another package with its own types, if you don't want to make it a dependency?

My first thought was making codemirror an optional peer dependency for graphql-language-service-interface... but then I'm not sure what to do with that codemirror import (I'm not a TS master yet but I'm working on it lol)

In other lib projects I've worked on, I've just added the types package as a dev dep and an optional peer dep. Then in a package that uses that lib, I have it add the same types package as a dev dep so it can build. Translating that strategy here might look like:

  • add codemirror or @types/codemirror as a devdep to graphql-language-server-interface, and as an optional peer dep
  • add @types/codemirror as a devdep to vscode-graphql so it can build... because it doesn't need codemirror stuff but it does need the types defined.

@ferm10n
Copy link
Contributor Author

ferm10n commented Nov 4, 2021

Now that I say that though, why does vscode-graphql's build type check this module anyway? Shouldn't node_modules get excluded?

@imolorhe
Copy link
Contributor

imolorhe commented Nov 5, 2021

The only issue I see here would be keeping the types in sync, assuming the Token type in codemirror is updated, but this looks like a cleaner alternative, considering how the codemirror Token is probably the most used (and frequently referenced) type in the Codemirror package.

@acao
Copy link
Member

acao commented Nov 6, 2021

@ferm10n excellent point! i think we need to tweak some tsconfig on the vscode-graphql side at least...

@imolorhe another great point. I swear I found a way to automatically extract external definititions statically to the .d.ts files once, but after some time searching I couldn't remember how I accomplished it. Triple slash directives perhaps?

@acao acao merged commit 8869c4b into graphql:main Nov 7, 2021
@github-actions github-actions bot mentioned this pull request Nov 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants