-
Notifications
You must be signed in to change notification settings - Fork 47
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
Prevent publishing of empty files #997
Prevent publishing of empty files #997
Conversation
src/files/BrsFile.ts
Outdated
FunctionStatement: () => { | ||
isPublishable = true; | ||
}, | ||
MethodStatement: () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Methods can't exist on their own, so we can probably remove this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed 👍
src/files/BrsFile.ts
Outdated
isPublishable = true; | ||
} | ||
}), { | ||
walkMode: WalkMode.visitStatementsRecursive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably don't need the recursive part (that steps into function bodies which we don't care about for this)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I wasn't sure if perhaps something like a namespace could contain functions so perhaps I needed the recursive version? Happy to change this and the methods version though. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Okay, so I've been toying with a different name for this option. I'm open to other names, but here's what I came up with: Let's rename Along with that, I'm thinking we should rename Thoughts? |
src/files/XmlFile.ts
Outdated
private determinePkgMapPath(uri) { | ||
if (/^pkg:\/.+/.test(uri)) { | ||
return uri.replace(/^pkg:\//, ''); | ||
} | ||
return util.getPkgPathFromTarget(this.pkgPath, uri); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can completely eliminate this function and just call util.getPkgPathFromTarget
from checkScriptsForPublishableImports
. We do a similar pkg:/
check in getPkgPathFromTarget
.
That makes sense to me. I wasn't really sold on publish either so will update. 👍 |
…tinez/brighterscript into prevent-publishing-empty-files
This is fantastic work! Thank you so much. |
This PR seeks to fix Issue #981.
The PR adds a config variable
pruneEmptyCodeFiles
which defaults tofalse
. When set totrue
, brightscript files that are considered empty won't be published during transpilation. It also adds acanBePruned
property to the Brs and XML files.Currently Brs files are considered empty if they don't contain a
FunctionStatement
,MethodStatement
, or aClassStatement
. I might have missed something here.I can't really think of any reason why an xml file would be considered empty so I've defaulted the value to true for now. One thing I have implemented here for XML files is, imports of empty scripts are removed. If a brightscript file that an xml files references has their
canBePruned
field return false, the associated import will be removed too.On a large internal project, this resulted in significant compile-time speedups.
ultra 4800x (12.5):
stick4k 3800x (12.5):
express 3960x (11.5):