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

[FEATURE] Support build minification excludes #653

Merged
merged 4 commits into from
Oct 18, 2021

Conversation

larskissel
Copy link
Member

Supports the build configuration "minification excludes"
introduced in specVersion 2.6. This allows to exclude
JavaScript resources from minification (tasks: uglify and
createDebugFiles).

JIRA: CPOUI5FOUNDATION-405

Supports the build configuration "minification excludes"
introduced in specVersion 2.6. This allows to exclude
JavaScript resources from minification (tasks: uglify and
createDebugFiles).

JIRA: CPOUI5FOUNDATION-405
@larskissel
Copy link
Member Author

Integration tests will be uploaded with the next commit.

@coveralls
Copy link

coveralls commented Oct 15, 2021

Coverage Status

Coverage decreased (-0.006%) to 94.71% when pulling ff01604 on minificationExcludes into be7d24a on master.

const minificationPattern = ["/**/*.js"];
if (["2.6"].includes(project.specVersion)) {
const minification = (project.builder && project.builder.minification) || {};
this.enhancePatternWithExcludes(minificationPattern, minification.excludes);
Copy link
Member

Choose a reason for hiding this comment

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

Should the pattern be prefixed with /resources/ here?
The default pattern for applications is /**/*.js, so I'd expect the excludes to be possible for all paths, not just within /resources/.
Or do I missing something here? For libraries it totally makese sense as we only process /resources/.

Copy link
Member

Choose a reason for hiding this comment

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

I think you're right! I was always only thinking of libraries...

Copy link
Member

Choose a reason for hiding this comment

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

But in that case we should still prepend /, right?
So that patterns are something like sap/ui/demo/todo/thirdparty/**

Copy link
Member Author

Choose a reason for hiding this comment

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

In the new implementation the Application-/LibraryBuilder has to set the prefix. Does it look like you expected it?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm... after thinking again about this, I'm not sure whether / is really correct.
At least not in all cases.

The files within webapp are available at the app namespace. e.g. /resources/sap/ui/demo/todo/Component.js. So using /resources should actually be correct if the app has a namespace. If there is no namespace (see

if (!project.metadata.namespace) {
), I think we should indeed use / as prefix.

Also see handling in Builder:

getVirtualBasePathPrefix: function({project, virBasePath}) {
if (project.type === "application" && project.metadata.namespace) {
return projectBasePath;
}
},

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think we didn't supply "/resources" in the other ApplicationBuilder task's patterns since it doesn't matter for applications (there are no test-resources anyways). However, to prevent the user from having to specify "/resources" in their minification excludes we indeed need to apply the same prefix as for libraries: /resources/.

Example for specifying component preload excludes in the openui5-sample-app:

builder:
  componentPreload:
    excludes:
      - "sap/ui/demo/todo/"

@@ -1614,14 +1690,50 @@ const libraryJTree = {
"configuration": {
"paths": {
"src": "main/src"
}
},
"propertiesFileSourceEncoding": "ISO-8859-1"
Copy link
Member

Choose a reason for hiding this comment

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

Why this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like I made copy&paste to the wrong object. Done.

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.

Fine with me if this also passed a manual test 🙂

@larskissel larskissel merged commit 0aa2301 into master Oct 18, 2021
@larskissel larskissel deleted the minificationExcludes branch October 18, 2021 15:07
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