Simplify telemetry Vite version detection (#7414)

This commit is contained in:
Bjorn Lu 2023-06-19 17:18:46 +08:00 committed by GitHub
parent 8f4a04d46b
commit bb644834ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 11 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Simplify telemetry Vite version detection

View file

@ -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';