r-wasm / webr

The statistical language R compiled to WebAssembly via Emscripten, for use in web browsers and Node.
https://docs.r-wasm.org/webr/latest/
Other
804 stars 54 forks source link

webR version string #409

Closed coatless closed 2 months ago

coatless commented 2 months ago

With the update cadence increasing, it would be good to be able to query the webR module itself to obtain the current version information, e.g.

webR.version;

This would avoid needing to querying the webr support package for version information, e.g.

var webRready = await import('https://webr.r-wasm.org/latest/webr.mjs').then(
  async ({ WebR }) => {
    const webR = new WebR();
    await webR.init();
    return webR;
  }
);

const webRVersion = await webRready.evalRString('as.character(utils::packageVersion("webr"))');
georgestagg commented 2 months ago

Good idea!

I've reworked how versioning is reported in https://github.com/r-wasm/webr/commit/3b1e66720a4168a099cd442fb24acc13882f50d9. Once GHA CI has caught up, it should be possible to access the version of webR using the property webR.version from JS. I'll try to remember to keep an eye on the results of this change for the next few pushes to main and tagged releases.

I've set this up so that the version should include the GitHub SHA for development builds hosted at [...]/latest/.

> webR.version;
< '0.3.3-dev+1298d00'

For tagged releases, this should return a standard version number as expected:

> webR.version;
< '0.3.3'

Note that this is based on the version reported in webR's package.json, which follows semver. For development versions of webR this will be slightly different to the version of the webr support package as reported by utils::packageVersion() due to the differing versioning practices for indicating pre-release versions. They should, however, match for tagged releases of webR.

coatless commented 2 months ago

@georgestagg this is wonderful! Thank you so much. 👍

No worries on the semver part, Quarto has a similar versioning scheme required for extensions.