Customization always loads PluginAPI version 0.1

Previously, when adding a site customization making use of the PluginAPI you could specify a version of the API to use in the <script> tag. Now that doesn’t work.

<script type="text/discourse-plugin" version="0.6">
  console.log(api.version)
</script>

The above should output 0.6, currently it outputs 0.1.

3 Likes

It actually does work, but I see why this confused you. So far, we haven’t had to translate any API calls from later versions of the API to earlier ones, so we can re-use the same API object that we created the first time it was requested (for version 0.1 in this case). You are getting back an object that implements all the 0.6 methods, it was just saying it was 0.1 because that’s the first version that requested it.

Since this is confusing, I updated the plugin code to update the version to the latest version that
requested it:

https://github.com/discourse/discourse/commit/3786d3679cd5acd20138054f8dde3ce7a6f1ca23

8 Likes