-
Notifications
You must be signed in to change notification settings - Fork 22
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
[FIX] Theme Build: Only process themes within library namespace #570
Conversation
Themes are expected to be within a "themes" folder directly below the library namespace. Other "themes" folders (e.g. within sub-directories) should be ignored and not compiled/processed.
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.
Do we deem this to be compatible because the runtime never loads themes from other paths anyways? Can't an application still load CSS from other paths?
What's the issue we are fixing here?
lib/types/library/LibraryBuilder.js
Outdated
@@ -152,14 +152,18 @@ class LibraryBuilder extends AbstractBuilder { | |||
} | |||
|
|||
this.addTask("buildThemes", async () => { | |||
// Only compile themes directly below the lib namespace to be in sync with the theme support at runtime | |||
// which only loads themes from that folder. | |||
const inputPattern = `/resources/${project.metadata.namespace}/themes/*/library.source.less`; |
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.
Apparently the namespace can be undefined here, see:
ui5-builder/lib/types/library/LibraryBuilder.js
Lines 6 to 11 in 08a34ae
if (!project.metadata.namespace) { | |
// TODO 3.0: Throw here | |
log.info("Skipping some tasks due to missing library namespace information. Your project " + | |
"might be missing a manifest.json or .library file. " + | |
"Also see: https://sap.github.io/ui5-tooling/pages/Builder/#library"); | |
} |
So a check and fallback is needed.
Do we need the same change in ThemeLibraryBuilder.js?
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.
For theme-library
I decided to rather stay with the existing pattern as we don't really know the namespaces. One solution would be to filter using the information of the available libraries, but that would be a bit more complex and requires that knowledge also within the generateThemeDesignerResources
task.
I think for theme-libraries
we can expect that it only contains themes
folders that should be compiled.
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.
Ok, makes sense! However, we still to add a check for the namespace here, otherwise you might end up with /resources/undefined/themes/*/library.source.less
here
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
Yes, the missing runtime support is what makes us consider this as compatible. Libraries don't load themes from a location other than their namespace. And the issue that we fix here is the unwanted (and sometimes broken) automatic triggering of a theme build just by the naming of a folder. The only convention for libraries is that their root namespace can contain a themes folder whose child folders contain the individual themes. And those will be built. See https://github.com/SAP/openui5/blob/master/docs/controllibraries.md#file-structure . |
Themes are expected to be within a "themes" folder directly below the
library namespace.
Other "themes" folders (e.g. within sub-directories) should be ignored
and not compiled/processed.