[wasm] feat: expose library version
This commit is contained in:
parent
3698c703fc
commit
87ac7aaa5d
@ -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),
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
@ -21,4 +21,12 @@ function loader() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get package version.
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getUmcVersion() {
|
||||
return process.env.UMC_VERSION;
|
||||
}
|
||||
|
||||
export const ready = loader();
|
||||
|
Loading…
Reference in New Issue
Block a user