From 1b7f559e0c1b48113589fe693a2caeaa4c9c54de Mon Sep 17 00:00:00 2001 From: Chris Helgert Date: Mon, 16 Oct 2023 13:02:14 +0200 Subject: [PATCH] chore(live-preview): expose current package version [] --- packages/live-preview-sdk/src/helpers/utils.ts | 4 ++-- packages/live-preview-sdk/src/index.ts | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/live-preview-sdk/src/helpers/utils.ts b/packages/live-preview-sdk/src/helpers/utils.ts index c4023c41..3d0b2278 100644 --- a/packages/live-preview-sdk/src/helpers/utils.ts +++ b/packages/live-preview-sdk/src/helpers/utils.ts @@ -1,4 +1,4 @@ -import * as packageJson from '../../package.json'; +import { version } from '../../package.json'; import { CONTENTFUL_ORIGINS, LIVE_PREVIEW_SDK_SOURCE } from '../constants'; import { PostMessageMethods } from '../messages'; import type { EditorMessage, MessageFromSDK } from '../messages'; @@ -15,7 +15,7 @@ export function sendMessageToEditor(method: PostMessageMethods, data: EditorMess from: 'live-preview', source: LIVE_PREVIEW_SDK_SOURCE, location: window.location.href, - version: packageJson.version || '2.2.0', + version, }; debug.log('Send message', message); diff --git a/packages/live-preview-sdk/src/index.ts b/packages/live-preview-sdk/src/index.ts index 0d9e4bb3..6edff3c3 100644 --- a/packages/live-preview-sdk/src/index.ts +++ b/packages/live-preview-sdk/src/index.ts @@ -2,6 +2,7 @@ import './styles.css'; import { type DocumentNode } from 'graphql'; +import { version } from '../package.json'; import { getAllTaggedEntries } from './fieldTaggingUtils'; import { sendMessageToEditor, @@ -29,6 +30,8 @@ import { TagAttributes, } from './types'; +export const VERSION = version; + export interface ContentfulLivePreviewInitConfig { locale: string; debugMode?: boolean;