Skip to content

Commit

Permalink
Node: extract version from package.json using require()
Browse files Browse the repository at this point in the history
This allows JS bundlers such as webpack to embed the version string in the
bundle. Otherwise a bundled JS app would look for mediasoup's package.json
in "../.." on the filesystem (and it's very likely not there).
  • Loading branch information
camilleoudot authored and ibc committed Nov 10, 2023
1 parent ea0fb97 commit 1ab9796
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions node/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as fs from 'node:fs';
import * as path from 'node:path';
import { Logger } from './Logger';
import { EnhancedEventEmitter } from './EnhancedEventEmitter';
import { workerBin, Worker, WorkerSettings } from './Worker';
Expand All @@ -16,9 +14,8 @@ export { types };
/**
* Expose mediasoup version.
*/
export const { version } = JSON.parse(fs.readFileSync(
path.join(__dirname, '..', '..', 'package.json'), { encoding: 'utf-8' }
));
// eslint-disable-next-line @typescript-eslint/no-var-requires
export const version: string = require('../../package.json').version;

/**
* Expose parseScalabilityMode() function.
Expand Down

0 comments on commit 1ab9796

Please sign in to comment.