Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions astro-cloudinary/src/constants/analytics.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
5 changes: 5 additions & 0 deletions astro-cloudinary/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineConfig } from 'tsup'
import pkg from './package.json';

export default defineConfig(() => {
return {
Expand All @@ -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),
},
};
});