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

[FIX] Theme Build: Only process themes within library namespace #570

Merged
merged 2 commits into from
Jan 21, 2021

Conversation

matz3
Copy link
Member

@matz3 matz3 commented Jan 20, 2021

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.

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.
@coveralls
Copy link

coveralls commented Jan 20, 2021

Coverage Status

Coverage decreased (-0.008%) to 93.678% when pulling 9267ddc on fix-themes-glob-patterns into 08a34ae on master.

Copy link
Member

@RandomByte RandomByte left a 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?

@@ -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`;
Copy link
Member

@RandomByte RandomByte Jan 20, 2021

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:

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?

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@codeworrior
Copy link
Member

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?

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 .

@matz3 matz3 requested a review from RandomByte January 21, 2021 11:42
@matz3 matz3 merged commit 8cecc01 into master Jan 21, 2021
@matz3 matz3 deleted the fix-themes-glob-patterns branch January 21, 2021 11:52
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

Successfully merging this pull request may close these issues.

4 participants