From bb644834ef03bc00048c7381f20a1c01388438e2 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Mon, 19 Jun 2023 17:18:46 +0800 Subject: [PATCH] Simplify telemetry Vite version detection (#7414) --- .changeset/brave-candles-invent.md | 5 +++++ packages/astro/src/events/index.ts | 13 ++----------- 2 files changed, 7 insertions(+), 11 deletions(-) create mode 100644 .changeset/brave-candles-invent.md diff --git a/.changeset/brave-candles-invent.md b/.changeset/brave-candles-invent.md new file mode 100644 index 000000000..e63ffcb3c --- /dev/null +++ b/.changeset/brave-candles-invent.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Simplify telemetry Vite version detection diff --git a/packages/astro/src/events/index.ts b/packages/astro/src/events/index.ts index 31e549ad7..7af647d44 100644 --- a/packages/astro/src/events/index.ts +++ b/packages/astro/src/events/index.ts @@ -1,19 +1,10 @@ import { AstroTelemetry } from '@astrojs/telemetry'; -import { createRequire } from 'module'; +import { version as viteVersion } from 'vite'; import { ASTRO_VERSION } from '../core/constants.js'; -const require = createRequire(import.meta.url); - -function getViteVersion() { - try { - const { version } = require('vite/package.json'); - return version; - } catch (e) {} - return undefined; -} export const telemetry = new AstroTelemetry({ astroVersion: ASTRO_VERSION, - viteVersion: getViteVersion(), + viteVersion, }); export * from './error.js';