Skip to content

fix(defaultExport): fixed version string causing issues with Angular compiler#536

Open
nickiannone-fis wants to merge 1 commit into
thoughtspot:mainfrom
nickiannone-fis:main
Open

fix(defaultExport): fixed version string causing issues with Angular compiler#536
nickiannone-fis wants to merge 1 commit into
thoughtspot:mainfrom
nickiannone-fis:main

Conversation

@nickiannone-fis
Copy link
Copy Markdown

Fixing issue described in #535

This converts the exports of the package.json file (for getting the build version number) into aliased default exports, fixing a build error encountered when using this in an Angular application.

…compiler

Co-authored-by: Copilot <copilot@github.com>
@nickiannone-fis nickiannone-fis requested a review from a team as a code owner May 21, 2026 20:25
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the SDK versioning logic by updating how the version is imported from package.json in ts-embed.ts and mixpanel-service.ts. The review feedback identifies opportunities to optimize the production bundle size and improve maintainability by centralizing the version export in a single module, thereby avoiding the redundant import of the entire JSON object across multiple files.

Comment thread src/mixpanel-service.ts
Comment on lines +5 to +7
import { default as packageInfo } from '../package.json';

const VERSION = packageInfo.version;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Importing the entire 'package.json' file as a default export can lead to the whole JSON object being included in the production bundle, which increases the SDK's footprint unnecessarily (including scripts, dependencies, and other metadata). Additionally, it exposes project metadata in the client-side code that isn't required at runtime.

Consider exporting the version string from this module so it can be reused in other parts of the SDK without re-importing the JSON file.

Suggested change
import { default as packageInfo } from '../package.json';
const VERSION = packageInfo.version;
import { default as packageInfo } from '../package.json';
export const VERSION = packageInfo.version;

Comment thread src/embed/ts-embed.ts
import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
import { processEventData, processAuthFailure } from '../utils/processData';
import { version } from '../../package.json';
import { default as packageInfo } from '../../package.json';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve maintainability and reduce bundle size, consider importing the 'VERSION' constant from the mixpanel service instead of re-importing the 'package.json' file here. This avoids duplicating the extraction logic and ensures a single source of truth for the SDK version.

Suggested change
import { default as packageInfo } from '../../package.json';
import { VERSION } from '../mixpanel-service';

Comment thread src/embed/ts-embed.ts
*/
export const THOUGHTSPOT_PARAM_PREFIX = 'ts-';
const TS_EMBED_ID = '_thoughtspot-embed';
const VERSION = packageInfo.version;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This local constant definition is redundant if the 'VERSION' is imported from the mixpanel service as suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant