diff --git a/um_wasm_loader/rollup.config.mjs b/um_wasm_loader/rollup.config.mjs index db00b8f..f00d084 100644 --- a/um_wasm_loader/rollup.config.mjs +++ b/um_wasm_loader/rollup.config.mjs @@ -2,6 +2,9 @@ import { defineConfig } from 'rollup'; import { wasm } from '@rollup/plugin-wasm'; import replace from '@rollup/plugin-replace'; import { dts } from 'rollup-plugin-dts'; +import { readFileSync } from 'node:fs'; + +const pkgJson = JSON.parse(readFileSync(new URL('package.json', import.meta.url), 'utf-8')); function makePlugins({ sync }) { const plugins = []; @@ -16,6 +19,7 @@ function makePlugins({ sync }) { preventAssignment: true, values: { 'process.env.UMC_INLINE_BUILD': JSON.stringify(String(sync ? 1 : 0)), + 'process.env.UMC_VERSION': JSON.stringify(pkgJson.version), }, }), ); diff --git a/um_wasm_loader/src/loader.mjs b/um_wasm_loader/src/loader.mjs index ddd1565..9697cf6 100644 --- a/um_wasm_loader/src/loader.mjs +++ b/um_wasm_loader/src/loader.mjs @@ -21,4 +21,12 @@ function loader() { } } +/** + * Get package version. + * @returns {string} + */ +export function getUmcVersion() { + return process.env.UMC_VERSION; +} + export const ready = loader();