PageSourceSearch

https://companion.free/assets/js/31d64736.724964cf.js

js companion.free collected 2026-10-07 14:47:56 UTC 8,090 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkcompanion_website=self.webpackChunkcompanion_website||[]).push([["2010"],{68465(e,o,n){n.r(o),n.d(o,{metadata:()=>i,default:()=>m,frontMatter:()=>a,contentTitle:()=>s,toc:()=>d,assets:()=>r});var i=JSON.parse('{"id":"module-development/module-lifecycle/companion-module-library","title":"The Companion Module Libraries","description":"Explanation of the companion module library.","source":"@site/for-developers/module-development/module-lifecycle/companion-module-library.md","sourceDirName":"module-development/module-lifecycle","slug":"/module-development/module-lifecycle/companion-module-library","permalink":"/for-developers/module-development/module-lifecycle/companion-module-library","draft":false,"unlisted":false,"editUrl":"https://github.com/bitfocus/website/tree/main/for-developers/module-development/module-lifecycle/companion-module-library.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{"title":"The Companion Module Libraries","sidebar_label":"@companion-module Libraries","sidebar_position":1,"description":"Explanation of the companion module library."},"sidebar":"developersSidebar","previous":{"title":"Module Development Lifecycle: Release and Maintenance","permalink":"/for-developers/module-development/module-lifecycle/"},"next":{"title":"License a module","permalink":"/for-developers/module-development/module-lifecycle/licensing"}}'),l=n(74848),t=n(28453);let a={title:"The Companion Module Libraries",sidebar_label:"@companion-module Libraries",sidebar_position:1,description:"Explanation of the companion module library."},s,r={},d=[{value:"What is the purpose of each library?",id:"what-is-the-purpose-of-each-library",level:2},{value:"@companion-module/base",id:"companion-modulebase",level:3},{value:"@companion-module/tools",id:"companion-moduletools",level:3},{value:"When should I update them?",id:"when-should-i-update-them",level:2},{value:"@companion-module/base",id:"companion-modulebase-1",level:3},{value:"@companion-module/tools",id:"companion-moduletools-1",level:3},{value:"Why were they created? - A bit of history",id:"why-were-they-created---a-bit-of-history",level:2},{value:"Further reading",id:"further-reading",level:2}];function u(e){let o={a:"a",code:"code",h2:"h2",h3:"h3",li:"li",p:"p",ul:"ul",...(0,t.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(o.p,{children:["Since Companion version 3.0, we have used ",(0,l.jsx)(o.code,{children:"@companion-module/base"})," and ",(0,l.jsx)(o.code,{children:"@companion-module/tools"})," libraries as part of the module API."]}),"\n",(0,l.jsxs)(o.p,{children:["The libraries are available on ",(0,l.jsx)(o.a,{href:"https://www.npmjs.com/",children:"npm"})," and are installed automatically when you run ",(0,l.jsx)(o.code,{children:"yarn install"}),"."]}),"\n",(0,l.jsx)(o.h2,{id:"what-is-the-purpose-of-each-library",children:"What is the purpose of each library?"}),"\n",(0,l.jsx)(o.h3,{id:"companion-modulebase",children:"@companion-module/base"}),"\n",(0,l.jsx)(o.p,{children:"This library is added as a regular dependency of your module. It contains various helpers and utilities that we think are useful to modules, as well as the main base class that your module should extend."}),"\n",(0,l.jsx)(o.p,{children:"If you have any suggestions for new utilities or helpers that would benefit many modules, let us know and we shall consider including it."}),"\n",(0,l.jsx)(o.h3,{id:"companion-moduletools",children:"@companion-module/tools"}),"\n",(0,l.jsx)(o.p,{children:"This library should be added as a devDependency of your module. It contains various bits of tooling and commands needed during the development or distribution of modules."}),"\n",(0,l.jsx)(o.p,{children:"For example, it contains a script to bundle your module for distribution and some eslint and typescript config presets that can be used."}),"\n",(0,l.jsx)(o.p,{children:"We expect every module to use the build script provided from this, the rest is optional extras that you can choose to use if you like."}),"\n",(0,l.jsx)(o.h2,{id:"when-should-i-update-them",children:"When should I update them?"}),"\n",(0,l.jsx)(o.h3,{id:"companion-modulebase-1",children:"@companion-module/base"}),"\n",(0,l.jsxs)(o.p,{children:["The version of this library determines the versions of Companion your module can be run with. See the ",(0,l.jsx)(o.a,{href:"https://github.com/bitfocus/companion-module-base/tree/main/packages/base#supported-versions-of-this-library",children:"version compatibility table"}),"."]}),"\n",(0,l.jsx)(o.p,{children:"For example, modules targeting Companion 3.0 should use @companion-module/base v1.4.3 (or any 1.x release back to v1.0.0). Modules targeting Companion 3.1 should use v1.5. A module written for 3.0 will run on 3.1, but a module written for 3.1 may not be compatible with 3.0."}),"\n",(0,l.jsx)(o.p,{children:"We recommend targeting the previous stable release of Companion. This will allow users who have not yet updated Companion to use the latest version of your module. But of course, you may wish to use newer versions if there are features that your module will benef
1it from."}),"\n",(0,l.jsx)(o.h3,{id:"companion-moduletools-1",children:"@companion-module/tools"}),"\n",(0,l.jsx)(o.p,{children:"This library is less picky about the version, and you will benefit by running an up to date version."}),"\n",(0,l.jsx)(o.h2,{id:"why-were-they-created---a-bit-of-history",children:"Why were they created? - A bit of history"}),"\n",(0,l.jsx)(o.p,{children:"Prior to Companion version 3, modules would pull various bits of code from the Companion code. This was problematic as it meant that modules had to live in one of a few specific locations to be able to access the code. In release builds, they had to be built in before Companion was packaged."}),"\n",(0,l.jsx)(o.p,{children:"This was the main issue that was blocking our ability to support adding newer versions of modules into already released versions."}),"\n",(0,l.jsxs)(o.p,{children:["Everything that modules need to access Companion is now located inside of ",(0,l.jsx)(o.code,{children:"@companion-module/base"}),". Some things have not been made available, as they were determined to not be appropriate and alternatives will be recommended to the few module authors who utilised them."]}),"\n",(0,l.jsxs)(o.p,{children:["Another benefit of this separation is that it allows us to better isolate modules from being tied to specific versions of Companion. The ",(0,l.jsx)(o.code,{children:"@companion-module/base"})," acts as a stable barrier between the two. It has intentionally been kept separate from the rest of the Companion code, so that changes made here get an extra level of scrutiny, as we want to guarantee backwards compatibility as much as possible. For example, in Companion version 2.x changes made to the module API occasionally required fixes to be applied to multiple modules. By having this barrier, we can avoid such problems for as long as possible, and can more easily create compatibility layers as needed."]}),"\n",(0,l.jsx)(o.h2,{id:"further-reading",children:"Further reading"}),"\n",(0,l.jsxs)(o.ul,{children:["\n",(0,l.jsx)(o.li,{children:(0,l.jsx)(o.a,{href:"/for-developers/module-development/home",children:"Introduction to modules"})}),"\n",(0,l.jsx)(o.li,{children:(0,l.jsx)(o.a,{href:"/for-developers/module-development/module-development-101",children:"Module development 101"})}),"\n",(0,l.jsx)(o.li,{children:(0,l.jsx)(o.a,{href:"../connection-basics/",children:"Module Basics"})}),"\n"]})]})}function m(e={}){let{wrapper:o}={...(0,t.R)(),...e.components};return o?(0,l.jsx)(o,{...e,children:(0,l.jsx)(u,{...e})}):u(e)}},28453(e,o,n){n.d(o,{R:()=>a,x:()=>s});var i=n(96540);let l={},t=i.createContext(l);function a(e){let o=i.useContext(t);return i.useMemo(function(){return"function"==typeof e?e(o):{...o,...e}},[o,e])}function s(e){let o;return o=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:a(e.components),i.createElement(t.Provider,{value:o},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.