rokucommunity / vscode-brightscript-language

A Visual Studio Code extension for Roku's BrightScript language
MIT License
104 stars 41 forks source link

bsConst in launch.json does not affect component libraries #461

Closed iBicha closed 1 month ago

iBicha commented 1 year ago

bsConst are being updated on the app manifest, but not component libraries

TwitchBronBron commented 1 year ago

Hmm. Component libraries and the main project all flow through the same manifest transformation logic here: https://github.com/rokucommunity/roku-debug/blob/bb2146888261a7d2d21cdb17dc31e1715e72ae2a/src/managers/ProjectManager.ts#L291

Are you using a preprocessor or brighterscript somewhere by chance? Because brighterscript currently transpiled away all the false blocks. (We want to fix that eventually...)

iBicha commented 1 year ago

Hmm. Component libraries and the main project all flow through the same manifest transformation logic here: https://github.com/rokucommunity/roku-debug/blob/bb2146888261a7d2d21cdb17dc31e1715e72ae2a/src/managers/ProjectManager.ts#L291

Are you using a preprocessor or brighterscript somewhere by chance? Because brighterscript currently transpiled away all the false blocks. (We want to fix that eventually...)

I'm using brighterscript, and the output of it contains all the false values.

Like after transpiling with bsc my manifest still has

bs_const=DEBUG=false;WEB_SERVER_BASIC_AUTH=false;DASH_THUMBNAILS=false;WEB_SOCKETS=true
iBicha commented 1 year ago

Also, I don't see it looping through all manifests, or is a Project object created for each component library?

TwitchBronBron commented 1 year ago

I wasn't talking about the manifest itself, i was talking about the code. So Something like this:

bs_const=some_true_value=true;some_false_value=false;

#if some_true_value
    'i get to stay
#end if
#if some_false_value
    'i get deleted
#end if 

will result in this output code:

#if some_true_value
    'i get to stay
#end if 
iBicha commented 1 year ago

Got it, sorry for not being clear. No what's missing is the manifest of the component library is not updated according to the launch config

TwitchBronBron commented 1 year ago

Got it, sorry for not being clear. No what's missing is the manifest of the component library is not updated according to the launch config

Ah, ok. Well then yeah, I guess there's a bug somewhere. Maybe vscode isn't sending the bsconst stuff up for complibs during launch.

Also, I don't see it looping through all manifests, or is a Project object created for each component library?

Yeah, we make one project for the main app, and a project for each complib.

iBicha commented 1 year ago

To work around the issue, I was trying to modify the manifest in staging just before bsc starts transpiling. Turns out bsc does not care about the manifest in the staging.

I ended up modifying the actual rootDir manifest right before bsc does work, and restoring it back later (plugin)

TwitchBronBron commented 1 month ago

BrighterScript v1 recently introduced proper AST support for conditional compile statements being transpiled into the output (see https://github.com/rokucommunity/brighterscript/pull/1149). So I'm going to close this issue, as it should eventually be fixed with v1 lands.