ropm Support
BrighterScript features that need runtime support (like the null-coalescing operator) call functions in bslib, BrighterScript's BrightScript runtime library. For BrighterScript-transpiled projects to work as ropm modules, they need a reference to bslib in their package. As ropm and BrighterScript become more popular, this could result in many duplicate copies of bslib.brs.
To reduce that duplication, BrighterScript has built-in support for loading bslib from ropm:
- If your program does not use ropm, or does use ropm but does not directly reference bslib, then the BrighterScript compiler copies bslib to
pkg:/source/bslib.brsat transpile time. - If your program uses ropm and has installed
bslibas a dependency, then the BrighterScript compiler does not emit a copy of bslib atpkg:/source/bslib.brs, and instead uses the version from ropm atpkg:/source/roku_modules/bslib/bslib.brs.
Installing bslib in your ropm-enabled project
bslib is published to npm as @rokucommunity/bslib. We recommend installing it with the bslib alias, since it produces smaller transpiled code (a bslib_ prefix instead of rokucommunity_bslib_):
ropm install bslib@npm:@rokucommunity/bslibInstalling it without the alias works too, it just produces longer names:
ropm install @rokucommunity/bslibSee also the bslibDestinationDir option, which controls where the compiler puts its copy of bslib.