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

Using Vercel speed insights in Astro #54

Closed
thecoshopteam opened this issue Feb 12, 2024 · 1 comment · Fixed by #55
Closed

Using Vercel speed insights in Astro #54

thecoshopteam opened this issue Feb 12, 2024 · 1 comment · Fixed by #55

Comments

@thecoshopteam
Copy link

Hey, I installed the @vercel/speed-insights package with npm and tried to add the component to my BaseHead.astro:

---
import SpeedInsights from "@vercel/speed-insights/astro";
---

<head>
  ...

  <SpeedInsights />
</head>

But when I add it, the import gets linted and says "Cannot find module '@vercel/speed-insights/astro' or its corresponding type declarations."

This is my package.json:

{
  "name": "...",
  "type": "module",
  "private": true,
  "scripts": {
    "dev": "astro dev",
    "build": "astro build",
    "preview": "astro preview",
    "astro": "astro",
  },
  "dependencies": {
    "@astrojs/vercel": "^7.1.1",
    "@vercel/speed-insights": "^1.0.9",
    "astro": "^4.2.8",
     ...
  },
}

How do I fix it? I followed Vercel's guide exactly and there's an issue.

I tried to see if I could import SpeedInsights from "@vercel/speed-insights";
And though the linting goes away on that line, I now get linted on the component line:

<SpeedInsights />

_Component 'SpeedInsights' is not a valid component.

If this is a Svelte or Vue component, it might have a syntax error that makes it impossible to parse.ts(2604)
(alias) const SpeedInsights: {
injectSpeedInsights: typeof injectSpeedInsights;
computeRoute: typeof computeRoute;
}
import SpeedInsights_

A friend on Discord says that looking at the package, it looks like it's not packaged correctly, the types point to a file that doesn't exist.

@lucas-mancini
Copy link

lucas-mancini commented Feb 13, 2024

Hi, I'm having the same issue. It currently does not work with "@vercel/speed-insights": "^1.0.9" and "astro": "^4.3.6".

Apparently this was fixed in #41, but I'm still experiencing the issue.

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 a pull request may close this issue.

2 participants