@ui5/builder 3.0.0-alpha.6 → 3.0.0-alpha.7

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 (42) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/index.js +0 -39
  3. package/lib/lbt/bundle/Builder.js +18 -48
  4. package/lib/lbt/resources/LocatorResource.js +1 -1
  5. package/lib/lbt/utils/escapePropertiesFile.js +3 -6
  6. package/lib/processors/bundlers/moduleBundler.js +2 -3
  7. package/lib/processors/jsdoc/lib/transformApiJson.js +13 -4
  8. package/lib/processors/manifestCreator.js +8 -45
  9. package/lib/tasks/TaskUtil.js +82 -17
  10. package/lib/tasks/bundlers/generateComponentPreload.js +14 -14
  11. package/lib/tasks/bundlers/generateFlexChangesBundle.js +6 -2
  12. package/lib/tasks/bundlers/generateLibraryPreload.js +84 -91
  13. package/lib/tasks/bundlers/generateManifestBundle.js +8 -10
  14. package/lib/tasks/bundlers/generateStandaloneAppBundle.js +7 -2
  15. package/lib/tasks/bundlers/utils/createModuleNameMapping.js +3 -2
  16. package/lib/tasks/generateCachebusterInfo.js +7 -3
  17. package/lib/tasks/generateLibraryManifest.js +5 -1
  18. package/lib/tasks/generateResourcesJson.js +1 -1
  19. package/lib/tasks/generateThemeDesignerResources.js +8 -2
  20. package/lib/tasks/generateVersionInfo.js +5 -5
  21. package/lib/tasks/taskRepository.js +1 -13
  22. package/lib/tasks/transformBootstrapHtml.js +6 -1
  23. package/package.json +4 -5
  24. package/lib/builder/BuildContext.js +0 -60
  25. package/lib/builder/ProjectBuildContext.js +0 -61
  26. package/lib/builder/builder.js +0 -425
  27. package/lib/types/AbstractBuilder.js +0 -270
  28. package/lib/types/AbstractFormatter.js +0 -66
  29. package/lib/types/AbstractUi5Formatter.js +0 -95
  30. package/lib/types/application/ApplicationBuilder.js +0 -211
  31. package/lib/types/application/ApplicationFormatter.js +0 -227
  32. package/lib/types/application/applicationType.js +0 -15
  33. package/lib/types/library/LibraryBuilder.js +0 -231
  34. package/lib/types/library/LibraryFormatter.js +0 -519
  35. package/lib/types/library/libraryType.js +0 -15
  36. package/lib/types/module/ModuleBuilder.js +0 -7
  37. package/lib/types/module/ModuleFormatter.js +0 -54
  38. package/lib/types/module/moduleType.js +0 -15
  39. package/lib/types/themeLibrary/ThemeLibraryBuilder.js +0 -64
  40. package/lib/types/themeLibrary/ThemeLibraryFormatter.js +0 -90
  41. package/lib/types/themeLibrary/themeLibraryType.js +0 -15
  42. package/lib/types/typeRepository.js +0 -46
package/CHANGELOG.md CHANGED
@@ -2,7 +2,27 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
4
4
 
5
- A list of unreleased changes can be found [here](https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.6...HEAD).
5
+ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.7...HEAD).
6
+
7
+ <a name="v3.0.0-alpha.7"></a>
8
+ ## [v3.0.0-alpha.7] - 2022-06-14
9
+ ### Breaking Changes
10
+ - Remove build execution ([#740](https://github.com/SAP/ui5-builder/issues/740)) [`af2e956`](https://github.com/SAP/ui5-builder/commit/af2e956f6cba1275669160328e32df3fffa782d0)
11
+
12
+ ### Bug Fixes
13
+ - Avoid redundant bundle creation ([#741](https://github.com/SAP/ui5-builder/issues/741)) [`13c8405`](https://github.com/SAP/ui5-builder/commit/13c840585946401d238936dfa38a6f70a73e9ed0)
14
+
15
+ ### Features
16
+ - Enable modern preload bundles without dependencies ([#739](https://github.com/SAP/ui5-builder/issues/739)) [`97cfa6c`](https://github.com/SAP/ui5-builder/commit/97cfa6cd3eadff57bcc18816534c7751551ebdb8)
17
+
18
+ ### BREAKING CHANGE
19
+
20
+ * builder.js has been removed. Use ui5-project builder instead
21
+ * Tasks now rely on Project instances being available on Resources (see https://github.com/SAP/ui5-fs/pull/381)
22
+ * TaskRepository#addTask has been removed. Custom tasks need to be added to the project graph instead
23
+ * TaskUtil#get/set/clearTag now requires a Project instance to be provided. Path strings are no longer sufficient
24
+ and will cause an exception to be thrown
25
+
6
26
 
7
27
  <a name="v3.0.0-alpha.6"></a>
8
28
  ## [v3.0.0-alpha.6] - 2022-04-26
@@ -721,6 +741,7 @@ to load the custom bundle file instead.
721
741
  - Add ability to configure component preloads and custom bundles [`2241e5f`](https://github.com/SAP/ui5-builder/commit/2241e5ff98fd95f1f80cc74959655ae7a9c660e7)
722
742
 
723
743
 
744
+ [v3.0.0-alpha.7]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.6...v3.0.0-alpha.7
724
745
  [v3.0.0-alpha.6]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.5...v3.0.0-alpha.6
725
746
  [v3.0.0-alpha.5]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.4...v3.0.0-alpha.5
726
747
  [v3.0.0-alpha.4]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.3...v3.0.0-alpha.4
package/index.js CHANGED
@@ -3,10 +3,6 @@
3
3
  * @public
4
4
  */
5
5
  module.exports = {
6
- /**
7
- * @type {import('./lib/builder/builder')}
8
- */
9
- builder: "./lib/builder/builder",
10
6
  /**
11
7
  * @public
12
8
  * @alias module:@ui5/builder.processors
@@ -160,41 +156,6 @@ module.exports = {
160
156
  * @type {import('./lib/tasks/TaskUtil')}
161
157
  */
162
158
  TaskUtil: "./lib/tasks/TaskUtil"
163
- },
164
- /**
165
- * @private
166
- * @alias module:@ui5/builder.types
167
- * @namespace
168
- */
169
- types: {
170
- /**
171
- * @type {typeof import('./lib/types/AbstractBuilder')}
172
- */
173
- AbstractBuilder: "./lib/types/AbstractBuilder",
174
- /**
175
- * @type {typeof import('./lib/types/AbstractFormatter')}
176
- */
177
- AbstractFormatter: "./lib/types/AbstractFormatter",
178
- /**
179
- * @type {import('./lib/types/application/applicationType')}
180
- */
181
- application: "./lib/types/application/applicationType",
182
- /**
183
- * @type {import('./lib/types/library/libraryType')}
184
- */
185
- library: "./lib/types/library/libraryType",
186
- /**
187
- * @type {import('./lib/types/themeLibrary/themeLibraryType')}
188
- */
189
- themeLibrary: "./lib/types/themeLibrary/themeLibraryType",
190
- /**
191
- * @type {import('./lib/types/module/moduleType')}
192
- */
193
- module: "./lib/types/module/moduleType",
194
- /**
195
- * @type {import('./lib/types/typeRepository')}
196
- */
197
- typeRepository: "./lib/types/typeRepository"
198
159
  }
199
160
  };
200
161
 
@@ -40,38 +40,6 @@ function isEmptyBundle(resolvedBundle) {
40
40
  return resolvedBundle.sections.every((section) => section.modules.length === 0);
41
41
  }
42
42
 
43
- const UI5BundleFormat = {
44
- beforePreloads(section) {
45
- let str = `jQuery.sap.registerPreloadedModules({\n`;
46
- if ( section.name ) {
47
- str += `"name":"${section.name}",\n`;
48
- }
49
- str += `"version":"2.0",\n`;
50
- str += `"modules":{\n`;
51
- return str;
52
- },
53
-
54
- afterPreloads(section) {
55
- return `}});\n`;
56
- },
57
-
58
- beforeBundleInfo() {
59
- return `"unsupported"; /* 'bundleInfo' section mode not supported (requires ui5loader)\n`;
60
- },
61
-
62
- afterBundleInfo() {
63
- return "*/\n";
64
- },
65
-
66
- requireSync(moduleName) {
67
- return `sap.ui.requireSync("${ModuleName.toRequireJSName(moduleName)}");\n`;
68
- },
69
-
70
- shouldDecorate(resolvedModule) {
71
- return resolvedModule.executes(UI5ClientConstants.MODULE__JQUERY_SAP_GLOBAL);
72
- }
73
- };
74
-
75
43
  const EVOBundleFormat = {
76
44
  beforePreloads(section) {
77
45
  return `sap.ui.require.preload({\n`;
@@ -115,7 +83,6 @@ class BundleBuilder {
115
83
  }
116
84
 
117
85
  async createBundle(module, options) {
118
- await this._prepare();
119
86
  if ( options.numberOfParts > 1 ) {
120
87
  const bundleInfos = [];
121
88
  const submodules = await this.splitter.run( module, options );
@@ -128,17 +95,6 @@ class BundleBuilder {
128
95
  }
129
96
  }
130
97
 
131
- _prepare() {
132
- return Promise.all([
133
- // check whether the resource pool contains debug and optimized sources
134
- this.pool.findResource( ModuleName.getDebugName(UI5ClientConstants.MODULE__JQUERY_SAP_GLOBAL) ).
135
- then( () => this.optimizedSources = true, () => this.optimizedSources = false ),
136
- // check whether EVO modules are available. If so, use EVO APIs, else use old UI5 APIs.
137
- this.pool.findResource(UI5ClientConstants.EVO_MARKER_RESOURCE).
138
- then( () => this.targetBundleFormat = EVOBundleFormat, () => this.targetBundleFormat = UI5BundleFormat )
139
- ]);
140
- }
141
-
142
98
  async _createBundle(module, options) {
143
99
  const resolvedModule = await this.resolver.resolve(module);
144
100
  if ( options.skipIfEmpty && isEmptyBundle(resolvedModule) ) {
@@ -153,11 +109,13 @@ class BundleBuilder {
153
109
  this.options.sourceMap = true;
154
110
  }
155
111
 
156
- // when decorateBootstrapModule is set to false, we don't write the optimized flag
157
- // and don't write the try catch wrapper
112
+ // Since UI5 Tooling 3.0: Always use modern API
113
+ this.targetBundleFormat = EVOBundleFormat;
114
+
115
+ // when decorateBootstrapModule is false,
116
+ // we don't write the optimized flag and don't write the try catch wrapper
158
117
  this.shouldDecorate = this.options.decorateBootstrapModule &&
159
- (((this.optimizedSources && !this.options.debugMode) || this.optimize) &&
160
- this.targetBundleFormat.shouldDecorate(resolvedModule));
118
+ this.targetBundleFormat.shouldDecorate(resolvedModule);
161
119
  // TODO is the following condition ok or should the availability of jquery.sap.global.js be configurable?
162
120
  this.jqglobalAvailable = !resolvedModule.containsGlobal;
163
121
  this.openModule(resolvedModule.name);
@@ -636,6 +594,18 @@ class BundleBuilder {
636
594
 
637
595
  if (moduleSourceMap) {
638
596
  moduleSourceMap = JSON.parse(moduleSourceMap);
597
+
598
+ // Check for index map, which is currently not supported
599
+ if (Array.isArray(moduleSourceMap.sections)) {
600
+ log.warn(
601
+ `Module ${moduleName} references an index source map which is currently not supported. ` +
602
+ `A transient source map will be created instead...`
603
+ );
604
+ moduleSourceMap = createTransientSourceMap({
605
+ moduleName: path.posix.basename(resourcePath),
606
+ moduleContent
607
+ });
608
+ }
639
609
  } else {
640
610
  log.verbose(`No source map available for module ${moduleName}. Creating transient source map...`);
641
611
  moduleSourceMap = createTransientSourceMap({
@@ -11,7 +11,7 @@ class LocatorResource extends Resource {
11
11
  }
12
12
 
13
13
  getProject() {
14
- return this.resource._project;
14
+ return this.resource.getProject();
15
15
  }
16
16
 
17
17
  getPath() {
@@ -4,7 +4,7 @@ const nonAsciiEscaper = require("../../processors/nonAsciiEscaper");
4
4
  * Can be used to escape *.properties files.
5
5
  *
6
6
  * Input encoding is read from project configuration.
7
- * In case the resource belongs to no project (e.g. bundler is used standalone) the default is "ISO-8859-1".
7
+ * In case the resource belongs to no project (e.g. bundler is used standalone) the default is "UTF-8".
8
8
  *
9
9
  * @private
10
10
  * @param {Resource} resource the resource for which the content will be escaped
@@ -12,13 +12,10 @@ const nonAsciiEscaper = require("../../processors/nonAsciiEscaper");
12
12
  */
13
13
  module.exports = async function(resource) {
14
14
  const project = resource.getProject();
15
- let propertiesFileSourceEncoding = project &&
16
- project.resources &&
17
- project.resources.configuration &&
18
- project.resources.configuration.propertiesFileSourceEncoding;
15
+ let propertiesFileSourceEncoding = project && project.getPropertiesFileSourceEncoding();
19
16
 
20
17
  if (!propertiesFileSourceEncoding) {
21
- if (project && ["0.1", "1.0", "1.1"].includes(project.specVersion)) {
18
+ if (project && ["0.1", "1.0", "1.1"].includes(project.getSpecVersion())) {
22
19
  // default encoding to "ISO-8859-1" for old specVersions
23
20
  propertiesFileSourceEncoding = "ISO-8859-1";
24
21
  } else {
@@ -91,9 +91,9 @@ const log = require("@ui5/logger").getLogger("builder:processors:bundlers:module
91
91
  * @typedef {object} ModuleBundleOptions
92
92
  * @property {boolean} [optimize=true] Whether the module bundle gets minified
93
93
  * @property {boolean} [sourceMap=true] Whether to generate a source map file for the bundle
94
- * @property {boolean} [decorateBootstrapModule=false] If set to 'false', the module won't be decorated
94
+ * @property {boolean} [decorateBootstrapModule=false] If set to 'false', bootable bundles won't be decorated
95
95
  * with an optimization marker
96
- * @property {boolean} [addTryCatchRestartWrapper=false] Whether to wrap bootable module bundles with
96
+ * @property {boolean} [addTryCatchRestartWrapper=false] Whether to wrap bootable bundles with
97
97
  * a try/catch to filter out "Restart" errors
98
98
  * @property {boolean} [usePredefineCalls=false] If set to 'true', sap.ui.predefine is used for UI5 modules
99
99
  * @property {number} [numberOfParts=1] The number of parts the module bundle should be splitted
@@ -148,7 +148,6 @@ module.exports = function({resources, options: {bundleDefinition, bundleOptions,
148
148
  log.verbose(`bundleDefinition: ${JSON.stringify(bundleDefinition, null, 2)}`);
149
149
  log.verbose(`bundleOptions: ${JSON.stringify(bundleOptions, null, 2)}`);
150
150
  }
151
-
152
151
  return pool.prepare( resources, moduleNameMapping ).
153
152
  then( () => builder.createBundle(bundleDefinition, bundleOptions) ).
154
153
  then( (results) => {
@@ -1386,13 +1386,16 @@ function transformer(sInputFile, sOutputFile, sLibraryFile, vDependencyAPIFiles,
1386
1386
 
1387
1387
  },
1388
1388
 
1389
+ formatUrlToLink: function(sTarget, sText, bSAPHosted){
1390
+ return `<a target="_blank" rel="noopener noreferrer" href="${sTarget}">${sText}</a>
1391
+ <img src="./resources/sap/ui/documentation/sdk/images/${bSAPHosted ? 'link-sap' : 'link-external'}.png"
1392
+ title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapUISDKExternalLink"/>`;
1393
+ },
1394
+
1389
1395
  handleExternalUrl: function (sTarget, sText) {
1390
1396
  // Check if the external domain is SAP hosted
1391
1397
  let bSAPHosted = /^https?:\/\/([\w.]*\.)?(?:sap|hana\.ondemand|sapfioritrial)\.com/.test(sTarget);
1392
-
1393
- return `<a target="_blank" rel="noopener noreferrer" href="${sTarget}">${sText}</a>
1394
- <img src="./resources/sap/ui/documentation/sdk/images/${bSAPHosted ? 'link-sap' : 'link-external'}.png"
1395
- title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapUISDKExternalLink"/>`;
1398
+ return this.formatUrlToLink(sTarget, sText, bSAPHosted);
1396
1399
  },
1397
1400
 
1398
1401
  /**
@@ -1599,6 +1602,12 @@ title="Information published on ${bSAPHosted ? '' : 'non '}SAP site" class="sapU
1599
1602
  return '<a target="_self" href="topic/' + aMatch[1] + '">' + sText + '</a>';
1600
1603
  }
1601
1604
 
1605
+ // demo:xxx Demo, open the demonstration page in a new window
1606
+ aMatch = sTarget.match(/^demo:([a-zA-Z0-9\/.]*)$/);
1607
+ if (aMatch) {
1608
+ return this.formatUrlToLink("test-resources/" + aMatch[1], sText, true);
1609
+ }
1610
+
1602
1611
  // sap.x.Xxx.prototype.xxx - In case of prototype we have a link to method
1603
1612
  aMatch = sTarget.match(/([a-zA-Z0-9.$_]+?)\.prototype\.([a-zA-Z0-9.$_]+)$/);
1604
1613
  if (aMatch) {
@@ -157,7 +157,9 @@ class LibraryBundle {
157
157
  /*
158
158
  * Creates the library manifest.json file for a UILibrary.
159
159
  */
160
- async function createManifest(libraryResource, libBundle, descriptorVersion, _include3rdParty, omitMinVersions) {
160
+ async function createManifest(
161
+ libraryResource, libBundle, descriptorVersion, _include3rdParty, omitMinVersions, getProjectVersion
162
+ ) {
161
163
  // create a Library wrapper around the .library XML
162
164
  const library = await Library.from(libraryResource);
163
165
 
@@ -223,13 +225,6 @@ async function createManifest(libraryResource, libBundle, descriptorVersion, _in
223
225
  return version && version !== "@version@" && version !== "${version}";
224
226
  }
225
227
 
226
- function getProjectVersion() {
227
- const project = libraryResource._project;
228
- if ( project ) {
229
- return project.version;
230
- }
231
- }
232
-
233
228
  function getLibraryTitle() {
234
229
  if ( library.getTitle() ) {
235
230
  return library.getTitle();
@@ -321,7 +316,7 @@ async function createManifest(libraryResource, libBundle, descriptorVersion, _in
321
316
  embeds: findEmbeddedComponents(),
322
317
  i18n,
323
318
  applicationVersion: {
324
- version: isValid(library.getVersion()) ? library.getVersion() : getProjectVersion()
319
+ version: isValid(library.getVersion()) ? library.getVersion() : getProjectVersion(library.getName())
325
320
  },
326
321
  title: getLibraryTitle(),
327
322
  description: library.getDocumentation(),
@@ -393,12 +388,7 @@ async function createManifest(libraryResource, libBundle, descriptorVersion, _in
393
388
 
394
389
  function createSapUI5() {
395
390
  function getUI5Version() {
396
- const dummy = new Dependency({
397
- libraryName: [{
398
- _: "sap.ui.core"
399
- }]
400
- });
401
- return normalizeVersion(getVersion(dummy));
391
+ return normalizeVersion(getProjectVersion("sap.ui.core"));
402
392
  }
403
393
 
404
394
  function dependencies() {
@@ -410,7 +400,7 @@ async function createManifest(libraryResource, libBundle, descriptorVersion, _in
410
400
  if ( library.getDependencies() != null ) {
411
401
  for (const dep of library.getDependencies()) {
412
402
  dependencies.libs[dep.getLibraryName()] = {
413
- minVersion: omitMinVersions ? "" : getVersion(dep),
403
+ minVersion: omitMinVersions ? "" : getProjectVersion(dep.getLibraryName()),
414
404
  lazy: dep.isLazy() || undefined // suppress default (false)
415
405
  };
416
406
  }
@@ -619,33 +609,6 @@ async function createManifest(libraryResource, libBundle, descriptorVersion, _in
619
609
  return v.major + "." + v.minor;
620
610
  }
621
611
 
622
- function getVersion(dependency) {
623
- const version = dependency.getVersion();
624
- if ( version != null ) {
625
- return version;
626
- }
627
-
628
- function hasName(entity) {
629
- return entity.metadata && entity.metadata.name === dependency.getLibraryName();
630
- }
631
-
632
- const project = libraryResource._project;
633
- if ( project ) {
634
- if ( Array.isArray(project.dependencies) ) {
635
- const lib = project.dependencies.find(hasName);
636
- if ( lib ) {
637
- return lib.version;
638
- }
639
- }
640
- if ( hasName(project) ) {
641
- return project.version;
642
- }
643
- }
644
-
645
- throw new Error(
646
- `Couldn't find version for library '${dependency.getLibraryName()}', project dependency missing?`);
647
- }
648
-
649
612
  return {
650
613
  "_version": descriptorVersion.toString(),
651
614
  "sap.app": createSapApp(),
@@ -657,7 +620,7 @@ async function createManifest(libraryResource, libBundle, descriptorVersion, _in
657
620
  };
658
621
  }
659
622
 
660
- module.exports = function({libraryResource, resources, options}) {
623
+ module.exports = function({libraryResource, resources, getProjectVersion, options}) {
661
624
  // merge options with defaults
662
625
  options = Object.assign({
663
626
  descriptorVersion: APP_DESCRIPTOR_V22, // TODO 3.0: change this to type string instead of a semver object
@@ -677,7 +640,7 @@ module.exports = function({libraryResource, resources, options}) {
677
640
  }
678
641
 
679
642
  return createManifest(libraryResource, libBundle, options.descriptorVersion, options.include3rdParty,
680
- options.omitMinVersions)
643
+ options.omitMinVersions, getProjectVersion)
681
644
  .then((manifest) => {
682
645
  return new EvoResource({
683
646
  path: resourcePathPrefix + "manifest.json",
@@ -19,9 +19,15 @@ class TaskUtil {
19
19
  * @public
20
20
  * @typedef {object} module:@ui5/builder.tasks.TaskUtil~StandardBuildTags
21
21
  * @property {string} OmitFromBuildResult
22
- * Setting this tag to true for a resource will prevent it from being written to the build target
22
+ * Setting this tag to true will prevent the resource from being written to the build target directory
23
23
  * @property {string} IsBundle
24
24
  * This tag identifies resources that contain (i.e. bundle) multiple other resources
25
+ * @property {string} IsDebugVariant
26
+ * This tag identifies resources that are a debug variant (typically named with a "-dbg" suffix)
27
+ * of another resource. This tag is part of the build manifest.
28
+ * @property {string} HasDebugVariant
29
+ * This tag identifies resources for which a debug variant has been created.
30
+ * This tag is part of the build manifest.
25
31
  */
26
32
 
27
33
  /**
@@ -34,12 +40,22 @@ class TaskUtil {
34
40
  */
35
41
  constructor({projectBuildContext}) {
36
42
  this._projectBuildContext = projectBuildContext;
37
-
38
43
  /**
39
44
  * @member {module:@ui5/builder.tasks.TaskUtil~StandardBuildTags}
40
45
  * @public
41
46
  */
42
- this.STANDARD_TAGS = this._projectBuildContext.STANDARD_TAGS;
47
+ this.STANDARD_TAGS = Object.freeze({
48
+ // "Project" tags:
49
+ // Will be stored on project instance and are hence part of the build manifest
50
+ IsDebugVariant: "ui5:IsDebugVariant",
51
+ HasDebugVariant: "ui5:HasDebugVariant",
52
+
53
+ // "Build" tags:
54
+ // Will be stored on the project build context
55
+ // They are only available to the build tasks of a single project
56
+ OmitFromBuildResult: "ui5:OmitFromBuildResult",
57
+ IsBundle: "ui5:IsBundle"
58
+ });
43
59
  }
44
60
 
45
61
  /**
@@ -51,14 +67,20 @@ class TaskUtil {
51
67
  * This method is only available to custom task extensions defining
52
68
  * <b>Specification Version 2.2 and above</b>.
53
69
  *
54
- * @param {string|module:@ui5/fs.Resource} resourcePath Path or resource-instance the tag should be stored for
70
+ * @param {module:@ui5/fs.Resource} resource Resource-instance the tag should be stored for
55
71
  * @param {string} tag Name of the tag.
56
72
  * Currently only the [STANDARD_TAGS]{@link module:@ui5/builder.tasks.TaskUtil#STANDARD_TAGS} are allowed
57
73
  * @param {string|boolean|integer} [value=true] Tag value. Must be primitive
58
74
  * @public
59
75
  */
60
- setTag(resourcePath, tag, value) {
61
- return this._projectBuildContext.getResourceTagCollection().setTag(resourcePath, tag, value);
76
+ setTag(resource, tag, value) {
77
+ if (typeof resource === "string") {
78
+ throw new Error("Deprecated parameter: " +
79
+ "Since UI5 Tooling 3.0, #setTag requires a resource instance. Strings are no longer accepted");
80
+ }
81
+
82
+ const collection = this._projectBuildContext.getResourceTagCollection(resource, tag);
83
+ return collection.setTag(resource, tag, value);
62
84
  }
63
85
 
64
86
  /**
@@ -68,14 +90,19 @@ class TaskUtil {
68
90
  * This method is only available to custom task extensions defining
69
91
  * <b>Specification Version 2.2 and above</b>.
70
92
  *
71
- * @param {string|module:@ui5/fs.Resource} resourcePath Path or resource-instance the tag should be retrieved for
93
+ * @param {module:@ui5/fs.Resource} resource Resource-instance the tag should be retrieved for
72
94
  * @param {string} tag Name of the tag
73
95
  * @returns {string|boolean|integer|undefined} Tag value for the given resource.
74
96
  * <code>undefined</code> if no value is available
75
97
  * @public
76
98
  */
77
- getTag(resourcePath, tag) {
78
- return this._projectBuildContext.getResourceTagCollection().getTag(resourcePath, tag);
99
+ getTag(resource, tag) {
100
+ if (typeof resource === "string") {
101
+ throw new Error("Deprecated parameter: " +
102
+ "Since UI5 Tooling 3.0, #getTag requires a resource instance. Strings are no longer accepted");
103
+ }
104
+ const collection = this._projectBuildContext.getResourceTagCollection(resource, tag);
105
+ return collection.getTag(resource, tag);
79
106
  }
80
107
 
81
108
  /**
@@ -86,12 +113,17 @@ class TaskUtil {
86
113
  * This method is only available to custom task extensions defining
87
114
  * <b>Specification Version 2.2 and above</b>.
88
115
  *
89
- * @param {string|module:@ui5/fs.Resource} resourcePath Path or resource-instance the tag should be cleared for
116
+ * @param {module:@ui5/fs.Resource} resource Resource-instance the tag should be cleared for
90
117
  * @param {string} tag Tag
91
118
  * @public
92
119
  */
93
- clearTag(resourcePath, tag) {
94
- return this._projectBuildContext.getResourceTagCollection().clearTag(resourcePath, tag);
120
+ clearTag(resource, tag) {
121
+ if (typeof resource === "string") {
122
+ throw new Error("Deprecated parameter: " +
123
+ "Since UI5 Tooling 3.0, #clearTag requires a resource instance. Strings are no longer accepted");
124
+ }
125
+ const collection = this._projectBuildContext.getResourceTagCollection(resource, tag);
126
+ return collection.clearTag(resource, tag);
95
127
  }
96
128
 
97
129
  /**
@@ -136,6 +168,22 @@ class TaskUtil {
136
168
  return this._projectBuildContext.registerCleanupTask(callback);
137
169
  }
138
170
 
171
+ /**
172
+ * Retrieve a single project from the dependency graph
173
+ *
174
+ * </br></br>
175
+ * This method is only available to custom task extensions defining
176
+ * <b>Specification Version 2.7 and above</b>.
177
+ *
178
+ * @param {string} projectName Name of the project to retrieve
179
+ * @returns {module:@ui5/project.specifications.Project|undefined}
180
+ * project instance or undefined if the project is unknown to the graph
181
+ * @public
182
+ */
183
+ getProject(projectName) {
184
+ return this._projectBuildContext.getProject(projectName);
185
+ }
186
+
139
187
  /**
140
188
  * Get an interface to an instance of this class that only provides those functions
141
189
  * that are supported by the given custom task extension specification version.
@@ -150,12 +198,10 @@ class TaskUtil {
150
198
 
151
199
  const baseInterface = {
152
200
  STANDARD_TAGS: this.STANDARD_TAGS,
153
- setTag: this.setTag.bind(this),
154
- clearTag: this.clearTag.bind(this),
155
- getTag: this.getTag.bind(this),
156
- isRootProject: this.isRootProject.bind(this),
157
- registerCleanupTask: this.registerCleanupTask.bind(this)
158
201
  };
202
+ bindFunctions(this, baseInterface, [
203
+ "setTag", "clearTag", "getTag", "isRootProject", "registerCleanupTask"
204
+ ]);
159
205
  switch (specVersion) {
160
206
  case "2.2":
161
207
  case "2.3":
@@ -163,10 +209,29 @@ class TaskUtil {
163
209
  case "2.5":
164
210
  case "2.6":
165
211
  return baseInterface;
212
+ case "2.7":
213
+ baseInterface.getProject = (projectName) => {
214
+ const project = this.getProject(projectName);
215
+ const baseProjectInterface = {};
216
+ bindFunctions(project, baseProjectInterface, [
217
+ "getName", "getVersion", "getNamespace"
218
+ ]);
219
+ switch (specVersion) {
220
+ case "2.7":
221
+ return baseProjectInterface;
222
+ }
223
+ };
224
+ return baseInterface;
166
225
  default:
167
226
  throw new Error(`TaskUtil: Unknown or unsupported Specification Version ${specVersion}`);
168
227
  }
169
228
  }
170
229
  }
171
230
 
231
+ function bindFunctions(sourceObject, targetObject, funcNames) {
232
+ funcNames.forEach((funcName) => {
233
+ targetObject[funcName] = sourceObject[funcName].bind(sourceObject);
234
+ });
235
+ }
236
+
172
237
  module.exports = TaskUtil;
@@ -1,7 +1,6 @@
1
1
  const path = require("path");
2
2
  const moduleBundler = require("../../processors/bundlers/moduleBundler");
3
3
  const log = require("@ui5/logger").getLogger("builder:tasks:bundlers:generateComponentPreload");
4
- const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritized;
5
4
  const {negateFilters} = require("../../lbt/resources/ResourceFilterList");
6
5
 
7
6
  /**
@@ -11,7 +10,6 @@ const {negateFilters} = require("../../lbt/resources/ResourceFilterList");
11
10
  * @alias module:@ui5/builder.tasks.generateComponentPreload
12
11
  * @param {object} parameters Parameters
13
12
  * @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
14
- * @param {module:@ui5/fs.AbstractReader} parameters.dependencies Reader or Collection to read dependency files
15
13
  * @param {module:@ui5/builder.tasks.TaskUtil|object} [parameters.taskUtil] TaskUtil
16
14
  * @param {object} parameters.options Options
17
15
  * @param {string} parameters.options.projectName Project name
@@ -23,32 +21,28 @@ const {negateFilters} = require("../../lbt/resources/ResourceFilterList");
23
21
  * inclusion overrides an earlier exclusion, and vice versa.
24
22
  * @param {string[]} [parameters.options.paths] Array of paths (or glob patterns) for component files
25
23
  * @param {string[]} [parameters.options.namespaces] Array of component namespaces
24
+ * @param {string[]} [parameters.options.skipBundles] Names of bundles that should not be created
26
25
  * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
27
26
  */
28
27
  module.exports = function({
29
- workspace, dependencies, taskUtil, options: {projectName, paths, namespaces, excludes = []}
28
+ workspace, taskUtil, options: {projectName, paths, namespaces, skipBundles = [], excludes = []}
30
29
  }) {
31
- let combo = new ReaderCollectionPrioritized({
32
- name: `generateComponentPreload - prioritize workspace over dependencies: ${projectName}`,
33
- readers: [workspace, dependencies]
34
- });
35
-
30
+ let nonDbgWorkspace = workspace;
36
31
  if (taskUtil) {
37
- combo = combo.filter(function(resource) {
32
+ nonDbgWorkspace = workspace.filter(function(resource) {
38
33
  // Remove any debug variants
39
34
  return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.IsDebugVariant);
40
35
  });
41
36
  }
42
37
 
43
- // TODO 3.0: Limit to workspace resources?
44
- return combo.byGlob("/resources/**/*.{js,json,xml,html,properties,library,js.map}")
38
+ return nonDbgWorkspace.byGlob("/resources/**/*.{js,json,xml,html,properties,library,js.map}")
45
39
  .then(async (resources) => {
46
40
  let allNamespaces = [];
47
41
  if (paths) {
48
42
  allNamespaces = await Promise.all(paths.map(async (componentPath) => {
49
43
  const globPath = "/resources/" + componentPath;
50
44
  log.verbose(`Globbing for Components directories with configured path ${globPath}...`);
51
- const components = await combo.byGlob(globPath); // TODO 3.0: Limit to workspace resources?
45
+ const components = await nonDbgWorkspace.byGlob(globPath);
52
46
  return components.map((component) => {
53
47
  const compDir = path.dirname(component.getPath()).replace(/^\/resources\//i, "");
54
48
  log.verbose(`Found component namespace ${compDir}`);
@@ -72,6 +66,12 @@ module.exports = function({
72
66
  const unusedFilterExcludes = new Set(allFilterExcludes);
73
67
 
74
68
  const bundleDefinitions = allNamespaces.map((namespace) => {
69
+ const bundleName = `${namespace}/Component-preload.js`;
70
+ if (skipBundles.includes(bundleName)) {
71
+ log.verbose(`Skipping generation of bundle ${bundleName}`);
72
+ return null;
73
+ }
74
+
75
75
  const filters = [
76
76
  `${namespace}/`,
77
77
  `${namespace}/**/manifest.json`,
@@ -101,7 +101,7 @@ module.exports = function({
101
101
  });
102
102
 
103
103
  return {
104
- name: `${namespace}/Component-preload.js`,
104
+ name: bundleName,
105
105
  defaultFileTypes: [
106
106
  ".js",
107
107
  ".control.xml",
@@ -134,7 +134,7 @@ module.exports = function({
134
134
  });
135
135
  }
136
136
 
137
- return Promise.all(bundleDefinitions.map((bundleDefinition) => {
137
+ return Promise.all(bundleDefinitions.filter(Boolean).map((bundleDefinition) => {
138
138
  log.verbose(`Generating ${bundleDefinition.name}...`);
139
139
  return moduleBundler({
140
140
  resources,