@ui5/builder 3.0.0-alpha.9 → 3.0.0-beta.2

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 (83) hide show
  1. package/.reuse/dep5 +2 -2
  2. package/CHANGELOG.md +59 -1
  3. package/CONTRIBUTING.md +1 -1
  4. package/README.md +4 -4
  5. package/jsdoc.json +2 -2
  6. package/lib/lbt/UI5ClientConstants.js +7 -8
  7. package/lib/lbt/analyzer/ComponentAnalyzer.js +60 -22
  8. package/lib/lbt/analyzer/FioriElementsAnalyzer.js +31 -20
  9. package/lib/lbt/analyzer/JSModuleAnalyzer.js +119 -77
  10. package/lib/lbt/analyzer/SmartTemplateAnalyzer.js +31 -20
  11. package/lib/lbt/analyzer/XMLCompositeAnalyzer.js +35 -25
  12. package/lib/lbt/analyzer/XMLTemplateAnalyzer.js +71 -18
  13. package/lib/lbt/analyzer/analyzeLibraryJS.js +22 -6
  14. package/lib/lbt/bundle/AutoSplitter.js +10 -11
  15. package/lib/lbt/bundle/Builder.js +33 -36
  16. package/lib/lbt/bundle/BundleDefinition.js +1 -5
  17. package/lib/lbt/bundle/BundleWriter.js +1 -2
  18. package/lib/lbt/bundle/ResolvedBundleDefinition.js +6 -7
  19. package/lib/lbt/bundle/Resolver.js +11 -12
  20. package/lib/lbt/calls/SapUiDefine.js +16 -11
  21. package/lib/lbt/graph/dependencyGraph.js +3 -4
  22. package/lib/lbt/graph/dominatorTree.js +3 -3
  23. package/lib/lbt/graph/topologicalSort.js +3 -3
  24. package/lib/lbt/resources/LibraryFileAnalyzer.js +6 -9
  25. package/lib/lbt/resources/LocatorResource.js +2 -2
  26. package/lib/lbt/resources/LocatorResourcePool.js +3 -3
  27. package/lib/lbt/resources/ModuleInfo.js +2 -3
  28. package/lib/lbt/resources/Resource.js +3 -4
  29. package/lib/lbt/resources/ResourceCollector.js +8 -9
  30. package/lib/lbt/resources/ResourceFilterList.js +38 -40
  31. package/lib/lbt/resources/ResourceInfo.js +1 -1
  32. package/lib/lbt/resources/ResourceInfoList.js +5 -3
  33. package/lib/lbt/resources/ResourcePool.js +15 -21
  34. package/lib/lbt/utils/ASTUtils.js +60 -44
  35. package/lib/lbt/utils/JSTokenizer.js +4 -4
  36. package/lib/lbt/utils/ModuleName.js +10 -20
  37. package/lib/lbt/utils/escapePropertiesFile.js +4 -4
  38. package/lib/lbt/utils/parseUtils.js +5 -11
  39. package/lib/processors/bootstrapHtmlTransformer.js +15 -7
  40. package/lib/processors/bundlers/flexChangesBundler.js +16 -8
  41. package/lib/processors/bundlers/moduleBundler.js +26 -15
  42. package/lib/processors/jsdoc/apiIndexGenerator.js +16 -9
  43. package/lib/processors/jsdoc/jsdocGenerator.js +37 -25
  44. package/lib/processors/jsdoc/lib/{createIndexFiles.js → createIndexFiles.cjs} +0 -0
  45. package/lib/processors/jsdoc/lib/{transformApiJson.js → transformApiJson.cjs} +59 -2
  46. package/lib/processors/jsdoc/lib/ui5/{plugin.js → plugin.cjs} +310 -119
  47. package/lib/processors/jsdoc/lib/ui5/template/{publish.js → publish.cjs} +6 -2
  48. package/lib/processors/jsdoc/lib/ui5/template/utils/{versionUtil.js → versionUtil.cjs} +0 -0
  49. package/lib/processors/jsdoc/sdkTransformer.js +18 -11
  50. package/lib/processors/libraryLessGenerator.js +28 -16
  51. package/lib/processors/manifestCreator.js +15 -14
  52. package/lib/processors/minifier.js +22 -16
  53. package/lib/processors/nonAsciiEscaper.js +17 -7
  54. package/lib/processors/resourceListCreator.js +13 -13
  55. package/lib/processors/stringReplacer.js +13 -6
  56. package/lib/processors/themeBuilder.js +33 -24
  57. package/lib/processors/versionInfoGenerator.js +40 -30
  58. package/lib/tasks/buildThemes.js +18 -11
  59. package/lib/tasks/bundlers/generateBundle.js +23 -12
  60. package/lib/tasks/bundlers/generateComponentPreload.js +23 -12
  61. package/lib/tasks/bundlers/generateFlexChangesBundle.js +16 -8
  62. package/lib/tasks/bundlers/generateLibraryPreload.js +33 -17
  63. package/lib/tasks/bundlers/generateStandaloneAppBundle.js +21 -13
  64. package/lib/tasks/bundlers/utils/createModuleNameMapping.js +7 -7
  65. package/lib/tasks/escapeNonAsciiCharacters.js +12 -5
  66. package/lib/tasks/generateCachebusterInfo.js +17 -9
  67. package/lib/tasks/generateLibraryManifest.js +14 -8
  68. package/lib/tasks/generateResourcesJson.js +15 -9
  69. package/lib/tasks/generateThemeDesignerResources.js +19 -9
  70. package/lib/tasks/generateVersionInfo.js +12 -5
  71. package/lib/tasks/jsdoc/executeJsdocSdkTransformation.js +17 -9
  72. package/lib/tasks/jsdoc/generateApiIndex.js +16 -10
  73. package/lib/tasks/jsdoc/generateJsdoc.js +131 -119
  74. package/lib/tasks/minify.js +13 -6
  75. package/lib/tasks/replaceBuildtime.js +12 -5
  76. package/lib/tasks/replaceCopyright.js +12 -5
  77. package/lib/tasks/replaceVersion.js +12 -5
  78. package/lib/tasks/taskRepository.js +24 -30
  79. package/lib/tasks/transformBootstrapHtml.js +6 -5
  80. package/package.json +44 -31
  81. package/index.js +0 -173
  82. package/lib/processors/bundlers/manifestBundler.js +0 -172
  83. package/lib/tasks/bundlers/generateManifestBundle.js +0 -49
