Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not seem to work with the latest version of BS #6

Open
waaadim opened this issue Nov 12, 2024 · 3 comments
Open

Does not seem to work with the latest version of BS #6

waaadim opened this issue Nov 12, 2024 · 3 comments

Comments

@waaadim
Copy link

waaadim commented Nov 12, 2024

Getting an error when running this with Brighterscript alpha-41

[04:19:12:414 PM] Building
[04:19:12:415 PM] Error when calling plugin bsc-plugin-findnodes.beforeBuildProgram: TypeError: program.getScopes is not a function or its return value is not iterable
    at findNodeWithIDInjection (.../node_modules/bsc-plugin-auto-findnode/src/findNodes.ts:20:33)
    at Plugin.beforeProgramTranspile (.../node_modules/bsc-plugin-auto-findnode/src/Plugin.ts:15:32)
    at .../node_modules/brighterscript/src/PluginInterface.ts:83:51
    at Logger.time (.../node_modules/@rokucommunity/logger/dist/Logger.js:355:20)
    at PluginInterface.emitAsync (.../node_modules/brighterscript/src/PluginInterface.ts:81:40)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Object.action (.../node_modules/brighterscript/src/Program.ts:1633:27)
    at async Program.build (.../node_modules/brighterscript/src/Program.ts:1630:9)
    at async .../node_modules/brighterscript/src/ProgramBuilder.ts:444:17
    at async .../node_modules/brighterscript/src/ProgramBuilder.ts:442:13
[04:19:12:476 PM] Building finished. (61.873ms)
@TwitchBronBron
Copy link
Member

Yeah, this won't work with bsc v1 alphas at this time. We'll need to spin up a v1 alpha branch of this plugin to support that, as the bsc AST has changed a bit in v1. Any chance you'd be willing to help out in upgrading this lib to bsc v1?

@waaadim
Copy link
Author

waaadim commented Nov 13, 2024

I looked a little bit into this today.

Does it make sense to find all usages of m.FIELD and only add those in init?
Or is it too risky?

@TwitchBronBron
Copy link
Member

Hmm. I think it might be too risky to do it that way out of the box. Consider logic like this:

m.labelPrimary = m.top.findNode("labelPrimary")
m.labelSecondary = m.top.findNode("labelSecondary")

' m.theme contains "Primary" or "Secondary"
label = m["label" + m.theme]

Would technically be a breaking change to make that the default setting. However, I could see there being a configuration option that would apply this optimization. We'd scan for all files in the current scope, build every m.* reference, and any that are nodes with those ids, we'd include.

I kinda like this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants