rokucommunity / brighterscript

A superset of Roku's BrightScript language
MIT License
153 stars 47 forks source link

certain imports do not produce a script tag when importing #122

Closed georgejecook closed 3 years ago

georgejecook commented 4 years ago

I have this import in several files:

import "pkg:/source/maestro/ioc/IOCMixin.bs"

it's a valid import, imported into BaseClass.bs, extended by AuthManager.bs

The AuthenticationService xml imports AuthManager.bs

I would expect the import to be present in the build AuthenticationService.xml's script imports: it is not I add the import to the extended AuthManager class; it still doesn't show up. I add it to the AuthenticationService.bs file, it still doesn't show up as a script tag

The only recourse I have is to add the imports that get dropped as a script tag in the file.

georgejecook commented 4 years ago

I've looked into this more; but I can't see rhyme or reason to it - my only guess is perhaps we're missing an error somewhere.. I'll try and investigate some more

TwitchBronBron commented 4 years ago

Yeah very strange. Can you put together a very small sample project that will reproduce the issue? Then I can dig into this early next week.

TwitchBronBron commented 4 years ago

@georgejecook can you look over this spec and tell me if that properly represents the code structure you were describing above? I did find one issue where the path separators were wrong on windows for some of the imports, but other than that, the spec passes. Is this still an issue? If so, can you modify the spec below to reproduce your issue?

it('complicated import graph adds correct script tags', async () => {
    await program.addOrReplaceFile('source/maestro/ioc/IOCMixin.bs', `
        sub DoIocThings()
        end sub
    `);
    await program.addOrReplaceFile('source/BaseClass.bs', `
        import "pkg:/source/maestro/ioc/IOCMixin.bs"
    `);

    await program.addOrReplaceFile('components/AuthManager.bs', `
        import "pkg:/source/BaseClass.bs"
    `);
    await testTranspile(`
        <?xml version="1.0" encoding="utf-8" ?>
        <component name="ChildScene" extends="ParentScene">
            <script type="text/brighterscript" uri="AuthManager.bs" />
        </component>
    `, `
        <?xml version="1.0" encoding="utf-8" ?>
        <component name="ChildScene" extends="ParentScene">
            <script type="text/brightscript" uri="AuthManager.brs" />
            <script type="text/brightscript" uri="pkg:/source/maestro/ioc/IOCMixin.bs" />
            <script type="text/brightscript" uri="pkg:/source/BaseClass.brs" />
            <script type="text/brightscript" uri="pkg:/source/bslib.brs" />
        </component>
    `, null, 'components/AuthenticationService.xml');
});
georgejecook commented 3 years ago

I'm closing this, as it appears to be working on 2 projects these days.