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

Error when importing Svelte components in a .astro page (File 'Path/Component.svelte.tsx' is not a module) #652

Closed
1 task
marcfilleul opened this issue Sep 17, 2023 · 6 comments · Fixed by withastro/astro#10244
Labels
- P2: has workaround Bug, but has workaround (priority) feat: svelte Related to the Svelte integration (scope)

Comments

@marcfilleul
Copy link

Astro Info

Astro                    v3.1.0
Node                     v18.17.1
System                   macOS (arm64)
Package Manager          yarn
Output                   static
Adapter                  none
Integrations             @astrojs/svelte
                         @astrojs/vue
                         @astrojs/react

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Here is a public repo with a fresh Astro 3.1.0 + Svelte, Vue and React integrations:
Repo to reproduce the issue

When importing a Svelte component in a .astro page, I have an error saying: File 'Path/Component.svelte.tsx' is not a module. And I don't have any intellisense for the available props.
The components work as expected though.
I have no issue with Vue or React components.

Everything is working in Astro 2.0, so it seems to be an Astro 3.0 regression.
Maybe it's only a Astro language-tools issue.

It's not related to my vscode settings as I still get the error when reverting back to the default settings.

Here is a screenshot of my error in vscode:
svelte-compo-import-error

What's the expected result?

I would expect to have no error and working intellisense for props.

Link to Minimal Reproducible Example

https://github.com/marcfilleul/astro-3

Participation

  • I am willing to submit a pull request for this issue.
@bluwy bluwy transferred this issue from withastro/astro Sep 18, 2023
@Princesseuh Princesseuh added bug feat: svelte Related to the Svelte integration (scope) labels Sep 18, 2023
@YolCruz
Copy link

YolCruz commented Sep 22, 2023

Has anyone found a workaround for this? I would really like to use Astro with Svelte

@YolCruz
Copy link

YolCruz commented Sep 26, 2023

I tried this with yarn. bun and pnpm. There's no issue with pnpm

@marcfilleul
Copy link
Author

I tried this with yarn. bun and pnpm. There's no issue with pnpm

Very interesting. I hope it will help investigate the issue.

@Princesseuh
Copy link
Member

Typically it's pnpm that has issues, not the other ones, ha. Not quite sure what this is about. Will investigate

@Princesseuh
Copy link
Member

Sorry about the delay, I got pulled into other things. In the reproduction, the issue is that typescript isn't installed and yarn can't find it. Since it's a peer dep of Svelte's editor integration, probably that other package manager install it magically.

As such, running npm install typescript will workaround the issue in the meantime until we have a better fix.

@ralphwest1
Copy link

ralphwest1 commented Feb 9, 2024

I am newly running into this exact same error, when running astro check.
Error: File 'c:/../SvelteComponent.svelte' is not a module.
I am on a windows machine and using pnpm with typescript installed.

Issue seems to be related to recent realease of @volar/language-service removing typescript.

As a temporary fix I was able to resolve by modifying my package.json as below:

{
  "dependencies": {
-    "@astrojs/check": "0.5.1",
+    "@astrojs/check": "0.4.1",
  },
+  "pnpm": {
+   "overrides": {
+      "@astrojs/language-server": "2.6.2"
+   }
  },
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: has workaround Bug, but has workaround (priority) feat: svelte Related to the Svelte integration (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants