Skip to content
Merged
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
9 changes: 8 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import dts from "rollup-plugin-dts";
import banner2 from 'rollup-plugin-banner2'
import packageJson from "./package.json" assert { type: "json" };

const version = packageJson.version ?? null;


export default [
{
input: "src/index.ts",
Expand All @@ -26,7 +29,11 @@ export default [
commonjs(),
typescript({ tsconfig: "./tsconfig.json" }),
banner2(() => `
"use client";
"use client";

if (typeof window !== "undefined") {
window.CODEIUM_REACT_CODE_VERSION = ${version ? `${JSON.stringify(version)}` : null};
}
`)
],
},
Expand Down
3 changes: 2 additions & 1 deletion src/utils/identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export const getBrowserVersion = () => {
*/
export const getPackageVersion = () => {
try {
return require('../../package.json').version;
// @ts-ignore
return window.CODEIUM_REACT_CODE_VERSION ? window.CODEIUM_REACT_CODE_VERSION : null;
} catch (e) {
return null;
}
Expand Down