Add bslib inline functionality to eliminate need for bslib.brs imports #1577
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds the ability to inline bslib functions directly into individual files, eliminating the need for library consumers to manage
bslib.brsimports.Problem
The current
bslib.brspattern works for app developers but creates friction for library consumers who must remember to addbslib.brsimports when using libraries that leverage BrighterScript features like template strings and ternary operators.Solution
This PR introduces a new
bslibHandlingconfiguration option that allows developers to choose between two modes:shared(default): Current behavior with a single sharedbslib.brsfileunique-per-file: Inlines bslib functions directly into each file with unique suffixesConfiguration
{ "bslibHandling": { "mode": "shared" | "unique-per-file", "uniqueStrategy": "md5" | "guid" } }Example
Input BrighterScript:
Shared Mode (current behavior):
Unique-per-file Mode:
Key Features
Implementation Details
bslibHandlingconfiguration toBsConfig.tsand schemaBrsTranspileStateto track used bslib functions and generate unique suffixesBrsFile.transpile()to inject inlined functionsXmlFileandProgramto skip bslib imports/copying in unique-per-file modeThis makes BrighterScript libraries more portable and reduces the friction for library adoption while maintaining full backward compatibility.
Original prompt
Fixes #1524
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.