Skip to content

Commit

Permalink
[INTERNAL] ApplicationBuilder: Align task order of "minify"
Browse files Browse the repository at this point in the history
In the LibraryBuilder the task is executed before the
generateManifestBundle and before any of the bundle tasks.
Therefore, the minify task should be executed right after the
replaceVersion task.
  • Loading branch information
matz3 committed Apr 12, 2022
1 parent 1369dc5 commit d2c269f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
42 changes: 21 additions & 21 deletions lib/types/application/ApplicationBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,27 @@ class ApplicationBuilder extends AbstractBuilder {
});
});

// Support rules should not be minified to have readable code in the Support Assistant
const minificationPattern = ["/**/*.js", "!**/*.support.js"];
if (["2.6"].includes(project.specVersion)) {
const minificationExcludes = project.builder && project.builder.minification &&
project.builder.minification.excludes;
if (minificationExcludes) {
// TODO 3.0: namespaces should become mandatory, see existing check above
const patternPrefix = project.metadata.namespace ? "/resources/" : "/";
this.enhancePatternWithExcludes(minificationPattern, minificationExcludes, patternPrefix);
}
}
this.addTask("minify", async () => {
return getTask("minify").task({
workspace: resourceCollections.workspace,
taskUtil,
options: {
pattern: minificationPattern
}
});
});

this.addTask("generateFlexChangesBundle", async () => {
const generateFlexChangesBundle = getTask("generateFlexChangesBundle").task;
return generateFlexChangesBundle({
Expand All @@ -67,27 +88,6 @@ class ApplicationBuilder extends AbstractBuilder {
});
}

// Support rules should not be minified to have readable code in the Support Assistant
const minificationPattern = ["/**/*.js", "!**/*.support.js"];
if (["2.6"].includes(project.specVersion)) {
const minificationExcludes = project.builder && project.builder.minification &&
project.builder.minification.excludes;
if (minificationExcludes) {
// TODO 3.0: namespaces should become mandatory, see existing check above
const patternPrefix = project.metadata.namespace ? "/resources/" : "/";
this.enhancePatternWithExcludes(minificationPattern, minificationExcludes, patternPrefix);
}
}
this.addTask("minify", async () => {
return getTask("minify").task({
workspace: resourceCollections.workspace,
taskUtil,
options: {
pattern: minificationPattern
}
});
});

const componentPreload = project.builder && project.builder.componentPreload;
if (componentPreload && (componentPreload.namespaces || componentPreload.paths)) {
this.addTask("generateComponentPreload", async () => {
Expand Down
10 changes: 5 additions & 5 deletions test/lib/types/application/ApplicationBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ test("Instantiation", (t) => {
"escapeNonAsciiCharacters",
"replaceCopyright",
"replaceVersion",
"minify",
"generateFlexChangesBundle",
"generateManifestBundle",
"minify",
"generateComponentPreload",
"generateStandaloneAppBundle",
"transformBootstrapHtml",
Expand All @@ -83,9 +83,9 @@ test("Instantiation without component preload project configuration", (t) => {
"escapeNonAsciiCharacters",
"replaceCopyright",
"replaceVersion",
"minify",
"generateFlexChangesBundle",
"generateManifestBundle",
"minify",
"generateComponentPreload",
"generateStandaloneAppBundle",
"transformBootstrapHtml",
Expand All @@ -107,8 +107,8 @@ test("Instantiation without project namespace", (t) => {
"escapeNonAsciiCharacters",
"replaceCopyright",
"replaceVersion",
"generateFlexChangesBundle",
"minify",
"generateFlexChangesBundle",
"generateStandaloneAppBundle",
"transformBootstrapHtml",
"generateBundle",
Expand All @@ -131,10 +131,10 @@ test("Instantiation with custom tasks", (t) => {
"replaceCopyright",
"minify--1",
"replaceVersion",
"generateFlexChangesBundle",
"generateManifestBundle",
"minify",
"replaceVersion--1",
"generateFlexChangesBundle",
"generateManifestBundle",
"generateComponentPreload",
"generateStandaloneAppBundle",
"transformBootstrapHtml",
Expand Down

0 comments on commit d2c269f

Please sign in to comment.