@@ -1,6 +1,12 @@
1
- const log = require("@ui5/logger").getLogger("builder:processors:versionInfoGenerator");
2
- const resourceFactory = require("@ui5/fs").resourceFactory;
3
- const posixPath = require("path").posix;
1
+ import logger from "@ui5/logger";
2
+ const log = logger.getLogger("builder:processors:versionInfoGenerator");
3
+ import {createResource} from "@ui5/fs/resourceFactory";
4
+ import posixPath from "node:path/posix";
5
+
6
+ /**
7
+ * @public
8
+ * @module @ui5/builder/processors/versionInfoGenerator
9
+ */
4
10
 
5
11
  function pad(v) {
6
12
  return String(v).padStart(2, "0");
@@ -19,7 +25,7 @@ function getTimestamp() {
19
25
  /**
20
26
  * Manifest libraries as defined in the manifest.json file
21
27
  *
22
- * @typedef {object<string, {lazy: boolean}>} ManifestLibraries
28
+ * @typedef {Object<string, {lazy: boolean}>} ManifestLibraries
23
29
  *
24
30
  * sample:
25
31
  * <pre>
@@ -40,28 +46,29 @@ function getTimestamp() {
40
46
  * @property {string} id The library name, e.g. "lib.x"
41
47
  * @property {string} embeddedBy the library this component is embedded in, e.g. "lib.x"
42
48
  * @property {string[]} embeds the embedded component names, e.g. ["lib.x.sub"]
43
- * @property {ManifestLibraries} libs the dependencies, e.g. {"sap.chart":{"lazy": true}, "sap.f":{}}
49
+ * @property {module:@ui5/builder/processors/versionInfoGenerator~ManifestLibraries} libs the dependencies, e.g.
50
+ * {"sap.chart":{"lazy": true}, "sap.f":{}}
44
51
  */
45
52
 
46
53
 
47
54
  /**
48
55
  * Processes manifest resource and extracts information.
49
56
  *
50
- * @param {module:@ui5/fs.Resource} manifestResource
51
- * @returns {Promise<ManifestInfo>}
57
+ * @param {@ui5/fs/Resource} manifestResource
58
+ * @returns {Promise<module:@ui5/builder/processors/versionInfoGenerator~ManifestInfo>}
52
59
  */
53
60
  const processManifest = async (manifestResource) => {
54
61
  const manifestContent = await manifestResource.getString();
55
62
  const manifestObject = JSON.parse(manifestContent);
56
- const manifestInfo = {};
63
+ const manifestInfo = Object.create(null);
57
64
 
58
65
  // sap.ui5/dependencies is used for the "manifestHints/libs"
59
66
  if (manifestObject["sap.ui5"]) {
60
67
  const manifestDependencies = manifestObject["sap.ui5"]["dependencies"];
61
68
  if (manifestDependencies && manifestDependencies.libs) {
62
- const libs = {};
69
+ const libs = Object.create(null);
63
70
  for (const [libKey, libValue] of Object.entries(manifestDependencies.libs)) {
64
- libs[libKey] = {};
71
+ libs[libKey] = Object.create(null);
65
72
  if (libValue.lazy) {
66
73
  libs[libKey].lazy = true;
67
74
  }
@@ -145,7 +152,7 @@ const getManifestPath = (filePath, subPath) => {
145
152
  class DependencyInfo {
146
153
  /**
147
154
  *
148
- * @param {ManifestLibraries} libs
155
+ * @param {module:@ui5/builder/processors/versionInfoGenerator~ManifestLibraries} libs
149
156
  * @param {string} name library name, e.g. "lib.x"
150
157
  */
151
158
  constructor(libs, name) {
@@ -182,7 +189,7 @@ class DependencyInfo {
182
189
  * - resolved children become lazy if their parent is lazy
183
190
  *
184
191
  * @param {Map<string,DependencyInfo>} dependencyInfoMap
185
- * @returns {ManifestLibraries} resolved libraries
192
+ * @returns {module:@ui5/builder/processors/versionInfoGenerator~ManifestLibraries} resolved libraries
186
193
  */
187
194
  getResolvedLibraries(dependencyInfoMap) {
188
195
  if (!this._libsResolved) {
@@ -223,7 +230,7 @@ class DependencyInfo {
223
230
  * @returns {object} the object with sorted keys
224
231
  */
225
232
  const sortObjectKeys = (obj) => {
226
- const sortedObject = {};
233
+ const sortedObject = Object.create(null);
227
234
  const keys = Object.keys(obj);
228
235
  keys.sort();
229
236
  keys.forEach((key) => {
@@ -260,14 +267,14 @@ const getManifestHints = (dependencyInfo, dependencyInfoMap) => {
260
267
  * @property {string} componentName The library name, e.g. "lib.x"
261
268
  * @property {Set<string>} bundledComponents The embedded components which have an embeddedBy reference to the library
262
269
  * @property {DependencyInfo} dependencyInfo The dependency info object
263
- * @property {ArtifactInfo[]} embeds The embedded artifact infos
270
+ * @property {module:@ui5/builder/processors/versionInfoGenerator~ArtifactInfo[]} embeds The embedded artifact infos
264
271
  */
265
272
 
266
273
 
267
274
  /**
268
275
  * Processes the manifest and creates a ManifestInfo and an ArtifactInfo.
269
276
  *
270
- * @param {module:@ui5/fs.Resource} libraryManifest
277
+ * @param {@ui5/fs/Resource} libraryManifest
271
278
  * @param {string} [name] library name, if not provided using the ManifestInfo's id
272
279
  * @returns {Promise<{manifestInfo: ManifestInfo, libraryArtifactInfo: ArtifactInfo}>}
273
280
  */
@@ -283,8 +290,8 @@ async function processManifestAndGetArtifactInfo(libraryManifest, name) {
283
290
  /**
284
291
  * Processes the library info and fills the maps <code>dependencyInfoMap</code> and <code>embeddedInfoMap</code>.
285
292
  *
286
- * @param {LibraryInfo} libraryInfo
287
- * @returns {Promise<ArtifactInfo|undefined>}
293
+ * @param {module:@ui5/builder/processors/versionInfoGenerator~LibraryInfo} libraryInfo
294
+ * @returns {Promise<module:@ui5/builder/processors/versionInfoGenerator~ArtifactInfo|undefined>}
288
295
  */
289
296
  const processLibraryInfo = async (libraryInfo) => {
290
297
  if (!libraryInfo.libraryManifest) {
@@ -338,38 +345,41 @@ const processLibraryInfo = async (libraryInfo) => {
338
345
  *
339
346
  * contains information about the name and the version of the library and its manifest, as well as the nested manifests.
340
347
  *
348
+ * @public
341
349
  * @typedef {object} LibraryInfo
342
350
  * @property {string} name The library name, e.g. "lib.x"
343
351
  * @property {string} version The library version, e.g. "1.0.0"
344
- * @property {module:@ui5/fs.Resource} libraryManifest library manifest resource,
352
+ * @property {@ui5/fs/Resource} libraryManifest library manifest resource,
345
353
  * e.g. resource with path "lib/x/manifest.json"
346
- * @property {module:@ui5/fs.Resource[]} embeddedManifests list of embedded manifest resources,
354
+ * @property {@ui5/fs/Resource[]} embeddedManifests list of embedded manifest resources,
347
355
  * e.g. resource with path "lib/x/sub/manifest.json"
348
- * @public
349
356
  */
350
357
 
351
358
  /**
352
359
  * Creates sap-ui-version.json.
353
360
  *
354
361
  * @public
355
- * @alias module:@ui5/builder.processors.versionInfoGenerator
362
+ * @function default
363
+ * @static
364
+ *
356
365
  * @param {object} parameters Parameters
357
366
  * @param {object} parameters.options Options
358
367
  * @param {string} parameters.options.rootProjectName Name of the root project
359
368
  * @param {string} parameters.options.rootProjectVersion Version of the root project
360
- * @param {LibraryInfo[]} parameters.options.libraryInfos Array of objects representing libraries,
369
+ * @param {module:@ui5/builder/processors/versionInfoGenerator~LibraryInfo[]} parameters.options.libraryInfos Array of
370
+ * objects representing libraries,
361
371
  * e.g. <pre>
362
372
  * {
363
373
  * name: "lib.x",
364
374
  * version: "1.0.0",
365
- * libraryManifest: module:@ui5/fs.Resource,
366
- * embeddedManifests: module:@ui5/fs.Resource[]
375
+ * libraryManifest: @ui5/fs/Resource,
376
+ * embeddedManifests: @ui5/fs/Resource[]
367
377
  * }
368
378
  * </pre>
369
- * @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving with an array containing the versionInfo resource
379
+ * @returns {Promise<@ui5/fs/Resource[]>} Promise resolving with an array containing the versionInfo resource
370
380
  */
371
381
 
372
- module.exports = async function({options}) {
382
+ export default async function({options}) {
373
383
  if (!options.rootProjectName || options.rootProjectVersion === undefined || options.libraryInfos === undefined) {
374
384
  throw new Error("[versionInfoGenerator]: Missing options parameters");
375
385
  }
@@ -423,7 +433,7 @@ module.exports = async function({options}) {
423
433
  let components;
424
434
  artifactInfos.forEach((artifactInfo) => {
425
435
  artifactInfo.embeds.forEach((embeddedArtifactInfo) => {
426
- const componentObject = {};
436
+ const componentObject = Object.create(null);
427
437
  const bundledComponents = artifactInfo.bundledComponents;
428
438
  const componentName = embeddedArtifactInfo.componentName;
429
439
  if (!bundledComponents.has(componentName)) {
@@ -436,7 +446,7 @@ module.exports = async function({options}) {
436
446
  componentObject.manifestHints = manifestHints;
437
447
  }
438
448
 
439
- components = components || {};
449
+ components = components || Object.create(null);
440
450
  components[componentName] = componentObject;
441
451
  });
442
452
  });
@@ -454,8 +464,8 @@ module.exports = async function({options}) {
454
464
  components
455
465
  };
456
466
 
457
- return [resourceFactory.createResource({
467
+ return [createResource({
458
468
  path: "/resources/sap-ui-version.json",
459
469
  string: JSON.stringify(versionJson, null, "\t")
460
470
  })];
461
- };
471
+ }
@@ -1,17 +1,24 @@
1
- const path = require("path");
2
- const themeBuilder = require("../processors/themeBuilder");
3
- const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritized;
4
- const fsInterface = require("@ui5/fs").fsInterface;
5
- const log = require("@ui5/logger").getLogger("builder:tasks:buildThemes");
1
+ import path from "node:path";
2
+ import themeBuilder from "../processors/themeBuilder.js";
3
+ import fsInterface from "@ui5/fs/fsInterface";
4
+ import ReaderCollectionPrioritized from "@ui5/fs/ReaderCollectionPrioritized";
5
+ import logger from "@ui5/logger";
6
+ const log = logger.getLogger("builder:tasks:buildThemes");
6
7
 
8
+ /**
9
+ * @public
10
+ * @module @ui5/builder/tasks/buildThemes
11
+ */
7
12
  /**
8
13
  * Task to build a library theme.
9
14
  *
10
15
  * @public
11
- * @alias module:@ui5/builder.tasks.buildThemes
16
+ * @function default
17
+ * @static
18
+ *
12
19
  * @param {object} parameters Parameters
13
- * @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
20
+ * @param {@ui5/fs/DuplexCollection} parameters.workspace DuplexCollection to read and write files
21
+ * @param {@ui5/fs/AbstractReader} parameters.dependencies Reader or Collection to read dependency files
15
22
  * @param {object} parameters.options Options
16
23
  * @param {string} parameters.options.projectName Project name
17
24
  * @param {string} parameters.options.inputPattern Search pattern for *.less files to be built
@@ -21,7 +28,7 @@ const log = require("@ui5/logger").getLogger("builder:tasks:buildThemes");
21
28
  * @param {boolean} [parameters.options.cssVariables=false]
22
29
  * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
23
30
  */
24
- module.exports = async function({
31
+ export default async function({
25
32
  workspace, dependencies,
26
33
  options: {
27
34
  projectName, inputPattern, librariesPattern, themesPattern, compress, cssVariables
@@ -97,7 +104,7 @@ module.exports = async function({
97
104
 
98
105
  if (log.isLevelEnabled("verbose")) {
99
106
  if (!libraryAvailable) {
100
- log.verbose(`Skipping ${resourcePath}: Library is not available`);
107
+ log.silly(`Skipping ${resourcePath}: Library is not available`);
101
108
  }
102
109
  if (!themeAvailable) {
103
110
  log.verbose(`Skipping ${resourcePath}: sap.ui.core theme '${themeName}' is not available. ` +
@@ -136,4 +143,4 @@ module.exports = async function({
136
143
  await Promise.all(processedResources.map((resource) => {
137
144
  return workspace.write(resource);
138
145
  }));
139
- };
146
+ }
@@ -1,23 +1,34 @@
1
- const moduleBundler = require("../../processors/bundlers/moduleBundler");
2
- const createModuleNameMapping = require("./utils/createModuleNameMapping");
3
- const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritized;
1
+ import moduleBundler from "../../processors/bundlers/moduleBundler.js";
2
+ import createModuleNameMapping from "./utils/createModuleNameMapping.js";
3
+ import ReaderCollectionPrioritized from "@ui5/fs/ReaderCollectionPrioritized";
4
4
 
5
+ /**
6
+ * @public
7
+ * @module @ui5/builder/tasks/bundlers/generateBundle
8
+ */
9
+
10
+ /* eslint-disable max-len */
5
11
  /**
6
12
  * Generates a bundle based on the given bundle definition
7
13
  *
8
14
  * @public
9
- * @alias module:@ui5/builder.tasks.generateBundle
15
+ * @function default
16
+ * @static
17
+ *
10
18
  * @param {object} parameters Parameters
11
- * @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
12
- * @param {module:@ui5/fs.ReaderCollection} parameters.dependencies Collection to read dependency files
13
- * @param {module:@ui5/project.build.helpers.TaskUtil|object} [parameters.taskUtil] TaskUtil
19
+ * @param {@ui5/fs/DuplexCollection} parameters.workspace DuplexCollection to read and write files
20
+ * @param {@ui5/fs/ReaderCollection} parameters.dependencies Collection to read dependency files
21
+ * @param {@ui5/project/build/helpers/TaskUtil|object} [parameters.taskUtil] TaskUtil
14
22
  * @param {object} parameters.options Options
15
23
  * @param {string} parameters.options.projectName Project name
16
- * @param {ModuleBundleDefinition} parameters.options.bundleDefinition Module bundle definition
17
- * @param {ModuleBundleOptions} [parameters.options.bundleOptions] Module bundle options
24
+ * @param {module:@ui5/builder/processors/bundlers/moduleBundler~ModuleBundleDefinition} parameters.options.bundleDefinition Module
25
+ * bundle definition
26
+ * @param {module:@ui5/builder/processors/bundlers/moduleBundler~ModuleBundleOptions} [parameters.options.bundleOptions] Module
27
+ * bundle options
18
28
  * @returns {Promise} Promise resolving with <code>undefined</code> once data has been written
19
29
  */
20
- module.exports = function({
30
+ /* eslint-enable max-len */
31
+ export default async function({
21
32
  workspace, dependencies, taskUtil, options: {projectName, bundleDefinition, bundleOptions}
22
33
  }) {
23
34
  let combo = new ReaderCollectionPrioritized({
@@ -76,7 +87,7 @@ module.exports = function({
76
87
  // Omit -dbg files for optimize bundles and vice versa
77
88
  const filterTag = optimize ?
78
89
  taskUtil.STANDARD_TAGS.IsDebugVariant : taskUtil.STANDARD_TAGS.HasDebugVariant;
79
- combo = combo.filter(function(resource) {
90
+ combo = await combo.filter(function(resource) {
80
91
  return !taskUtil.getTag(resource, filterTag);
81
92
  });
82
93
  }
@@ -108,4 +119,4 @@ module.exports = function({
108
119
  }));
109
120
  });
110
121
  });
111
- };
122
+ }
@@ -1,16 +1,24 @@
1
- const path = require("path");
2
- const moduleBundler = require("../../processors/bundlers/moduleBundler");
3
- const log = require("@ui5/logger").getLogger("builder:tasks:bundlers:generateComponentPreload");
4
- const {negateFilters} = require("../../lbt/resources/ResourceFilterList");
1
+ import path from "node:path";
2
+ import moduleBundler from "../../processors/bundlers/moduleBundler.js";
3
+ import logger from "@ui5/logger";
4
+ const log = logger.getLogger("builder:tasks:bundlers:generateComponentPreload");
5
+ import {negateFilters} from "../../lbt/resources/ResourceFilterList.js";
6
+
7
+ /**
8
+ * @public
9
+ * @module @ui5/builder/tasks/bundlers/generateComponentPreload
10
+ */
5
11
 
6
12
  /**
7
13
  * Task to for application bundling.
8
14
  *
9
15
  * @public
10
- * @alias module:@ui5/builder.tasks.generateComponentPreload
16
+ * @function default
17
+ * @static
18
+ *
11
19
  * @param {object} parameters Parameters
12
- * @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
13
- * @param {module:@ui5/project.build.helpers.TaskUtil|object} [parameters.taskUtil] TaskUtil
20
+ * @param {@ui5/fs/DuplexCollection} parameters.workspace DuplexCollection to read and write files
21
+ * @param {@ui5/project/build/helpers/TaskUtil|object} [parameters.taskUtil] TaskUtil
14
22
  * @param {object} parameters.options Options
15
23
  * @param {string} parameters.options.projectName Project name
16
24
  * @param {string[]} [parameters.options.excludes=[]] List of modules declared as glob patterns (resource name patterns)
@@ -24,14 +32,17 @@ const {negateFilters} = require("../../lbt/resources/ResourceFilterList");
24
32
  * @param {string[]} [parameters.options.skipBundles] Names of bundles that should not be created
25
33
  * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
26
34
  */
27
- module.exports = function({
35
+ export default async function({
28
36
  workspace, taskUtil, options: {projectName, paths, namespaces, skipBundles = [], excludes = []}
29
37
  }) {
30
38
  let nonDbgWorkspace = workspace;
31
39
  if (taskUtil) {
32
- nonDbgWorkspace = workspace.filter(function(resource) {
33
- // Remove any debug variants
34
- return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.IsDebugVariant);
40
+ nonDbgWorkspace = taskUtil.resourceFactory.createFilterReader({
41
+ reader: workspace,
42
+ callback: function(resource) {
43
+ // Remove any debug variants
44
+ return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.IsDebugVariant);
45
+ }
35
46
  });
36
47
  }
37
48
 
@@ -163,4 +174,4 @@ module.exports = function({
163
174
  ]);
164
175
  }));
165
176
  });
166
- };
177
+ }
@@ -1,6 +1,12 @@
1
- const log = require("@ui5/logger").getLogger("builder:tasks:bundlers:generateFlexChangesBundle");
2
- const flexChangesBundler = require("../../processors/bundlers/flexChangesBundler");
3
- const semver = require("semver");
1
+ import logger from "@ui5/logger";
2
+ const log = logger.getLogger("builder:tasks:bundlers:generateFlexChangesBundle");
3
+ import flexChangesBundler from "../../processors/bundlers/flexChangesBundler.js";
4
+ import semver from "semver";
5
+
6
+ /**
7
+ * @public
8
+ * @module @ui5/builder/tasks/bundlers/generateFlexChangesBundle
9
+ */
4
10
 
5
11
  /* eslint "jsdoc/check-param-names": ["error", {"disableExtraPropertyReporting":true}] */
6
12
  /**
@@ -12,15 +18,17 @@ const semver = require("semver");
12
18
  * If there are control variants and minUI5Version < 1.73 build will break and throw an error.
13
19
  *
14
20
  * @public
15
- * @alias module:@ui5/builder.tasks.generateFlexChangesBundle
21
+ * @function default
22
+ * @static
23
+ *
16
24
  * @param {object} parameters Parameters
17
- * @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
18
- * @param {module:@ui5/project.build.helpers.TaskUtil|object} [parameters.taskUtil] TaskUtil
25
+ * @param {@ui5/fs/DuplexCollection} parameters.workspace DuplexCollection to read and write files
26
+ * @param {@ui5/project/build/helpers/TaskUtil|object} [parameters.taskUtil] TaskUtil
19
27
  * @param {object} [parameters.options] Options
20
28
  * @param {string} [parameters.options.projectNamespace] Project Namespace
21
29
  * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
22
30
  */
23
- module.exports = async function({workspace, taskUtil, options = {}}) {
31
+ export default async function({workspace, taskUtil, options = {}}) {
24
32
  // Backward compatibility: "namespace" option got renamed to "projectNamespace"
25
33
  const namespace = options.projectNamespace || options.namespace;
26
34
 
@@ -101,4 +109,4 @@ module.exports = async function({workspace, taskUtil, options = {}}) {
101
109
  });
102
110
  }
103
111
  }
104
- };
112
+ }
@@ -1,7 +1,8 @@
1
- const log = require("@ui5/logger").getLogger("builder:tasks:bundlers:generateLibraryPreload");
2
- const moduleBundler = require("../../processors/bundlers/moduleBundler");
3
- const {negateFilters} = require("../../lbt/resources/ResourceFilterList");
4
- const createModuleNameMapping = require("./utils/createModuleNameMapping");
1
+ import logger from "@ui5/logger";
2
+ const log = logger.getLogger("builder:tasks:bundlers:generateLibraryPreload");
3
+ import moduleBundler from "../../processors/bundlers/moduleBundler.js";
4
+ import {negateFilters} from "../../lbt/resources/ResourceFilterList.js";
5
+ import createModuleNameMapping from "./utils/createModuleNameMapping.js";
5
6
 
6
7
  function getDefaultLibraryPreloadFilters(namespace, excludes) {
7
8
  const filters = [
@@ -216,14 +217,21 @@ function getSapUiCoreBunDef(name, filters, preload) {
216
217
  return bundleDefinition;
217
218
  }
218
219
 
220
+ /**
221
+ * @public
222
+ * @module @ui5/builder/tasks/bundlers/generateLibraryPreload
223
+ */
224
+
219
225
  /**
220
226
  * Task for library bundling.
221
227
  *
222
228
  * @public
223
- * @alias module:@ui5/builder.tasks.generateLibraryPreload
229
+ * @function default
230
+ * @static
231
+ *
224
232
  * @param {object} parameters Parameters
225
- * @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
226
- * @param {module:@ui5/project.build.helpers.TaskUtil} [parameters.taskUtil] TaskUtil
233
+ * @param {@ui5/fs/DuplexCollection} parameters.workspace DuplexCollection to read and write files
234
+ * @param {@ui5/project/build/helpers/TaskUtil} [parameters.taskUtil] TaskUtil
227
235
  * @param {object} parameters.options Options
228
236
  * @param {string} parameters.options.projectName Project name
229
237
  * @param {string[]} [parameters.options.skipBundles] Names of bundles that should not be created
@@ -235,12 +243,15 @@ function getSapUiCoreBunDef(name, filters, preload) {
235
243
  * inclusion overrides an earlier exclusion, and vice versa.
236
244
  * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
237
245
  */
238
- module.exports = function({workspace, taskUtil, options: {skipBundles = [], excludes = [], projectName}}) {
246
+ export default async function({workspace, taskUtil, options: {skipBundles = [], excludes = [], projectName}}) {
239
247
  let nonDbgWorkspace = workspace;
240
248
  if (taskUtil) {
241
- nonDbgWorkspace = workspace.filter(function(resource) {
242
- // Remove any debug variants
243
- return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.IsDebugVariant);
249
+ nonDbgWorkspace = taskUtil.resourceFactory.createFilterReader({
250
+ reader: workspace,
251
+ callback: function(resource) {
252
+ // Remove any debug variants
253
+ return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.IsDebugVariant);
254
+ }
244
255
  });
245
256
  }
246
257
 
@@ -265,7 +276,7 @@ module.exports = function({workspace, taskUtil, options: {skipBundles = [], excl
265
276
  // This is mainly to have an easier check without version parsing or using semver.
266
277
  // If no project/specVersion is available, the bundles should also be created to not break potential
267
278
  // existing use cases without a properly formed/formatted project tree.
268
- if (!taskUtil || ["0.1", "1.1", "2.0"].includes(taskUtil.getProject().getSpecVersion())) {
279
+ if (!taskUtil || taskUtil.getProject().getSpecVersion().lte("2.0")) {
269
280
  const isEvo = resources.find((resource) => {
270
281
  return resource.getPath() === "/resources/ui5loader.js";
271
282
  });
@@ -273,10 +284,15 @@ module.exports = function({workspace, taskUtil, options: {skipBundles = [], excl
273
284
  let unoptimizedModuleNameMapping;
274
285
  let unoptimizedResources = resources;
275
286
  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}");
287
+ const unoptimizedWorkspace = taskUtil.resourceFactory.createFilterReader({
288
+ reader: workspace,
289
+ callback: function(resource) {
290
+ // Remove any non-debug variants
291
+ return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.HasDebugVariant);
292
+ }
293
+ });
294
+ unoptimizedResources =
295
+ await unoptimizedWorkspace.byGlob("/**/*.{js,json,xml,html,properties,library,js.map}");
280
296
 
281
297
  unoptimizedModuleNameMapping = createModuleNameMapping({
282
298
  resources: unoptimizedResources,
@@ -434,4 +450,4 @@ module.exports = function({workspace, taskUtil, options: {skipBundles = [], excl
434
450
  });
435
451
  });
436
452
  });
437
- };
453
+ }
@@ -1,7 +1,8 @@
1
- const log = require("@ui5/logger").getLogger("builder:tasks:bundlers:generateStandaloneAppBundle");
2
- const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritized;
3
- const moduleBundler = require("../../processors/bundlers/moduleBundler");
4
- const createModuleNameMapping = require("./utils/createModuleNameMapping");
1
+ import logger from "@ui5/logger";
2
+ const log = logger.getLogger("builder:tasks:bundlers:generateStandaloneAppBundle");
3
+ import ReaderCollectionPrioritized from "@ui5/fs/ReaderCollectionPrioritized";
4
+ import moduleBundler from "../../processors/bundlers/moduleBundler.js";
5
+ import createModuleNameMapping from "./utils/createModuleNameMapping.js";
5
6
 
6
7
  function getBundleDefinition(config) {
7
8
  const bundleDefinition = {
@@ -58,22 +59,29 @@ function getBundleDefinition(config) {
58
59
  return bundleDefinition;
59
60
  }
60
61
 
62
+ /**
63
+ * @public
64
+ * @module @ui5/builder/tasks/bundlers/generateStandaloneAppBundle
65
+ */
66
+
61
67
  /* eslint "jsdoc/check-param-names": ["error", {"disableExtraPropertyReporting":true}] */
62
68
  /**
63
69
  * Task for bundling standalone applications.
64
70
  *
65
71
  * @public
66
- * @alias module:@ui5/builder.tasks.generateStandaloneAppBundle
72
+ * @function default
73
+ * @static
74
+ *
67
75
  * @param {object} parameters Parameters
68
- * @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
69
- * @param {module:@ui5/fs.AbstractReader} parameters.dependencies Reader or Collection to read dependency files
70
- * @param {module:@ui5/project.build.helpers.TaskUtil|object} [parameters.taskUtil] TaskUtil
76
+ * @param {@ui5/fs/DuplexCollection} parameters.workspace DuplexCollection to read and write files
77
+ * @param {@ui5/fs/AbstractReader} parameters.dependencies Reader or Collection to read dependency files
78
+ * @param {@ui5/project/build/helpers/TaskUtil|object} [parameters.taskUtil] TaskUtil
71
79
  * @param {object} parameters.options Options
72
80
  * @param {string} parameters.options.projectName Project name
73
81
  * @param {string} [parameters.options.projectNamespace] Project namespace
74
82
  * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
75
83
  */
76
- module.exports = async function({workspace, dependencies, taskUtil, options}) {
84
+ export default async function({workspace, dependencies, taskUtil, options}) {
77
85
  const {projectName} = options;
78
86
  // Backward compatibility: "namespace" option got renamed to "projectNamespace"
79
87
  const namespace = options.projectNamespace || options.namespace;
@@ -90,7 +98,7 @@ module.exports = async function({workspace, dependencies, taskUtil, options}) {
90
98
 
91
99
  if (taskUtil) {
92
100
  // Omit -dbg files
93
- combo = combo.filter(function(resource) {
101
+ combo = await combo.filter(function(resource) {
94
102
  return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.IsDebugVariant);
95
103
  });
96
104
  }
@@ -109,13 +117,13 @@ module.exports = async function({workspace, dependencies, taskUtil, options}) {
109
117
  let unoptimizedModuleNameMapping;
110
118
  let unoptimizedResources = resources;
111
119
  if (taskUtil) {
112
- unoptimizedResources = await new ReaderCollectionPrioritized({
120
+ unoptimizedResources = await (await new ReaderCollectionPrioritized({
113
121
  name: `generateStandaloneAppBundle - prioritize workspace over dependencies: ${projectName}`,
114
122
  readers: [workspace, dependencies]
115
123
  }).filter(function(resource) {
116
124
  // Remove any non-debug variants
117
125
  return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.HasDebugVariant);
118
- }).byGlob("/resources/**/*.{js,json,xml,html,properties,library,js.map}");
126
+ })).byGlob("/resources/**/*.{js,json,xml,html,properties,library,js.map}");
119
127
 
120
128
  unoptimizedModuleNameMapping = createModuleNameMapping({
121
129
  resources: unoptimizedResources,
@@ -167,4 +175,4 @@ module.exports = async function({workspace, dependencies, taskUtil, options}) {
167
175
  return Promise.all(writes);
168
176
  }));
169
177
  });
170
- };
178
+ }
@@ -1,4 +1,4 @@
1
- const ModuleName = require("../../../lbt/utils/ModuleName");
1
+ import {getNonDebugName} from "../../../lbt/utils/ModuleName.js";
2
2
 
3
3
  /**
4
4
  * For "unoptimized" bundles, the non-debug files have already been filtered out above.
@@ -10,17 +10,17 @@ const ModuleName = require("../../../lbt/utils/ModuleName");
10
10
  *
11
11
  * @private
12
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
13
+ * @param {@ui5/fs/Resource[]} parameters.resources List of resources
14
+ * @param {@ui5/project/build/helpers/TaskUtil|object} parameters.taskUtil TaskUtil
15
15
  * @returns {object} Module name mapping
16
16
  */
17
- module.exports = function({resources, taskUtil}) {
18
- const moduleNameMapping = {};
17
+ export default function({resources, taskUtil}) {
18
+ const moduleNameMapping = Object.create(null);
19
19
  for (let i = resources.length - 1; i >= 0; i--) {
20
20
  const resource = resources[i];
21
21
  if (taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.IsDebugVariant)) {
22
22
  const resourcePath = resource.getPath();
23
- const nonDbgPath = ModuleName.getNonDebugName(resourcePath);
23
+ const nonDbgPath = getNonDebugName(resourcePath);
24
24
  if (!nonDbgPath) {
25
25
  throw new Error(`Failed to resolve non-debug name for ${resourcePath}`);
26
26
  }
@@ -28,4 +28,4 @@ module.exports = function({resources, taskUtil}) {
28
28
  }
29
29
  }
30
30
  return moduleNameMapping;
31
- };
31
+ }