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

[graphiql] cm6-graphql | Cannot use import statement outside a module | import { getTokenAtPosition, getTypeInfo, getAutocompleteSuggestions, getDiagnostics } from 'graphql-language-service'; #3579

Open
1 task done
Kyrylo-Usichenko opened this issue Apr 9, 2024 · 1 comment

Comments

@Kyrylo-Usichenko
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I am using CM6 in my project and want to add graphQL.

I am trying to import

<script lang="ts">
	import { graphql } from 'cm6-graphql';
</script>

And have a lib error: "Cannot use import statement outside a module"

~/node_modules/cm6-graphql/dist/index.js:1
import { getTokenAtPosition, getTypeInfo, getAutocompleteSuggestions, getDiagnostics } from 'graphql-language-service';
^^^^^^

Expected Behavior

At first I've tried it in prod project, then created PoC app. I am expecting this import to work.

Steps To Reproduce

  1. Just create PoC app: pnpm create svelte@latest codemirror-graphql
  2. Create src/routes/+page
<script lang="ts">
	import { graphql } from 'cm6-graphql';
</script>

  1. run dev pnpm run dev
  2. open http://localhost:5173/ in browser

Environment

  • cm6-graphql Version: 0.0.14
  • svelte Version: 4.2.7
  • Bundler: vite 5.0.3

System

  • OS: MacOS Sonoma 14.4.1

Anything else?

No response

@ewen-lbh
Copy link

Adding "type": "module" to the package's package.json fixes the issue for me.

This can be done easily by patching the dependency with Yarn: yarn patch cm6-graphql

See e.g https://github.com/graphinx/templates/blob/b5946fd755cb5ad51d492b95eb9a8f0e34233c25/default/.yarn/patches/cm6-graphql-npm-0.0.15-fe23fd2b32.patch#L9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants