@ui5/builder 2.11.5 → 3.0.0-alpha.10

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.
Files changed (70) hide show
  1. package/CHANGELOG.md +125 -12
  2. package/index.js +4 -59
  3. package/jsdoc.json +0 -1
  4. package/lib/lbt/analyzer/JSModuleAnalyzer.js +31 -5
  5. package/lib/lbt/analyzer/XMLTemplateAnalyzer.js +2 -1
  6. package/lib/lbt/bundle/AutoSplitter.js +10 -24
  7. package/lib/lbt/bundle/Builder.js +367 -168
  8. package/lib/lbt/bundle/BundleWriter.js +17 -0
  9. package/lib/lbt/bundle/Resolver.js +3 -3
  10. package/lib/lbt/resources/LocatorResource.js +7 -9
  11. package/lib/lbt/resources/LocatorResourcePool.js +8 -4
  12. package/lib/lbt/resources/Resource.js +7 -0
  13. package/lib/lbt/resources/ResourceCollector.js +43 -18
  14. package/lib/lbt/resources/ResourceInfoList.js +0 -1
  15. package/lib/lbt/resources/ResourcePool.js +7 -6
  16. package/lib/lbt/utils/escapePropertiesFile.js +3 -6
  17. package/lib/lbt/utils/parseUtils.js +1 -1
  18. package/lib/processors/bundlers/moduleBundler.js +42 -17
  19. package/lib/processors/jsdoc/lib/createIndexFiles.js +1 -1
  20. package/lib/processors/jsdoc/lib/transformApiJson.js +7 -16
  21. package/lib/processors/jsdoc/lib/ui5/plugin.js +111 -6
  22. package/lib/processors/jsdoc/lib/ui5/template/publish.js +112 -91
  23. package/lib/processors/jsdoc/lib/ui5/template/utils/versionUtil.js +1 -1
  24. package/lib/processors/manifestCreator.js +8 -45
  25. package/lib/processors/minifier.js +90 -0
  26. package/lib/processors/resourceListCreator.js +2 -16
  27. package/lib/tasks/buildThemes.js +1 -1
  28. package/lib/tasks/bundlers/generateBundle.js +82 -14
  29. package/lib/tasks/bundlers/generateComponentPreload.js +31 -17
  30. package/lib/tasks/bundlers/generateFlexChangesBundle.js +7 -3
  31. package/lib/tasks/bundlers/generateLibraryPreload.js +127 -79
  32. package/lib/tasks/bundlers/generateManifestBundle.js +8 -10
  33. package/lib/tasks/bundlers/generateStandaloneAppBundle.js +54 -15
  34. package/lib/tasks/bundlers/utils/createModuleNameMapping.js +31 -0
  35. package/lib/tasks/generateCachebusterInfo.js +7 -3
  36. package/lib/tasks/generateLibraryManifest.js +6 -8
  37. package/lib/tasks/generateResourcesJson.js +15 -9
  38. package/lib/tasks/generateThemeDesignerResources.js +118 -2
  39. package/lib/tasks/generateVersionInfo.js +5 -5
  40. package/lib/tasks/jsdoc/generateJsdoc.js +1 -1
  41. package/lib/tasks/minify.js +41 -0
  42. package/lib/tasks/replaceVersion.js +1 -1
  43. package/lib/tasks/taskRepository.js +7 -15
  44. package/lib/tasks/transformBootstrapHtml.js +6 -1
  45. package/package.json +20 -19
  46. package/lib/builder/BuildContext.js +0 -39
  47. package/lib/builder/ProjectBuildContext.js +0 -55
  48. package/lib/builder/builder.js +0 -420
  49. package/lib/processors/debugFileCreator.js +0 -52
  50. package/lib/processors/resourceCopier.js +0 -24
  51. package/lib/processors/uglifier.js +0 -45
  52. package/lib/tasks/TaskUtil.js +0 -160
  53. package/lib/tasks/createDebugFiles.js +0 -30
  54. package/lib/tasks/uglify.js +0 -33
  55. package/lib/types/AbstractBuilder.js +0 -270
  56. package/lib/types/AbstractFormatter.js +0 -66
  57. package/lib/types/AbstractUi5Formatter.js +0 -95
  58. package/lib/types/application/ApplicationBuilder.js +0 -220
  59. package/lib/types/application/ApplicationFormatter.js +0 -227
  60. package/lib/types/application/applicationType.js +0 -15
  61. package/lib/types/library/LibraryBuilder.js +0 -237
  62. package/lib/types/library/LibraryFormatter.js +0 -519
  63. package/lib/types/library/libraryType.js +0 -15
  64. package/lib/types/module/ModuleBuilder.js +0 -7
  65. package/lib/types/module/ModuleFormatter.js +0 -54
  66. package/lib/types/module/moduleType.js +0 -15
  67. package/lib/types/themeLibrary/ThemeLibraryBuilder.js +0 -62
  68. package/lib/types/themeLibrary/ThemeLibraryFormatter.js +0 -90
  69. package/lib/types/themeLibrary/themeLibraryType.js +0 -15
  70. package/lib/types/typeRepository.js +0 -46
