diff --git a/astro-cloudinary/src/constants/analytics.ts b/astro-cloudinary/src/constants/analytics.ts index 6ac7018..3d0fc16 100644 --- a/astro-cloudinary/src/constants/analytics.ts +++ b/astro-cloudinary/src/constants/analytics.ts @@ -1,10 +1,12 @@ import astroPkg from 'astro/package.json'; -import pkg from '../../package.json'; + +// Injected at build time to avoid bundling this package's package.json +declare const __ASTRO_CLOUDINARY_VERSION__: string; export const ASTRO_CLOUDINARY_ANALYTICS_PRODUCT_ID = 'B'; export const ASTRO_CLOUDINARY_ANALYTICS_ID = 'G'; export const ASTRO_VERSION = normalizeVersion(astroPkg.version); -export const ASTRO_CLOUDINARY_VERSION = normalizeVersion(pkg.version); +export const ASTRO_CLOUDINARY_VERSION = normalizeVersion(__ASTRO_CLOUDINARY_VERSION__); function normalizeVersion(version: string) { let normalized = version; diff --git a/astro-cloudinary/tsup.config.ts b/astro-cloudinary/tsup.config.ts index 0d53447..6df0a1d 100644 --- a/astro-cloudinary/tsup.config.ts +++ b/astro-cloudinary/tsup.config.ts @@ -1,4 +1,5 @@ import { defineConfig } from 'tsup' +import pkg from './package.json'; export default defineConfig(() => { return { @@ -13,5 +14,9 @@ export default defineConfig(() => { sourcemap: true, format: ['esm'], external: ['astro', 'node:async_hooks', '#async-local-storage'], + // Inline the version instead of importing package.json into the bundle + define: { + __ASTRO_CLOUDINARY_VERSION__: JSON.stringify(pkg.version), + }, }; }); \ No newline at end of file