Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] expose version identifiers #1459

Closed
wants to merge 1 commit into from
Closed
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
5 changes: 5 additions & 0 deletions build/rollup_plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import strip from '@rollup/plugin-strip';
import {Plugin} from 'rollup';
import {importAssertionsPlugin} from 'rollup-plugin-import-assert';

import {version} from '../package.json';

// Common set of plugins/transformations shared across different rollup
// builds (main maplibre bundle, style-spec package, benchmarks bundle)

Expand All @@ -32,6 +34,9 @@ export const plugins = (production: boolean): Plugin[] => [
'_token_stack:': ''
}
}),
replace({
'__packageVersion': version,
}),
production && strip({
sourceMap: true,
functions: ['PerformanceUtils.*', 'Debug.*']
Expand Down
7 changes: 7 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ const exported = {
*/
clearPrewarmedResources,

/**
* Returns the package version of the library
*/
get version(): string {
return '__packageVersion';
},

/**
* Gets and sets the number of web workers instantiated on a page with GL JS maps.
* By default, it is set to half the number of CPU cores (capped at 6).
Expand Down
7 changes: 7 additions & 0 deletions src/ui/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,13 @@ class Map extends Camera {
return this._mapId;
}

/**
* Returns the package version of the library
*/
get version(): string {
return '__packageVersion';
}

/**
* Adds an {@link IControl} to the map, calling `control.onAdd(this)`.
*
Expand Down