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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,7 +2,14 @@
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.5...HEAD).
5
+ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.6...HEAD).
6
+
7
+ <a name="v3.0.0-alpha.6"></a>
8
+ ## [v3.0.0-alpha.6] - 2022-04-26
9
+ ### Bug Fixes
10
+ - **JSModuleAnalyzer:** Fix detection of bundle name ([#705](https://github.com/SAP/ui5-builder/issues/705)) [`aaeafd4`](https://github.com/SAP/ui5-builder/commit/aaeafd4a1fd194dd08e5ae47c29d90f0b4c7d197)
11
+ - **generateResourcesJson:** Add raw-module info for debug bundles ([#736](https://github.com/SAP/ui5-builder/issues/736)) [`3b918e8`](https://github.com/SAP/ui5-builder/commit/3b918e83bfd38342778ecd4c58e648e99ad7cffc)
12
+
6
13
 
7
14
  <a name="v3.0.0-alpha.5"></a>
8
15
  ## [v3.0.0-alpha.5] - 2022-04-14
@@ -714,6 +721,7 @@ to load the custom bundle file instead.
714
721
  - Add ability to configure component preloads and custom bundles [`2241e5f`](https://github.com/SAP/ui5-builder/commit/2241e5ff98fd95f1f80cc74959655ae7a9c660e7)
715
722
 
716
723
 
724
+ [v3.0.0-alpha.6]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.5...v3.0.0-alpha.6
717
725
  [v3.0.0-alpha.5]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.4...v3.0.0-alpha.5
718
726
  [v3.0.0-alpha.4]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.3...v3.0.0-alpha.4
719
727
  [v3.0.0-alpha.3]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.2...v3.0.0-alpha.3
@@ -301,6 +301,9 @@ class JSModuleAnalyzer {
301
301
  */
302
302
  let bIsUi5Module = false;
303
303
 
304
+ // Module name via @ui5-bundle comment in first line. Overrides all other main module candidates.
305
+ let firstLineBundleName;
306
+
304
307
  // first analyze the whole AST...
305
308
  visit(ast, false);
306
309
 
@@ -314,7 +317,12 @@ class JSModuleAnalyzer {
314
317
  log.verbose(`bundle include directive ${subModule}`);
315
318
  } else if ( comment.value.startsWith("@ui5-bundle ") ) {
316
319
  const bundleName = comment.value.slice("@ui5-bundle ".length);
317
- setMainModuleInfo(bundleName, null);
320
+ if (comment.start === 0) {
321
+ // Remember the name from the first line to use it as final name
322
+ firstLineBundleName = bundleName;
323
+ } else {
324
+ setMainModuleInfo(bundleName, null);
325
+ }
318
326
  log.verbose(`bundle name directive ${bundleName}`);
319
327
  } else {
320
328
  log.warn(`unrecognized bundle directive ${comment.value}`);
@@ -324,7 +332,10 @@ class JSModuleAnalyzer {
324
332
  }
325
333
 
326
334
  // ...and finally take conclusions about the file's content
327
- if ( !mainModuleFound ) {
335
+ if ( firstLineBundleName ) {
336
+ // If the first line has a bundle name, use it and override all other found names
337
+ info.name = firstLineBundleName;
338
+ } else if ( !mainModuleFound ) {
328
339
  // if there's exactly one module definition in this file but it didn't
329
340
  // immediately qualify as main module, make it now the main module
330
341
  if ( candidateName != null && nModuleDeclarations == 1 ) {
@@ -110,10 +110,11 @@ class ResourceCollector {
110
110
  }
111
111
 
112
112
  async enrichWithDependencyInfo(resourceInfo) {
113
- return this._pool.getModuleInfo(resourceInfo.name).then(async (moduleInfo) => {
114
- if ( moduleInfo.name ) {
113
+ return this._pool.getModuleInfo(resourceInfo.name, resourceInfo.module).then(async (moduleInfo) => {
114
+ if ( !resourceInfo.module && moduleInfo.name ) {
115
115
  resourceInfo.module = moduleInfo.name;
116
116
  }
117
+
117
118
  if ( moduleInfo.dynamicDependencies ) {
118
119
  resourceInfo.dynRequired = true;
119
120
  }
@@ -279,37 +280,43 @@ class ResourceCollector {
279
280
 
280
281
  await Promise.all(promises);
281
282
 
282
- const debugBundlePromises = [];
283
-
284
- for (let i = debugResourcesInfo.length - 1; i >= 0; i--) {
285
- const dbgInfo = debugResourcesInfo[i];
286
- const nonDebugName = ResourceInfoList.getNonDebugName(dbgInfo.name);
283
+ await Promise.all(debugResourcesInfo.map(async (dbgInfo) => {
284
+ const debugName = dbgInfo.name;
285
+ const nonDebugName = ResourceInfoList.getNonDebugName(debugName);
287
286
  const nonDbgInfo = this._resources.get(nonDebugName);
288
287
 
289
288
  // FIXME: "merged" property is only calculated in ResourceInfo#copyFrom
290
289
  // Therefore using the same logic here to compute it.
290
+
291
+ // TODO: Idea: Use IsDebugVariant tag to decide whether to analyze the resource
292
+ // If the tag is set, we don't expect different analysis results so we can copy the info (else-path)
293
+ // Only when the tag is not set, we analyze the resource with its name (incl. -dbg)
294
+
291
295
  if (!nonDbgInfo || (nonDbgInfo.included != null && nonDbgInfo.included.size > 0)) {
292
296
  // We need to analyze the dbg resource if there is no non-dbg variant or
293
297
  // it is a bundle because we will (usually) have different content.
294
- debugBundlePromises.push(
295
- this.enrichWithDependencyInfo(dbgInfo)
296
- );
298
+
299
+ if (nonDbgInfo) {
300
+ // Always use the non-debug module name, if available
301
+ dbgInfo.module = nonDbgInfo.module;
302
+ }
303
+ await this.enrichWithDependencyInfo(dbgInfo);
297
304
  } else {
298
305
  // If the non-dbg resource is not a bundle, we can just copy over the info and skip
299
306
  // analyzing the dbg variant as both should have the same info.
300
307
 
301
- const newDbgInfo = new ResourceInfo(dbgInfo.name);
308
+ const newDbgInfo = new ResourceInfo(debugName);
302
309
 
303
310
  // First copy info of analysis from non-dbg file (included, required, condRequired, ...)
304
311
  newDbgInfo.copyFrom(null, nonDbgInfo);
305
312
  // Then copy over info from dbg file to properly set name, isDebug, etc.
306
313
  newDbgInfo.copyFrom(null, dbgInfo);
314
+ // Finally, set the module name to the non-dbg name
315
+ newDbgInfo.module = nonDbgInfo.module;
307
316
 
308
- this._resources.set(dbgInfo.name, newDbgInfo);
317
+ this._resources.set(debugName, newDbgInfo);
309
318
  }
310
- }
311
-
312
- await Promise.all(debugBundlePromises);
319
+ }));
313
320
  }
314
321
 
315
322
  createOrphanFilters() {
@@ -48,7 +48,6 @@ class ResourceInfoList {
48
48
  if ( myInfo == null ) {
49
49
  myInfo = new ResourceInfo(relativeName);
50
50
  myInfo.size = info.size;
51
- myInfo.module = ResourceInfoList.getNonDebugName(info.name);
52
51
  this.resources.push(myInfo);
53
52
  this.resourcesByName.set(relativeName, myInfo);
54
53
  }
@@ -176,17 +176,18 @@ class ResourcePool {
176
176
  /**
177
177
  * Retrieves the module info
178
178
  *
179
- * @param {string} name module name
179
+ * @param {string} resourceName resource/module name
180
+ * @param {string} [moduleName] module name, in case it differs from the resource name (e.g. for -dbg resources)
180
181
  * @returns {Promise<ModuleInfo>}
181
182
  */
182
- async getModuleInfo(name) {
183
- let info = this._dependencyInfos.get(name);
183
+ async getModuleInfo(resourceName, moduleName) {
184
+ let info = this._dependencyInfos.get(resourceName);
184
185
  if ( info == null ) {
185
186
  info = Promise.resolve().then(async () => {
186
- const resource = await this.findResource(name);
187
- return determineDependencyInfo( resource, this._rawModuleInfos.get(name), this );
187
+ const resource = await this.findResource(resourceName);
188
+ return determineDependencyInfo( resource, this._rawModuleInfos.get(moduleName || resourceName), this );
188
189
  });
189
- this._dependencyInfos.set(name, info);
190
+ this._dependencyInfos.set(resourceName, info);
190
191
  }
191
192
  return info;
192
193
  }
@@ -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,18 @@ 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
16
14
  * @param {object} parameters.options Options
17
15
  * @param {string} parameters.options.projectName Project name
18
16
  * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
19
17
  */
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
- });
18
+ module.exports = function({workspace, options: {projectName}}) {
25
19
  // Note:
26
20
  // *.library files are needed to identify libraries
27
21
  // *.json files are needed to avoid overwriting them
28
22
  // *.js files are needed to identify nested components
29
23
  // *.less, *.css, *.theming and *.theme files are needed to identify supported themes
30
24
  // *.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) => {
25
+ return workspace.byGlob("/resources/**/*.{js,json,library,less,css,theming,theme,properties}").then((resources) => {
32
26
  // Find all libraries and create a manifest.json file
33
27
  return workspace.byGlob("/resources/**/.library").then((libraryIndicatorResources) => {
34
28
  if (libraryIndicatorResources.length < 1) {
@@ -112,7 +112,6 @@ class LibraryBuilder extends AbstractBuilder {
112
112
  this.addTask("generateLibraryManifest", async () => {
113
113
  return getTask("generateLibraryManifest").task({
114
114
  workspace: resourceCollections.workspace,
115
- dependencies: resourceCollections.dependencies,
116
115
  taskUtil,
117
116
  options: {
118
117
  projectName: project.metadata.name
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/builder",
3
- "version": "3.0.0-alpha.5",
3
+ "version": "3.0.0-alpha.6",
4
4
  "description": "UI5 Tooling - Builder",
5
5
  "author": {
6
6
  "name": "SAP SE",
@@ -105,7 +105,7 @@
105
105
  "url": "git@github.com:SAP/ui5-builder.git"
106
106
  },
107
107
  "dependencies": {
108
- "@ui5/fs": "^3.0.0-alpha.2",
108
+ "@ui5/fs": "^3.0.0-alpha.3",
109
109
  "@ui5/logger": "^3.0.1-alpha.1",
110
110
  "cheerio": "1.0.0-rc.9",
111
111
  "escape-unicode": "^0.2.0",