@ui5/builder 2.11.1 → 3.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +4 -16
- package/jsdoc.json +0 -1
- package/lib/builder/BuildContext.js +17 -0
- package/lib/builder/ProjectBuildContext.js +11 -7
- package/lib/builder/builder.js +1 -2
- package/lib/lbt/analyzer/JSModuleAnalyzer.js +7 -0
- package/lib/lbt/bundle/AutoSplitter.js +10 -24
- package/lib/lbt/bundle/Builder.js +19 -41
- package/lib/lbt/bundle/Resolver.js +1 -1
- package/lib/lbt/resources/LocatorResource.js +0 -2
- package/lib/lbt/resources/Resource.js +7 -0
- package/lib/lbt/resources/ResourceCollector.js +33 -15
- package/lib/lbt/utils/parseUtils.js +1 -1
- package/lib/processors/bundlers/moduleBundler.js +11 -7
- package/lib/processors/manifestCreator.js +1 -1
- package/lib/processors/minifier.js +84 -0
- package/lib/processors/resourceListCreator.js +2 -16
- package/lib/tasks/TaskUtil.js +11 -9
- package/lib/tasks/buildThemes.js +6 -2
- package/lib/tasks/bundlers/generateBundle.js +30 -2
- package/lib/tasks/bundlers/generateComponentPreload.js +8 -1
- package/lib/tasks/bundlers/generateLibraryPreload.js +78 -49
- package/lib/tasks/bundlers/generateStandaloneAppBundle.js +13 -6
- package/lib/tasks/generateResourcesJson.js +14 -8
- package/lib/tasks/minify.js +31 -0
- package/lib/tasks/replaceVersion.js +1 -1
- package/lib/tasks/taskRepository.js +6 -2
- package/lib/types/application/ApplicationBuilder.js +22 -31
- package/lib/types/library/LibraryBuilder.js +22 -28
- package/lib/types/themeLibrary/ThemeLibraryBuilder.js +2 -1
- package/package.json +13 -13
- package/CHANGELOG.md +0 -711
- package/lib/processors/debugFileCreator.js +0 -52
- package/lib/processors/resourceCopier.js +0 -24
- package/lib/processors/uglifier.js +0 -45
- package/lib/tasks/createDebugFiles.js +0 -30
- package/lib/tasks/uglify.js +0 -33
|
@@ -66,17 +66,6 @@ const DEFAULT_SUPPORT_RESOURCES_FILTER = [
|
|
|
66
66
|
"**/*.support.js"
|
|
67
67
|
];
|
|
68
68
|
|
|
69
|
-
/**
|
|
70
|
-
* Hard coded debug bundle, to trigger separate analysis for this filename
|
|
71
|
-
* because sap-ui-core.js and sap-ui-core-dbg.js have different includes
|
|
72
|
-
*
|
|
73
|
-
* @type {string[]}
|
|
74
|
-
*/
|
|
75
|
-
const DEBUG_BUNDLES = [
|
|
76
|
-
"sap-ui-core-dbg.js",
|
|
77
|
-
"sap-ui-core-nojQuery-dbg.js"
|
|
78
|
-
];
|
|
79
|
-
|
|
80
69
|
/**
|
|
81
70
|
* Creates and adds resources.json entry (itself) to the list.
|
|
82
71
|
*
|
|
@@ -138,8 +127,7 @@ module.exports = async function({resources, dependencyResources = [], options})
|
|
|
138
127
|
debugResources: DEFAULT_DEBUG_RESOURCES_FILTER,
|
|
139
128
|
mergedResources: DEFAULT_BUNDLE_RESOURCES_FILTER,
|
|
140
129
|
designtimeResources: DEFAULT_DESIGNTIME_RESOURCES_FILTER,
|
|
141
|
-
supportResources: DEFAULT_SUPPORT_RESOURCES_FILTER
|
|
142
|
-
debugBundles: DEBUG_BUNDLES
|
|
130
|
+
supportResources: DEFAULT_SUPPORT_RESOURCES_FILTER
|
|
143
131
|
}, options);
|
|
144
132
|
|
|
145
133
|
const pool = new LocatorResourcePool();
|
|
@@ -158,12 +146,10 @@ module.exports = async function({resources, dependencyResources = [], options})
|
|
|
158
146
|
}
|
|
159
147
|
|
|
160
148
|
await collector.determineResourceDetails({
|
|
161
|
-
pool,
|
|
162
149
|
debugResources: options.debugResources,
|
|
163
150
|
mergedResources: options.mergedResources,
|
|
164
151
|
designtimeResources: options.designtimeResources,
|
|
165
|
-
supportResources: options.supportResources
|
|
166
|
-
debugBundles: options.debugBundles
|
|
152
|
+
supportResources: options.supportResources
|
|
167
153
|
});
|
|
168
154
|
|
|
169
155
|
// group resources by components and create ResourceInfoLists
|
package/lib/tasks/TaskUtil.js
CHANGED
|
@@ -20,6 +20,8 @@ class TaskUtil {
|
|
|
20
20
|
* @typedef {object} module:@ui5/builder.tasks.TaskUtil~StandardBuildTags
|
|
21
21
|
* @property {string} OmitFromBuildResult
|
|
22
22
|
* Setting this tag to true for a resource will prevent it from being written to the build target
|
|
23
|
+
* @property {string} IsBundle
|
|
24
|
+
* This tag identifies resources that contain (i.e. bundle) multiple other resources
|
|
23
25
|
*/
|
|
24
26
|
|
|
25
27
|
/**
|
|
@@ -49,14 +51,14 @@ class TaskUtil {
|
|
|
49
51
|
* This method is only available to custom task extensions defining
|
|
50
52
|
* <b>Specification Version 2.2 and above</b>.
|
|
51
53
|
*
|
|
52
|
-
* @param {module:@ui5/fs.Resource}
|
|
54
|
+
* @param {string|module:@ui5/fs.Resource} resourcePath Path or resource-instance the tag should be stored for
|
|
53
55
|
* @param {string} tag Name of the tag.
|
|
54
56
|
* Currently only the [STANDARD_TAGS]{@link module:@ui5/builder.tasks.TaskUtil#STANDARD_TAGS} are allowed
|
|
55
57
|
* @param {string|boolean|integer} [value=true] Tag value. Must be primitive
|
|
56
58
|
* @public
|
|
57
59
|
*/
|
|
58
|
-
setTag(
|
|
59
|
-
return this._projectBuildContext.getResourceTagCollection().setTag(
|
|
60
|
+
setTag(resourcePath, tag, value) {
|
|
61
|
+
return this._projectBuildContext.getResourceTagCollection().setTag(resourcePath, tag, value);
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
/**
|
|
@@ -66,14 +68,14 @@ class TaskUtil {
|
|
|
66
68
|
* This method is only available to custom task extensions defining
|
|
67
69
|
* <b>Specification Version 2.2 and above</b>.
|
|
68
70
|
*
|
|
69
|
-
* @param {module:@ui5/fs.Resource}
|
|
71
|
+
* @param {string|module:@ui5/fs.Resource} resourcePath Path or resource-instance the tag should be retrieved for
|
|
70
72
|
* @param {string} tag Name of the tag
|
|
71
73
|
* @returns {string|boolean|integer|undefined} Tag value for the given resource.
|
|
72
74
|
* <code>undefined</code> if no value is available
|
|
73
75
|
* @public
|
|
74
76
|
*/
|
|
75
|
-
getTag(
|
|
76
|
-
return this._projectBuildContext.getResourceTagCollection().getTag(
|
|
77
|
+
getTag(resourcePath, tag) {
|
|
78
|
+
return this._projectBuildContext.getResourceTagCollection().getTag(resourcePath, tag);
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
/**
|
|
@@ -84,12 +86,12 @@ class TaskUtil {
|
|
|
84
86
|
* This method is only available to custom task extensions defining
|
|
85
87
|
* <b>Specification Version 2.2 and above</b>.
|
|
86
88
|
*
|
|
87
|
-
* @param {module:@ui5/fs.Resource}
|
|
89
|
+
* @param {string|module:@ui5/fs.Resource} resourcePath Path or resource-instance the tag should be cleared for
|
|
88
90
|
* @param {string} tag Tag
|
|
89
91
|
* @public
|
|
90
92
|
*/
|
|
91
|
-
clearTag(
|
|
92
|
-
return this._projectBuildContext.getResourceTagCollection().clearTag(
|
|
93
|
+
clearTag(resourcePath, tag) {
|
|
94
|
+
return this._projectBuildContext.getResourceTagCollection().clearTag(resourcePath, tag);
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
/**
|
package/lib/tasks/buildThemes.js
CHANGED
|
@@ -54,8 +54,12 @@ module.exports = async function({
|
|
|
54
54
|
*/
|
|
55
55
|
let availableLibraries;
|
|
56
56
|
if (pAvailableLibraries) {
|
|
57
|
-
availableLibraries =
|
|
58
|
-
|
|
57
|
+
availableLibraries = [];
|
|
58
|
+
(await pAvailableLibraries).forEach((resource) => {
|
|
59
|
+
const library = path.dirname(resource.getPath());
|
|
60
|
+
if (!availableLibraries.includes(library)) {
|
|
61
|
+
availableLibraries.push(library);
|
|
62
|
+
}
|
|
59
63
|
});
|
|
60
64
|
}
|
|
61
65
|
let availableThemes;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const moduleBundler = require("../../processors/bundlers/moduleBundler");
|
|
2
|
+
const ModuleName = require("../../lbt/utils/ModuleName");
|
|
2
3
|
const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritized;
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -13,17 +14,44 @@ const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritiz
|
|
|
13
14
|
* @param {object} parameters.options Options
|
|
14
15
|
* @param {string} parameters.options.projectName Project name
|
|
15
16
|
* @param {ModuleBundleDefinition} parameters.options.bundleDefinition Module bundle definition
|
|
16
|
-
* @param {ModuleBundleOptions} parameters.options.bundleOptions Module bundle options
|
|
17
|
+
* @param {ModuleBundleOptions} [parameters.options.bundleOptions] Module bundle options
|
|
17
18
|
* @returns {Promise} Promise resolving with <code>undefined</code> once data has been written
|
|
18
19
|
*/
|
|
19
20
|
module.exports = function({
|
|
20
21
|
workspace, dependencies, taskUtil, options: {projectName, bundleDefinition, bundleOptions}
|
|
21
22
|
}) {
|
|
22
|
-
|
|
23
|
+
let combo = new ReaderCollectionPrioritized({
|
|
23
24
|
name: `libraryBundler - prioritize workspace over dependencies: ${projectName}`,
|
|
24
25
|
readers: [workspace, dependencies]
|
|
25
26
|
});
|
|
26
27
|
|
|
28
|
+
if (taskUtil) {
|
|
29
|
+
const optimize = !bundleOptions || bundleOptions.optimize !== false;
|
|
30
|
+
|
|
31
|
+
// Omit -dbg files for optimize bundles and vice versa
|
|
32
|
+
const filterTag = optimize ?
|
|
33
|
+
taskUtil.STANDARD_TAGS.IsDebugVariant : taskUtil.STANDARD_TAGS.HasDebugVariant;
|
|
34
|
+
combo = combo.filter(function(resource) {
|
|
35
|
+
return !taskUtil.getTag(resource, filterTag);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
if (!optimize) {
|
|
39
|
+
// For "unoptimized" bundles, the non-debug files have already been filtered out
|
|
40
|
+
// Now rename the debug variants to the same name so that they appear like the original
|
|
41
|
+
// resource to the bundler
|
|
42
|
+
combo = combo.transformer(async function(resourcePath, getResource) {
|
|
43
|
+
if (taskUtil.getTag(resourcePath, taskUtil.STANDARD_TAGS.IsDebugVariant)) {
|
|
44
|
+
const resource = await getResource();
|
|
45
|
+
const nonDbgPath = ModuleName.getNonDebugName(resource.getPath());
|
|
46
|
+
if (!nonDbgPath) {
|
|
47
|
+
throw new Error(`Failed to resolve non-debug name for ${resource.getPath()}`);
|
|
48
|
+
}
|
|
49
|
+
resource.setPath(nonDbgPath);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
27
55
|
return combo.byGlob("/resources/**/*.{js,json,xml,html,properties,library}").then((resources) => {
|
|
28
56
|
return moduleBundler({
|
|
29
57
|
options: {
|
|
@@ -28,11 +28,18 @@ const {negateFilters} = require("../../lbt/resources/ResourceFilterList");
|
|
|
28
28
|
module.exports = function({
|
|
29
29
|
workspace, dependencies, taskUtil, options: {projectName, paths, namespaces, excludes = []}
|
|
30
30
|
}) {
|
|
31
|
-
|
|
31
|
+
let combo = new ReaderCollectionPrioritized({
|
|
32
32
|
name: `generateComponentPreload - prioritize workspace over dependencies: ${projectName}`,
|
|
33
33
|
readers: [workspace, dependencies]
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
+
if (taskUtil) {
|
|
37
|
+
combo = combo.filter(function(resource) {
|
|
38
|
+
// Remove any debug variants
|
|
39
|
+
return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.IsDebugVariant);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
36
43
|
// TODO 3.0: Limit to workspace resources?
|
|
37
44
|
return combo.byGlob("/resources/**/*.{js,json,xml,html,properties,library}")
|
|
38
45
|
.then(async (resources) => {
|
|
@@ -2,6 +2,7 @@ const log = require("@ui5/logger").getLogger("builder:tasks:bundlers:generateLib
|
|
|
2
2
|
const moduleBundler = require("../../processors/bundlers/moduleBundler");
|
|
3
3
|
const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritized;
|
|
4
4
|
const {negateFilters} = require("../../lbt/resources/ResourceFilterList");
|
|
5
|
+
const ModuleName = require("../../lbt/utils/ModuleName");
|
|
5
6
|
|
|
6
7
|
function getDefaultLibraryPreloadFilters(namespace, excludes) {
|
|
7
8
|
const filters = [
|
|
@@ -272,67 +273,95 @@ function getSapUiCoreBunDef(name, filters, preload) {
|
|
|
272
273
|
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
|
|
273
274
|
*/
|
|
274
275
|
module.exports = function({workspace, dependencies, taskUtil, options: {projectName, excludes = []}}) {
|
|
275
|
-
|
|
276
|
+
let combo = new ReaderCollectionPrioritized({
|
|
276
277
|
name: `libraryBundler - prioritize workspace over dependencies: ${projectName}`,
|
|
277
278
|
readers: [workspace, dependencies]
|
|
278
279
|
});
|
|
279
280
|
|
|
280
|
-
|
|
281
|
+
if (taskUtil) {
|
|
282
|
+
combo = combo.filter(function(resource) {
|
|
283
|
+
// Remove any debug variants
|
|
284
|
+
return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.IsDebugVariant);
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return combo.byGlob("/**/*.{js,json,xml,html,properties,library}").then(async (resources) => {
|
|
281
289
|
// Find all libraries and create a library-preload.js bundle
|
|
282
290
|
|
|
283
|
-
let p;
|
|
291
|
+
let p = Promise.resolve();
|
|
284
292
|
|
|
285
|
-
// Create
|
|
286
|
-
//
|
|
293
|
+
// Create core bundles for older versions (<1.97.0) which don't define bundle configuration in the ui5.yaml
|
|
294
|
+
// See: https://github.com/SAP/openui5/commit/ff127fd2d009162ea43ad312dec99d759ebc23a0
|
|
287
295
|
if (projectName === "sap.ui.core") {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
296
|
+
const coreProject = resources[0]._project;
|
|
297
|
+
const coreSpecVersion = coreProject && coreProject.specVersion;
|
|
298
|
+
// Instead of checking the sap.ui.core library version, the specVersion is checked against all versions
|
|
299
|
+
// that have been defined for sap.ui.core before the bundle configuration has been introduced.
|
|
300
|
+
// This is mainly to have an easier check without version parsing or using semver.
|
|
301
|
+
// If no project/specVersion is available, the bundles should also be created to not break potential
|
|
302
|
+
// existing use cases without a properly formed/formatted project tree.
|
|
303
|
+
if (!coreSpecVersion || ["0.1", "1.1", "2.0"].includes(coreSpecVersion)) {
|
|
304
|
+
const isEvo = resources.find((resource) => {
|
|
305
|
+
return resource.getPath() === "/resources/ui5loader.js";
|
|
306
|
+
});
|
|
293
307
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
308
|
+
let unoptimizedResources = resources;
|
|
309
|
+
if (taskUtil) {
|
|
310
|
+
unoptimizedResources = await new ReaderCollectionPrioritized({
|
|
311
|
+
name: `libraryBundler - prioritize workspace over dependencies: ${projectName}`,
|
|
312
|
+
readers: [workspace, dependencies]
|
|
313
|
+
}).filter(function(resource) {
|
|
314
|
+
// Remove any non-debug variants
|
|
315
|
+
return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.HasDebugVariant);
|
|
316
|
+
}).transformer(async function(resourcePath, getResource) {
|
|
317
|
+
if (taskUtil.getTag(resourcePath, taskUtil.STANDARD_TAGS.IsDebugVariant)) {
|
|
318
|
+
const resource = await getResource();
|
|
319
|
+
const nonDbgPath = ModuleName.getNonDebugName(resource.getPath());
|
|
320
|
+
if (!nonDbgPath) {
|
|
321
|
+
throw new Error(`Failed to resolve non-debug name for ${resource.getPath()}`);
|
|
322
|
+
}
|
|
323
|
+
resource.setPath(nonDbgPath);
|
|
324
|
+
}
|
|
325
|
+
}).byGlob("/**/*.{js,json,xml,html,properties,library}");
|
|
326
|
+
}
|
|
303
327
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
options: getModuleBundlerOptions({
|
|
315
|
-
name: "sap-ui-core-nojQuery.js", filters, preload: true, provided: true
|
|
328
|
+
let filters;
|
|
329
|
+
if (isEvo) {
|
|
330
|
+
filters = ["ui5loader-autoconfig.js"];
|
|
331
|
+
} else {
|
|
332
|
+
filters = ["jquery.sap.global.js"];
|
|
333
|
+
}
|
|
334
|
+
p = Promise.all([
|
|
335
|
+
moduleBundler({
|
|
336
|
+
options: getModuleBundlerOptions({name: "sap-ui-core.js", filters, preload: true}),
|
|
337
|
+
resources
|
|
316
338
|
}),
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
options: getModuleBundlerOptions({
|
|
321
|
-
name: "sap-ui-core-nojQuery-dbg.js", filters, preload: false, provided: true
|
|
339
|
+
moduleBundler({
|
|
340
|
+
options: getModuleBundlerOptions({name: "sap-ui-core-dbg.js", filters, preload: false}),
|
|
341
|
+
resources: unoptimizedResources
|
|
322
342
|
}),
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
343
|
+
moduleBundler({
|
|
344
|
+
options: getModuleBundlerOptions({
|
|
345
|
+
name: "sap-ui-core-nojQuery.js", filters, preload: true, provided: true
|
|
346
|
+
}),
|
|
347
|
+
resources
|
|
348
|
+
}),
|
|
349
|
+
moduleBundler({
|
|
350
|
+
options: getModuleBundlerOptions({
|
|
351
|
+
name: "sap-ui-core-nojQuery-dbg.js", filters, preload: false, provided: true
|
|
352
|
+
}),
|
|
353
|
+
resources: unoptimizedResources
|
|
354
|
+
}),
|
|
355
|
+
]).then((results) => {
|
|
356
|
+
const bundles = Array.prototype.concat.apply([], results);
|
|
357
|
+
return Promise.all(bundles.map((bundle) => {
|
|
358
|
+
if (taskUtil) {
|
|
359
|
+
taskUtil.setTag(bundle, taskUtil.STANDARD_TAGS.IsBundle);
|
|
360
|
+
}
|
|
361
|
+
return workspace.write(bundle);
|
|
362
|
+
}));
|
|
363
|
+
});
|
|
364
|
+
}
|
|
336
365
|
}
|
|
337
366
|
|
|
338
367
|
return p.then(() => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const log = require("@ui5/logger").getLogger("builder:tasks:bundlers:generateStandaloneAppBundle");
|
|
2
|
+
const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritized;
|
|
2
3
|
const moduleBundler = require("../../processors/bundlers/moduleBundler");
|
|
3
4
|
|
|
4
5
|
function getBundleDefinition(config) {
|
|
@@ -76,12 +77,18 @@ module.exports = async function({workspace, dependencies, taskUtil, options: {pr
|
|
|
76
77
|
`unable to generate complete bundles for such projects.`);
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
let combo = new ReaderCollectionPrioritized({
|
|
81
|
+
name: `generateStandaloneAppBundle - prioritize workspace over dependencies: ${projectName}`,
|
|
82
|
+
readers: [workspace, dependencies]
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
if (taskUtil) {
|
|
86
|
+
// Omit -dbg files
|
|
87
|
+
combo = combo.filter(function(resource) {
|
|
88
|
+
return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.IsDebugVariant);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
const results = await combo.byGlob("/resources/**/*.{js,json,xml,html,properties,library}");
|
|
85
92
|
const resources = Array.prototype.concat.apply([], results);
|
|
86
93
|
|
|
87
94
|
const isEvo = resources.find((resource) => {
|
|
@@ -96,19 +96,25 @@ function getCreatorOptions(projectName) {
|
|
|
96
96
|
* @alias module:@ui5/builder.tasks.generateResourcesJson
|
|
97
97
|
* @param {object} parameters Parameters
|
|
98
98
|
* @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
|
|
99
|
-
* @param {module:@ui5/fs.AbstractReader}
|
|
99
|
+
* @param {module:@ui5/fs.AbstractReader} parameters.dependencies Reader or Collection to read dependency files
|
|
100
|
+
* @param {module:@ui5/builder.tasks.TaskUtil|object} [parameters.taskUtil] TaskUtil
|
|
100
101
|
* @param {object} parameters.options Options
|
|
101
102
|
* @param {string} parameters.options.projectName Project name
|
|
102
103
|
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
|
|
103
104
|
*/
|
|
104
|
-
module.exports = async function({workspace, dependencies, options: {projectName}}) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
// TODO 3.0: Make dependencies parameter mandatory
|
|
108
|
-
let dependencyResources;
|
|
109
|
-
if (dependencies) {
|
|
110
|
-
dependencyResources =
|
|
105
|
+
module.exports = async function({workspace, dependencies, taskUtil, options: {projectName}}) {
|
|
106
|
+
let resources = await workspace.byGlob(["/resources/**/*"].concat(DEFAULT_EXCLUDES));
|
|
107
|
+
let dependencyResources =
|
|
111
108
|
await dependencies.byGlob("/resources/**/*.{js,json,xml,html,properties,library}");
|
|
109
|
+
|
|
110
|
+
if (taskUtil) {
|
|
111
|
+
// Filter out resources that will be omitted from the build results
|
|
112
|
+
resources = resources.filter((resource) => {
|
|
113
|
+
return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.OmitFromBuildResult);
|
|
114
|
+
});
|
|
115
|
+
dependencyResources = dependencyResources.filter((resource) => {
|
|
116
|
+
return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.OmitFromBuildResult);
|
|
117
|
+
});
|
|
112
118
|
}
|
|
113
119
|
|
|
114
120
|
const resourceLists = await resourceListCreator({
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const minifier = require("../processors/minifier");
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Task to minify resources.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
* @alias module:@ui5/builder.tasks.minify
|
|
8
|
+
* @param {object} parameters Parameters
|
|
9
|
+
* @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
|
|
10
|
+
* @param {module:@ui5/builder.tasks.TaskUtil|object} [parameters.taskUtil] TaskUtil
|
|
11
|
+
* @param {object} parameters.options Options
|
|
12
|
+
* @param {string} parameters.options.pattern Pattern to locate the files to be processed
|
|
13
|
+
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
|
|
14
|
+
*/
|
|
15
|
+
module.exports = async function({workspace, taskUtil, options: {pattern}}) {
|
|
16
|
+
const resources = await workspace.byGlob(pattern);
|
|
17
|
+
const processedResources = await minifier({resources});
|
|
18
|
+
|
|
19
|
+
return Promise.all(processedResources.map(async ({resource, dbgResource, sourceMapResource}) => {
|
|
20
|
+
if (taskUtil) {
|
|
21
|
+
taskUtil.setTag(resource, taskUtil.STANDARD_TAGS.HasDebugVariant);
|
|
22
|
+
taskUtil.setTag(dbgResource, taskUtil.STANDARD_TAGS.IsDebugVariant);
|
|
23
|
+
taskUtil.setTag(sourceMapResource, taskUtil.STANDARD_TAGS.OmitFromBuildResult);
|
|
24
|
+
}
|
|
25
|
+
return Promise.all([
|
|
26
|
+
workspace.write(resource),
|
|
27
|
+
workspace.write(dbgResource),
|
|
28
|
+
workspace.write(sourceMapResource)
|
|
29
|
+
]);
|
|
30
|
+
}));
|
|
31
|
+
};
|
|
@@ -2,12 +2,11 @@ const taskInfos = {
|
|
|
2
2
|
replaceCopyright: {path: "./replaceCopyright"},
|
|
3
3
|
replaceVersion: {path: "./replaceVersion"},
|
|
4
4
|
replaceBuildtime: {path: "./replaceBuildtime"},
|
|
5
|
-
createDebugFiles: {path: "./createDebugFiles"},
|
|
6
5
|
escapeNonAsciiCharacters: {path: "./escapeNonAsciiCharacters"},
|
|
7
6
|
executeJsdocSdkTransformation: {path: "./jsdoc/executeJsdocSdkTransformation"},
|
|
8
7
|
generateApiIndex: {path: "./jsdoc/generateApiIndex"},
|
|
9
8
|
generateJsdoc: {path: "./jsdoc/generateJsdoc"},
|
|
10
|
-
|
|
9
|
+
minify: {path: "./minify"},
|
|
11
10
|
buildThemes: {path: "./buildThemes"},
|
|
12
11
|
transformBootstrapHtml: {path: "./transformBootstrapHtml"},
|
|
13
12
|
generateLibraryManifest: {path: "./generateLibraryManifest"},
|
|
@@ -27,6 +26,11 @@ function getTask(taskName) {
|
|
|
27
26
|
const taskInfo = taskInfos[taskName];
|
|
28
27
|
|
|
29
28
|
if (!taskInfo) {
|
|
29
|
+
if (["createDebugFiles", "uglify"].includes(taskName)) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
`Standard task ${taskName} has been removed in UI5 Tooling 3.0. ` +
|
|
32
|
+
`Please see the migration guide at https://sap.github.io/ui5-tooling/updates/migrate-v3/`);
|
|
33
|
+
}
|
|
30
34
|
throw new Error(`taskRepository: Unknown Task ${taskName}`);
|
|
31
35
|
}
|
|
32
36
|
try {
|
|
@@ -67,6 +67,27 @@ class ApplicationBuilder extends AbstractBuilder {
|
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
// Support rules should not be minified to have readable code in the Support Assistant
|
|
71
|
+
const minificationPattern = ["/**/*.js", "!**/*.support.js"];
|
|
72
|
+
if (["2.6"].includes(project.specVersion)) {
|
|
73
|
+
const minificationExcludes = project.builder && project.builder.minification &&
|
|
74
|
+
project.builder.minification.excludes;
|
|
75
|
+
if (minificationExcludes) {
|
|
76
|
+
// TODO 3.0: namespaces should become mandatory, see existing check above
|
|
77
|
+
const patternPrefix = project.metadata.namespace ? "/resources/" : "/";
|
|
78
|
+
this.enhancePatternWithExcludes(minificationPattern, minificationExcludes, patternPrefix);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
this.addTask("minify", async () => {
|
|
82
|
+
return getTask("minify").task({
|
|
83
|
+
workspace: resourceCollections.workspace,
|
|
84
|
+
taskUtil,
|
|
85
|
+
options: {
|
|
86
|
+
pattern: minificationPattern
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
70
91
|
const componentPreload = project.builder && project.builder.componentPreload;
|
|
71
92
|
if (componentPreload && (componentPreload.namespaces || componentPreload.paths)) {
|
|
72
93
|
this.addTask("generateComponentPreload", async () => {
|
|
@@ -138,37 +159,6 @@ class ApplicationBuilder extends AbstractBuilder {
|
|
|
138
159
|
});
|
|
139
160
|
}
|
|
140
161
|
|
|
141
|
-
const minificationPattern = ["/**/*.js"];
|
|
142
|
-
if (["2.6"].includes(project.specVersion)) {
|
|
143
|
-
const minificationExcludes = project.builder && project.builder.minification &&
|
|
144
|
-
project.builder.minification.excludes;
|
|
145
|
-
if (minificationExcludes) {
|
|
146
|
-
// TODO 3.0: namespaces should become mandatory, see existing check above
|
|
147
|
-
const patternPrefix = project.metadata.namespace ? "/resources/" : "/";
|
|
148
|
-
this.enhancePatternWithExcludes(minificationPattern, minificationExcludes, patternPrefix);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
this.addTask("createDebugFiles", async () => {
|
|
152
|
-
const createDebugFiles = getTask("createDebugFiles").task;
|
|
153
|
-
return createDebugFiles({
|
|
154
|
-
workspace: resourceCollections.workspace,
|
|
155
|
-
options: {
|
|
156
|
-
pattern: minificationPattern
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
this.addTask("uglify", async () => {
|
|
162
|
-
const uglify = getTask("uglify").task;
|
|
163
|
-
return uglify({
|
|
164
|
-
workspace: resourceCollections.workspace,
|
|
165
|
-
taskUtil,
|
|
166
|
-
options: {
|
|
167
|
-
pattern: minificationPattern
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
|
|
172
162
|
this.addTask("generateVersionInfo", async () => {
|
|
173
163
|
return getTask("generateVersionInfo").task({
|
|
174
164
|
workspace: resourceCollections.workspace,
|
|
@@ -209,6 +199,7 @@ class ApplicationBuilder extends AbstractBuilder {
|
|
|
209
199
|
return getTask("generateResourcesJson").task({
|
|
210
200
|
workspace: resourceCollections.workspace,
|
|
211
201
|
dependencies: resourceCollections.dependencies,
|
|
202
|
+
taskUtil,
|
|
212
203
|
options: {
|
|
213
204
|
projectName: project.metadata.name
|
|
214
205
|
}
|
|
@@ -89,6 +89,26 @@ class LibraryBuilder extends AbstractBuilder {
|
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
// Support rules should not be minified to have readable code in the Support Assistant
|
|
93
|
+
const minificationPattern = ["/resources/**/*.js", "!**/*.support.js"];
|
|
94
|
+
if (["2.6"].includes(project.specVersion)) {
|
|
95
|
+
const minificationExcludes = project.builder && project.builder.minification &&
|
|
96
|
+
project.builder.minification.excludes;
|
|
97
|
+
if (minificationExcludes) {
|
|
98
|
+
this.enhancePatternWithExcludes(minificationPattern, minificationExcludes, "/resources/");
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
this.addTask("minify", async () => {
|
|
103
|
+
return getTask("minify").task({
|
|
104
|
+
workspace: resourceCollections.workspace,
|
|
105
|
+
taskUtil,
|
|
106
|
+
options: {
|
|
107
|
+
pattern: minificationPattern
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
92
112
|
const componentPreload = project.builder && project.builder.componentPreload;
|
|
93
113
|
if (componentPreload) {
|
|
94
114
|
this.addTask("generateComponentPreload", async () => {
|
|
@@ -176,7 +196,7 @@ class LibraryBuilder extends AbstractBuilder {
|
|
|
176
196
|
dependencies: resourceCollections.dependencies,
|
|
177
197
|
options: {
|
|
178
198
|
projectName: project.metadata.name,
|
|
179
|
-
librariesPattern: !taskUtil.isRootProject() ? "/resources
|
|
199
|
+
librariesPattern: !taskUtil.isRootProject() ? "/resources/**/(*.library|library.js)" : undefined,
|
|
180
200
|
themesPattern: !taskUtil.isRootProject() ? "/resources/sap/ui/core/themes/*" : undefined,
|
|
181
201
|
inputPattern
|
|
182
202
|
}
|
|
@@ -195,37 +215,11 @@ class LibraryBuilder extends AbstractBuilder {
|
|
|
195
215
|
});
|
|
196
216
|
});
|
|
197
217
|
|
|
198
|
-
const minificationPattern = ["/resources/**/*.js"];
|
|
199
|
-
if (["2.6"].includes(project.specVersion)) {
|
|
200
|
-
const minificationExcludes = project.builder && project.builder.minification &&
|
|
201
|
-
project.builder.minification.excludes;
|
|
202
|
-
if (minificationExcludes) {
|
|
203
|
-
this.enhancePatternWithExcludes(minificationPattern, minificationExcludes, "/resources/");
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
this.addTask("createDebugFiles", async () => {
|
|
207
|
-
return getTask("createDebugFiles").task({
|
|
208
|
-
workspace: resourceCollections.workspace,
|
|
209
|
-
options: {
|
|
210
|
-
pattern: minificationPattern
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
this.addTask("uglify", async () => {
|
|
216
|
-
return getTask("uglify").task({
|
|
217
|
-
workspace: resourceCollections.workspace,
|
|
218
|
-
taskUtil,
|
|
219
|
-
options: {
|
|
220
|
-
pattern: minificationPattern
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
|
|
225
218
|
this.addTask("generateResourcesJson", () => {
|
|
226
219
|
return getTask("generateResourcesJson").task({
|
|
227
220
|
workspace: resourceCollections.workspace,
|
|
228
221
|
dependencies: resourceCollections.dependencies,
|
|
222
|
+
taskUtil,
|
|
229
223
|
options: {
|
|
230
224
|
projectName: project.metadata.name
|
|
231
225
|
}
|
|
@@ -29,7 +29,7 @@ class ThemeLibraryBuilder extends AbstractBuilder {
|
|
|
29
29
|
dependencies: resourceCollections.dependencies,
|
|
30
30
|
options: {
|
|
31
31
|
projectName: project.metadata.name,
|
|
32
|
-
librariesPattern: !taskUtil.isRootProject() ? "/resources
|
|
32
|
+
librariesPattern: !taskUtil.isRootProject() ? "/resources/**/(*.library|library.js)" : undefined,
|
|
33
33
|
themesPattern: !taskUtil.isRootProject() ? "/resources/sap/ui/core/themes/*" : undefined,
|
|
34
34
|
inputPattern: "/resources/**/themes/*/library.source.less"
|
|
35
35
|
}
|
|
@@ -51,6 +51,7 @@ class ThemeLibraryBuilder extends AbstractBuilder {
|
|
|
51
51
|
return getTask("generateResourcesJson").task({
|
|
52
52
|
workspace: resourceCollections.workspace,
|
|
53
53
|
dependencies: resourceCollections.dependencies,
|
|
54
|
+
taskUtil,
|
|
54
55
|
options: {
|
|
55
56
|
projectName: project.metadata.name
|
|
56
57
|
}
|