@@ -1,13 +1,13 @@
1
1
  const log = require("@ui5/logger").getLogger("builder:tasks:bundlers:generateLibraryPreload");
2
2
  const moduleBundler = require("../../processors/bundlers/moduleBundler");
3
- const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritized;
4
3
  const {negateFilters} = require("../../lbt/resources/ResourceFilterList");
4
+ const createModuleNameMapping = require("./utils/createModuleNameMapping");
5
5
 
6
6
  function getDefaultLibraryPreloadFilters(namespace, excludes) {
7
7
  const filters = [
8
8
  `${namespace}/`,
9
9
  `${namespace}/**/manifest.json`,
10
- `!${namespace}/*-preload.js`, // exclude all bundles
10
+ `!${namespace}/**/*-preload.js`, // exclude all bundles
11
11
  `!${namespace}/designtime/`,
12
12
  `!${namespace}/**/*.designtime.js`,
13
13
  `!${namespace}/**/*.support.js`
@@ -142,46 +142,6 @@ function getSupportFilesBundleDefinition(namespace) {
142
142
  };
143
143
  }
144
144
 
145
- function createLibraryBundles(libraryNamespace, resources, excludes) {
146
- return Promise.all([
147
- moduleBundler({
148
- options: {
149
- bundleDefinition: getBundleDefinition(libraryNamespace, excludes),
150
- bundleOptions: {
151
- optimize: true,
152
- usePredefineCalls: true,
153
- ignoreMissingModules: true
154
- }
155
- },
156
- resources
157
- }),
158
- moduleBundler({
159
- options: {
160
- bundleDefinition: getDesigntimeBundleDefinition(libraryNamespace),
161
- bundleOptions: {
162
- optimize: true,
163
- usePredefineCalls: true,
164
- ignoreMissingModules: true,
165
- skipIfEmpty: true
166
- }
167
- },
168
- resources
169
- }),
170
- moduleBundler({
171
- options: {
172
- bundleDefinition: getSupportFilesBundleDefinition(libraryNamespace),
173
- bundleOptions: {
174
- optimize: false,
175
- usePredefineCalls: true,
176
- ignoreMissingModules: true,
177
- skipIfEmpty: true
178
- }
179
- },
180
- resources
181
- })
182
- ]);
183
- }
184
-
185
145
  function getModuleBundlerOptions(config) {
186
146
  const moduleBundlerOptions = {};
187
147
 
@@ -211,6 +171,10 @@ function getModuleBundlerOptions(config) {
211
171
  moduleBundlerOptions.bundleDefinition.sections.unshift(providedSection);
212
172
  }
213
173
 
174
+ if (config.moduleNameMapping) {
175
+ moduleBundlerOptions.moduleNameMapping = config.moduleNameMapping;
176
+ }
177
+
214
178
  return moduleBundlerOptions;
215
179
  }
216
180
 
@@ -259,25 +223,36 @@ function getSapUiCoreBunDef(name, filters, preload) {
259
223
  * @alias module:@ui5/builder.tasks.generateLibraryPreload
260
224
  * @param {object} parameters Parameters
261
225
  * @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
262
- * @param {module:@ui5/fs.AbstractReader} parameters.dependencies Reader or Collection to read dependency files
263
- * @param {module:@ui5/builder.tasks.TaskUtil|object} [parameters.taskUtil] TaskUtil
226
+ * @param {module:@ui5/project.build.helpers.TaskUtil} [parameters.taskUtil] TaskUtil
227
+ * @param {object} parameters.options Options
228
+ * @param {string} parameters.options.projectName Project name
229
+ * @param {string[]} [parameters.options.skipBundles] Names of bundles that should not be created
264
230
  * @param {string[]} [parameters.options.excludes=[]] List of modules declared as glob patterns (resource name patterns)
265
231
  * that should be excluded from the library-preload.js bundle.
266
232
  * A pattern ending with a slash '/' will, similarly to the use of a single '*' or double '**' asterisk,
267
233
  * denote an arbitrary number of characters or folder names.
268
234
  * Re-includes should be marked with a leading exclamation mark '!'. The order of filters is relevant; a later
269
235
  * inclusion overrides an earlier exclusion, and vice versa.
270
- * @param {object} parameters.options Options
271
- * @param {string} parameters.options.projectName Project name
272
236
  * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
273
237
  */
274
- module.exports = function({workspace, dependencies, taskUtil, options: {projectName, excludes = []}}) {
275
- const combo = new ReaderCollectionPrioritized({
276
- name: `libraryBundler - prioritize workspace over dependencies: ${projectName}`,
277
- readers: [workspace, dependencies]
278
- });
238
+ module.exports = function({workspace, taskUtil, options: {skipBundles = [], excludes = [], projectName}}) {
239
+ let nonDbgWorkspace = workspace;
240
+ if (taskUtil) {
241
+ nonDbgWorkspace = workspace.filter(function(resource) {
242
+ // Remove any debug variants
243
+ return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.IsDebugVariant);
244
+ });
245
+ }
279
246
 
280
- return combo.byGlob("/**/*.{js,json,xml,html,properties,library}").then((resources) => {
247
+ const execModuleBundlerIfNeeded = ({options, resources}) => {
248
+ if (skipBundles.includes(options.bundleDefinition.name)) {
249
+ log.verbose(`Skipping generation of bundle ${options.bundleDefinition.name}`);
250
+ return null;
251
+ }
252
+ return moduleBundler({options, resources});
253
+ };
254
+
255
+ return nonDbgWorkspace.byGlob("/**/*.{js,json,xml,html,properties,library,js.map}").then(async (resources) => {
281
256
  // Find all libraries and create a library-preload.js bundle
282
257
 
283
258
  let p = Promise.resolve();
@@ -285,17 +260,30 @@ module.exports = function({workspace, dependencies, taskUtil, options: {projectN
285
260
  // Create core bundles for older versions (<1.97.0) which don't define bundle configuration in the ui5.yaml
286
261
  // See: https://github.com/SAP/openui5/commit/ff127fd2d009162ea43ad312dec99d759ebc23a0
287
262
  if (projectName === "sap.ui.core") {
288
- const coreProject = resources[0]._project;
289
- const coreSpecVersion = coreProject && coreProject.specVersion;
290
263
  // Instead of checking the sap.ui.core library version, the specVersion is checked against all versions
291
264
  // that have been defined for sap.ui.core before the bundle configuration has been introduced.
292
265
  // This is mainly to have an easier check without version parsing or using semver.
293
266
  // If no project/specVersion is available, the bundles should also be created to not break potential
294
267
  // existing use cases without a properly formed/formatted project tree.
295
- if (!coreSpecVersion || ["0.1", "1.1", "2.0"].includes(coreSpecVersion)) {
268
+ if (!taskUtil || ["0.1", "1.1", "2.0"].includes(taskUtil.getProject().getSpecVersion())) {
296
269
  const isEvo = resources.find((resource) => {
297
270
  return resource.getPath() === "/resources/ui5loader.js";
298
271
  });
272
+
273
+ let unoptimizedModuleNameMapping;
274
+ let unoptimizedResources = resources;
275
+ if (taskUtil) {
276
+ unoptimizedResources = await workspace.filter(function(resource) {
277
+ // Remove any non-debug variants
278
+ return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.HasDebugVariant);
279
+ }).byGlob("/**/*.{js,json,xml,html,properties,library,js.map}");
280
+
281
+ unoptimizedModuleNameMapping = createModuleNameMapping({
282
+ resources: unoptimizedResources,
283
+ taskUtil
284
+ });
285
+ }
286
+
299
287
  let filters;
300
288
  if (isEvo) {
301
289
  filters = ["ui5loader-autoconfig.js"];
@@ -303,33 +291,46 @@ module.exports = function({workspace, dependencies, taskUtil, options: {projectN
303
291
  filters = ["jquery.sap.global.js"];
304
292
  }
305
293
  p = Promise.all([
306
- moduleBundler({
294
+ execModuleBundlerIfNeeded({
307
295
  options: getModuleBundlerOptions({name: "sap-ui-core.js", filters, preload: true}),
308
296
  resources
309
297
  }),
310
- moduleBundler({
311
- options: getModuleBundlerOptions({name: "sap-ui-core-dbg.js", filters, preload: false}),
312
- resources
298
+ execModuleBundlerIfNeeded({
299
+ options: getModuleBundlerOptions({
300
+ name: "sap-ui-core-dbg.js", filters, preload: false,
301
+ moduleNameMapping: unoptimizedModuleNameMapping
302
+ }),
303
+ resources: unoptimizedResources
313
304
  }),
314
- moduleBundler({
305
+ execModuleBundlerIfNeeded({
315
306
  options: getModuleBundlerOptions({
316
307
  name: "sap-ui-core-nojQuery.js", filters, preload: true, provided: true
317
308
  }),
318
309
  resources
319
310
  }),
320
- moduleBundler({
311
+ execModuleBundlerIfNeeded({
321
312
  options: getModuleBundlerOptions({
322
- name: "sap-ui-core-nojQuery-dbg.js", filters, preload: false, provided: true
313
+ name: "sap-ui-core-nojQuery-dbg.js", filters, preload: false, provided: true,
314
+ moduleNameMapping: unoptimizedModuleNameMapping
323
315
  }),
324
- resources
316
+ resources: unoptimizedResources
325
317
  }),
326
318
  ]).then((results) => {
327
- const bundles = Array.prototype.concat.apply([], results);
328
- return Promise.all(bundles.map((bundle) => {
319
+ const bundles = Array.prototype.concat.apply([], results).filter(Boolean);
320
+ return Promise.all(bundles.map(({bundle, sourceMap}) => {
329
321
  if (taskUtil) {
330
322
  taskUtil.setTag(bundle, taskUtil.STANDARD_TAGS.IsBundle);
323
+ if (sourceMap) {
324
+ // Clear tag that might have been set by the minify task, in cases where
325
+ // the bundle name is identical to a source file
326
+ taskUtil.clearTag(sourceMap, taskUtil.STANDARD_TAGS.OmitFromBuildResult);
327
+ }
328
+ }
329
+ const writes = [workspace.write(bundle)];
330
+ if (sourceMap) {
331
+ writes.push(workspace.write(sourceMap));
331
332
  }
332
- return workspace.write(bundle);
333
+ return Promise.all(writes);
333
334
  }));
334
335
  });
335
336
  }
@@ -342,7 +343,8 @@ module.exports = function({workspace, dependencies, taskUtil, options: {projectN
342
343
  } else {
343
344
  // Fallback to "library.js" as library indicator
344
345
  log.verbose(
345
- `Could not find a ".library" file for project ${projectName}, falling back to "library.js".`);
346
+ `Could not find a ".library" file for project ${projectName}, ` +
347
+ `falling back to "library.js".`);
346
348
  return workspace.byGlob("/resources/**/library.js");
347
349
  }
348
350
  }).then((libraryIndicatorResources) => {
@@ -354,7 +356,7 @@ module.exports = function({workspace, dependencies, taskUtil, options: {projectN
354
356
  return;
355
357
  }
356
358
 
357
- return Promise.all(libraryIndicatorResources.map((libraryIndicatorResource) => {
359
+ return Promise.all(libraryIndicatorResources.map(async (libraryIndicatorResource) => {
358
360
  // Determine library namespace from library indicator file path
359
361
  // ending with either ".library" or "library.js" (see fallback logic above)
360
362
  // e.g. /resources/sap/foo/.library => sap/foo
@@ -364,18 +366,64 @@ module.exports = function({workspace, dependencies, taskUtil, options: {projectN
364
366
  const libraryNamespaceMatch = libraryIndicatorPath.match(libraryNamespacePattern);
365
367
  if (libraryNamespaceMatch && libraryNamespaceMatch[1]) {
366
368
  const libraryNamespace = libraryNamespaceMatch[1];
367
- return createLibraryBundles(libraryNamespace, resources, excludes)
368
- .then((results) => {
369
- const bundles = Array.prototype.concat.apply([], results);
370
- return Promise.all(bundles.map((bundle) => {
371
- if (bundle) {
372
- if (taskUtil) {
373
- taskUtil.setTag(bundle, taskUtil.STANDARD_TAGS.IsBundle);
374
- }
375
- return workspace.write(bundle);
369
+ const results = await Promise.all([
370
+ execModuleBundlerIfNeeded({
371
+ options: {
372
+ bundleDefinition: getBundleDefinition(libraryNamespace, excludes),
373
+ bundleOptions: {
374
+ optimize: true,
375
+ usePredefineCalls: true,
376
+ ignoreMissingModules: true
377
+ }
378
+ },
379
+ resources
380
+ }),
381
+ execModuleBundlerIfNeeded({
382
+ options: {
383
+ bundleDefinition: getDesigntimeBundleDefinition(libraryNamespace),
384
+ bundleOptions: {
385
+ optimize: true,
386
+ usePredefineCalls: true,
387
+ ignoreMissingModules: true,
388
+ skipIfEmpty: true
389
+ }
390
+ },
391
+ resources
392
+ }),
393
+ execModuleBundlerIfNeeded({
394
+ options: {
395
+ bundleDefinition: getSupportFilesBundleDefinition(libraryNamespace),
396
+ bundleOptions: {
397
+ optimize: false,
398
+ usePredefineCalls: true,
399
+ ignoreMissingModules: true,
400
+ skipIfEmpty: true
401
+ }
402
+ // Note: Although the bundle uses optimize=false, there is
403
+ // no moduleNameMapping needed, as support files are excluded from minification.
404
+ },
405
+ resources
406
+ })
407
+ ]);
408
+ const bundles = Array.prototype.concat.apply([], results).filter(Boolean);
409
+ return Promise.all(bundles.map(({bundle, sourceMap} = {}) => {
410
+ if (bundle) {
411
+ if (taskUtil) {
412
+ taskUtil.setTag(bundle, taskUtil.STANDARD_TAGS.IsBundle);
413
+ if (sourceMap) {
414
+ // Clear tag that might have been set by the minify task, in cases where
415
+ // the bundle name is identical to a source file
416
+ taskUtil.clearTag(sourceMap,
417
+ taskUtil.STANDARD_TAGS.OmitFromBuildResult);
376
418
  }
377
- }));
378
- });
419
+ }
420
+ const writes = [workspace.write(bundle)];
421
+ if (sourceMap) {
422
+ writes.push(workspace.write(sourceMap));
423
+ }
424
+ return Promise.all(writes);
425
+ }
426
+ }));
379
427
  } else {
380
428
  log.verbose(
381
429
  `Could not determine library namespace from file "${libraryIndicatorPath}" ` +
@@ -4,14 +4,7 @@ const DESCRIPTOR = "manifest.json";
4
4
  const PROPERTIES_EXT = ".properties";
5
5
  const BUNDLE_NAME = "manifest-bundle.zip";
6
6
 
7
- /**
8
- *
9
- * @public
10
- * @typedef {object} ManifestBundlerOptions
11
- * @property {string} projectName Project Name
12
- * @property {string} namespace Namespace
13
- */
14
-
7
+ /* eslint "jsdoc/check-param-names": ["error", {"disableExtraPropertyReporting":true}] */
15
8
  /**
16
9
  * Task for manifestBundler.
17
10
  *
@@ -19,11 +12,16 @@ const BUNDLE_NAME = "manifest-bundle.zip";
19
12
  * @alias module:@ui5/builder.tasks.generateManifestBundle
20
13
  * @param {object} parameters Parameters
21
14
  * @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
22
- * @param {ManifestBundlerOptions} parameters.options Options
15
+ * @param {object} parameters.options Options
16
+ * @param {string} parameters.options.projectName Project name
17
+ * @param {string} parameters.options.projectNamespace Project namespace
23
18
  * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
24
19
  */
25
20
  module.exports = async function({workspace, options = {}}) {
26
- const {projectName, namespace} = options;
21
+ const {projectName} = options;
22
+ // Backward compatibility: "namespace" option got renamed to "projectNamespace"
23
+ const namespace = options.projectNamespace || options.namespace;
24
+
27
25
  if (!projectName || !namespace) {
28
26
  throw new Error("[generateManifestBundle]: One or more mandatory options not provided");
29
27
  }
@@ -1,5 +1,7 @@
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");
4
+ const createModuleNameMapping = require("./utils/createModuleNameMapping");
3
5
 
4
6
  function getBundleDefinition(config) {
5
7
  const bundleDefinition = {
@@ -56,6 +58,7 @@ function getBundleDefinition(config) {
56
58
  return bundleDefinition;
57
59
  }
58
60
 
61
+ /* eslint "jsdoc/check-param-names": ["error", {"disableExtraPropertyReporting":true}] */
59
62
  /**
60
63
  * Task for bundling standalone applications.
61
64
  *
@@ -64,25 +67,34 @@ function getBundleDefinition(config) {
64
67
  * @param {object} parameters Parameters
65
68
  * @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
66
69
  * @param {module:@ui5/fs.AbstractReader} parameters.dependencies Reader or Collection to read dependency files
67
- * @param {module:@ui5/builder.tasks.TaskUtil|object} [parameters.taskUtil] TaskUtil
70
+ * @param {module:@ui5/project.build.helpers.TaskUtil|object} [parameters.taskUtil] TaskUtil
68
71
  * @param {object} parameters.options Options
69
72
  * @param {string} parameters.options.projectName Project name
70
- * @param {string} [parameters.options.namespace] Project namespace
73
+ * @param {string} [parameters.options.projectNamespace] Project namespace
71
74
  * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
72
75
  */
73
- module.exports = async function({workspace, dependencies, taskUtil, options: {projectName, namespace}}) {
76
+ module.exports = async function({workspace, dependencies, taskUtil, options}) {
77
+ const {projectName} = options;
78
+ // Backward compatibility: "namespace" option got renamed to "projectNamespace"
79
+ const namespace = options.projectNamespace || options.namespace;
80
+
74
81
  if (!namespace) {
75
82
  log.warn(`Namespace of project ${projectName} is not known. Self contained bundling is currently ` +
76
83
  `unable to generate complete bundles for such projects.`);
77
84
  }
78
85
 
79
- // If an application does not have a namespace, its resources are located at the root. Otherwise in /resources
80
- // For dependencies, we do not want to search in their test-resources
81
- const results = await Promise.all([
82
- workspace.byGlob("/**/*.{js,json,xml,html,properties,library}"),
83
- dependencies.byGlob("/resources/**/*.{js,json,xml,html,properties,library}")
84
- ]);
85
- const resources = Array.prototype.concat.apply([], results);
86
+ let combo = new ReaderCollectionPrioritized({
87
+ name: `generateStandaloneAppBundle - prioritize workspace over dependencies: ${projectName}`,
88
+ readers: [workspace, dependencies]
89
+ });
90
+
91
+ if (taskUtil) {
92
+ // Omit -dbg files
93
+ combo = combo.filter(function(resource) {
94
+ return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.IsDebugVariant);
95
+ });
96
+ }
97
+ const resources = await combo.byGlob("/resources/**/*.{js,json,xml,html,properties,library,js.map}");
86
98
 
87
99
  const isEvo = resources.find((resource) => {
88
100
  return resource.getPath() === "/resources/ui5loader.js";
@@ -94,6 +106,23 @@ module.exports = async function({workspace, dependencies, taskUtil, options: {pr
94
106
  filters = ["jquery.sap.global.js"];
95
107
  }
96
108
 
109
+ let unoptimizedModuleNameMapping;
110
+ let unoptimizedResources = resources;
111
+ if (taskUtil) {
112
+ unoptimizedResources = await new ReaderCollectionPrioritized({
113
+ name: `generateStandaloneAppBundle - prioritize workspace over dependencies: ${projectName}`,
114
+ readers: [workspace, dependencies]
115
+ }).filter(function(resource) {
116
+ // Remove any non-debug variants
117
+ return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.HasDebugVariant);
118
+ }).byGlob("/resources/**/*.{js,json,xml,html,properties,library,js.map}");
119
+
120
+ unoptimizedModuleNameMapping = createModuleNameMapping({
121
+ resources: unoptimizedResources,
122
+ taskUtil
123
+ });
124
+ }
125
+
97
126
  await Promise.all([
98
127
  moduleBundler({
99
128
  resources,
@@ -107,7 +136,7 @@ module.exports = async function({workspace, dependencies, taskUtil, options: {pr
107
136
  }
108
137
  }),
109
138
  moduleBundler({
110
- resources,
139
+ resources: unoptimizedResources,
111
140
  options: {
112
141
  bundleDefinition: getBundleDefinition({
113
142
  name: "sap-ui-custom-dbg.js",
@@ -116,16 +145,26 @@ module.exports = async function({workspace, dependencies, taskUtil, options: {pr
116
145
  }),
117
146
  bundleOptions: {
118
147
  optimize: false
119
- }
148
+ },
149
+ moduleNameMapping: unoptimizedModuleNameMapping
120
150
  }
121
151
  })
122
152
  ]).then((results) => {
123
153
  const bundles = Array.prototype.concat.apply([], results);
124
- return Promise.all(bundles.map((resource) => {
154
+ return Promise.all(bundles.map(({bundle, sourceMap}) => {
125
155
  if (taskUtil) {
126
- taskUtil.setTag(resource, taskUtil.STANDARD_TAGS.IsBundle);
156
+ taskUtil.setTag(bundle, taskUtil.STANDARD_TAGS.IsBundle);
157
+ if (sourceMap) {
158
+ // Clear tag that might have been set by the minify task, in cases where
159
+ // the bundle name is identical to a source file
160
+ taskUtil.clearTag(sourceMap, taskUtil.STANDARD_TAGS.OmitFromBuildResult);
161
+ }
162
+ }
163
+ const writes = [workspace.write(bundle)];
164
+ if (sourceMap) {
165
+ writes.push(workspace.write(sourceMap));
127
166
  }
128
- return workspace.write(resource);
167
+ return Promise.all(writes);
129
168
  }));
130
169
  });
131
170
  };
@@ -0,0 +1,31 @@
1
+ const ModuleName = require("../../../lbt/utils/ModuleName");
2
+
3
+ /**
4
+ * For "unoptimized" bundles, the non-debug files have already been filtered out above.
5
+ * Now we need to create a mapping from the debug-variant resource path to the respective module
6
+ * name, which is basically the non-debug resource path, minus the "/resources/"" prefix.
7
+ * This mapping overwrites internal logic of the LocatorResourcePool which would otherwise determine
8
+ * the module name from the resource path, which would contain "-dbg" in this case. That would be
9
+ * incorrect since debug-variants should still keep the original module name.
10
+ *
11
+ * @private
12
+ * @param {object} parameters Parameters
13
+ * @param {module:@ui5/fs.Resource[]} parameters.resources List of resources
14
+ * @param {module:@ui5/project.build.helpers.TaskUtil|object} parameters.taskUtil TaskUtil
15
+ * @returns {object} Module name mapping
16
+ */
17
+ module.exports = function({resources, taskUtil}) {
18
+ const moduleNameMapping = {};
19
+ for (let i = resources.length - 1; i >= 0; i--) {
20
+ const resource = resources[i];
21
+ if (taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.IsDebugVariant)) {
22
+ const resourcePath = resource.getPath();
23
+ const nonDbgPath = ModuleName.getNonDebugName(resourcePath);
24
+ if (!nonDbgPath) {
25
+ throw new Error(`Failed to resolve non-debug name for ${resourcePath}`);
26
+ }
27
+ moduleNameMapping[resourcePath] = nonDbgPath.slice("/resources/".length);
28
+ }
29
+ }
30
+ return moduleNameMapping;
31
+ };
@@ -28,6 +28,7 @@ function getSigner(type) {
28
28
  }
29
29
  }
30
30
 
31
+ /* eslint "jsdoc/check-param-names": ["error", {"disableExtraPropertyReporting":true}] */
31
32
  /**
32
33
  * Task to generate the application cachebuster info file.
33
34
  *
@@ -35,13 +36,16 @@ function getSigner(type) {
35
36
  * @alias module:@ui5/builder.tasks.generateCachebusterInfo
36
37
  * @param {object} parameters Parameters
37
38
  * @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
38
- * @param {module:@ui5/fs.AbstractReader} parameters.dependencies Reader or Collection to read dependency files
39
39
  * @param {object} parameters.options Options
40
- * @param {string} parameters.options.namespace Namespace of the application
40
+ * @param {string} parameters.options.projectNamespace Namespace of the application
41
41
  * @param {string} [parameters.options.signatureType='time'] Type of signature to be used ('time' or 'hash')
42
42
  * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
43
43
  */
44
- module.exports = function({workspace, dependencies, options: {namespace, signatureType}}) {
44
+ module.exports = function({workspace, options}) {
45
+ const {signatureType} = options;
46
+ // Backward compatibility: "namespace" option got renamed to "projectNamespace"
47
+ const namespace = options.projectNamespace || options.namespace;
48
+
45
49
  const basePath = `/resources/${namespace}/`;
46
50
  return workspace.byGlob(`/resources/${namespace}/**/*`)
47
51
  .then(async (resources) => {
@@ -2,7 +2,6 @@
2
2
 
3
3
  const log = require("@ui5/logger").getLogger("builder:tasks:generateLibraryManifest");
4
4
  const manifestCreator = require("../processors/manifestCreator");
5
- const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritized;
6
5
 
7
6
 
8
7
  /**
@@ -12,23 +11,19 @@ const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritiz
12
11
  * @alias module:@ui5/builder.tasks.generateLibraryManifest
13
12
  * @param {object} parameters Parameters
14
13
  * @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
15
- * @param {module:@ui5/fs.AbstractReader} parameters.dependencies Reader or Collection to read dependency files
14
+ * @param {module:@ui5/project.build.helpers.TaskUtil|object} [parameters.taskUtil] TaskUtil
16
15
  * @param {object} parameters.options Options
17
16
  * @param {string} parameters.options.projectName Project name
18
17
  * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
19
18
  */
20
- module.exports = function({workspace, dependencies, options: {projectName}}) {
21
- const combo = new ReaderCollectionPrioritized({
22
- name: `libraryManifestGenerator - prioritize workspace over dependencies: ${projectName}`,
23
- readers: [workspace, dependencies]
24
- });
19
+ module.exports = function({workspace, taskUtil, options: {projectName}}) {
25
20
  // Note:
26
21
  // *.library files are needed to identify libraries
27
22
  // *.json files are needed to avoid overwriting them
28
23
  // *.js files are needed to identify nested components
29
24
  // *.less, *.css, *.theming and *.theme files are needed to identify supported themes
30
25
  // *.properties to identify existence of i18n bundles (e.g. messagebundle.properties)
31
- return combo.byGlob("/**/*.{js,json,library,less,css,theming,theme,properties}").then((resources) => {
26
+ return workspace.byGlob("/resources/**/*.{js,json,library,less,css,theming,theme,properties}").then((resources) => {
32
27
  // Find all libraries and create a manifest.json file
33
28
  return workspace.byGlob("/resources/**/.library").then((libraryIndicatorResources) => {
34
29
  if (libraryIndicatorResources.length < 1) {
@@ -51,6 +46,9 @@ module.exports = function({workspace, dependencies, options: {projectName}}) {
51
46
  libraryResource: libraryIndicatorResource,
52
47
  namespace: libraryNamespace,
53
48
  resources,
49
+ getProjectVersion: (projectName) => {
50
+ return taskUtil?.getProject(projectName)?.getVersion();
51
+ },
54
52
  options: {
55
53
  }
56
54
  }).then((manifest) => {
@@ -43,7 +43,7 @@ function getCreatorOptions(projectName) {
43
43
  *
44
44
  * <p>
45
45
  * The detailed structure can be found in the documentation:
46
- * {@link https://openui5.hana.ondemand.com/#topic/adcbcf8b50924556ab3f321fcd9353ea}
46
+ * {@link https://sdk.openui5.org/topic/adcbcf8b50924556ab3f321fcd9353ea}
47
47
  * </p>
48
48
  *
49
49
  * <p>
@@ -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} [parameters.dependencies] Reader or Collection to read dependency files
99
+ * @param {module:@ui5/fs.AbstractReader} parameters.dependencies Reader or Collection to read dependency files
100
+ * @param {module:@ui5/project.build.helpers.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
- const resources = await workspace.byGlob(["/resources/**/*"].concat(DEFAULT_EXCLUDES));
105
+ module.exports = async function({workspace, dependencies, taskUtil, options: {projectName}}) {
106
+ let resources = await workspace.byGlob(["/resources/**/*"].concat(DEFAULT_EXCLUDES));
107
+ let dependencyResources =
108
+ await dependencies.byGlob("/resources/**/*.{js,json,xml,html,properties,library,js.map}");
106
109
 
107
- // TODO 3.0: Make dependencies parameter mandatory
108
- let dependencyResources;
109
- if (dependencies) {
110
- dependencyResources =
111
- await dependencies.byGlob("/resources/**/*.{js,json,xml,html,properties,library}");
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({