@ui5/builder 3.0.0-alpha.2 → 3.0.0-alpha.3

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,10 +2,16 @@
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.2...HEAD).
5
+ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.3...HEAD).
6
+
7
+ <a name="v3.0.0-alpha.3"></a>
8
+ ## [v3.0.0-alpha.3] - 2022-03-10
9
+ ### Bug Fixes
10
+ - **LocatorResourcePool:** Wait for resources in prepare step ([#719](https://github.com/SAP/ui5-builder/issues/719)) [`1b7f93f`](https://github.com/SAP/ui5-builder/commit/1b7f93f4988340d7a6575be3191a02e6c295ebd0)
11
+
6
12
 
7
13
  <a name="v3.0.0-alpha.2"></a>
8
- ## [v3.0.0-alpha.2] - 2022-02-21
14
+ ## [v3.0.0-alpha.2] - 2022-02-25
9
15
  ### Bug Fixes
10
16
  - **XMLTemplateAnalyzer:** Analyze core:require of FragmentDefinition [`af075ed`](https://github.com/SAP/ui5-builder/commit/af075edf784d9f1ba162a34f0bf150dbcbc0f479)
11
17
 
@@ -687,6 +693,7 @@ to load the custom bundle file instead.
687
693
  - Add ability to configure component preloads and custom bundles [`2241e5f`](https://github.com/SAP/ui5-builder/commit/2241e5ff98fd95f1f80cc74959655ae7a9c660e7)
688
694
 
689
695
 
696
+ [v3.0.0-alpha.3]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.2...v3.0.0-alpha.3
690
697
  [v3.0.0-alpha.2]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.1...v3.0.0-alpha.2
691
698
  [v3.0.0-alpha.1]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.0...v3.0.0-alpha.1
692
699
  [v3.0.0-alpha.0]: https://github.com/SAP/ui5-builder/compare/v2.11.2...v3.0.0-alpha.0
@@ -1,9 +1,5 @@
1
1
  const Resource = require("./Resource");
2
2
 
3
- // function extractName(path) {
4
- // return path.slice( "/resources/".length);
5
- // }
6
-
7
3
  class LocatorResource extends Resource {
8
4
  constructor(pool, resource, moduleName) {
9
5
  super(pool, moduleName, null, resource.getStatInfo());
@@ -10,7 +10,7 @@ class LocatorResourcePool extends ResourcePool {
10
10
  if (!moduleName) {
11
11
  moduleName = resource.getPath().slice("/resources/".length);
12
12
  }
13
- this.addResource(new LocatorResource(this, resource, moduleName));
13
+ return this.addResource(new LocatorResource(this, resource, moduleName));
14
14
  }).filter(Boolean)
15
15
  );
16
16
  }
@@ -90,8 +90,7 @@ const log = require("@ui5/logger").getLogger("builder:processors:bundlers:module
90
90
  * @public
91
91
  * @typedef {object} ModuleBundleOptions
92
92
  * @property {boolean} [optimize=true] Whether the module bundle gets minified
93
- * @property {boolean} [sourceMap] Whether to generate a source map file for the bundle.
94
- * Defaults to true if <code>optimize</code> is set to true
93
+ * @property {boolean} [sourceMap=true] Whether to generate a source map file for the bundle
95
94
  * @property {boolean} [decorateBootstrapModule=false] If set to 'false', the module won't be decorated
96
95
  * with an optimization marker
97
96
  * @property {boolean} [addTryCatchRestartWrapper=false] Whether to wrap bootable module bundles with
@@ -124,12 +123,14 @@ const log = require("@ui5/logger").getLogger("builder:processors:bundlers:module
124
123
  Optional mapping of resource paths to module name in order to overwrite the default determination
125
124
  * @param {ModuleBundleDefinition} parameters.options.bundleDefinition Module bundle definition
126
125
  * @param {ModuleBundleOptions} [parameters.options.bundleOptions] Module bundle options
127
- * @returns {Promise<module:@ui5/builder.processors.MinifierResult[]>} Promise resolving with module bundle resources
126
+ * @returns {Promise<module:@ui5/builder.processors.ModuleBundlerResult[]>}
127
+ * Promise resolving with module bundle resources
128
128
  */
129
129
  module.exports = function({resources, options: {bundleDefinition, bundleOptions, moduleNameMapping}}) {
130
130
  // Apply defaults without modifying the passed object
131
131
  bundleOptions = Object.assign({}, {
132
132
  optimize: true,
133
+ sourceMap: true,
133
134
  decorateBootstrapModule: false,
134
135
  addTryCatchRestartWrapper: false,
135
136
  usePredefineCalls: false,
@@ -34,12 +34,13 @@ const debugFileRegex = /((?:\.view|\.fragment|\.controller|\.designtime|\.suppor
34
34
  * @alias module:@ui5/builder.processors.minifier
35
35
  * @param {object} parameters Parameters
36
36
  * @param {module:@ui5/fs.Resource[]} parameters.resources List of resources to be processed
37
- * @param {boolean} [parameters.addSourceMappingUrl=true]
37
+ * @param {object} [parameters.options] Options
38
+ * @param {boolean} [parameters.options.addSourceMappingUrl=true]
38
39
  * Whether to add a sourceMappingURL reference to the end of the minified resource
39
40
  * @returns {Promise<module:@ui5/builder.processors.MinifierResult[]>}
40
41
  * Promise resolving with object of resource, dbgResource and sourceMap
41
42
  */
42
- module.exports = async function({resources, addSourceMappingUrl = true}) {
43
+ module.exports = async function({resources, options: {addSourceMappingUrl = true} = {}}) {
43
44
  return Promise.all(resources.map(async (resource) => {
44
45
  const dbgPath = resource.getPath().replace(debugFileRegex, "-dbg$1");
45
46
  const dbgResource = await resource.clone();
@@ -1,5 +1,5 @@
1
1
  const moduleBundler = require("../../processors/bundlers/moduleBundler");
2
- const ModuleName = require("../../lbt/utils/ModuleName");
2
+ const createModuleNameMapping = require("./utils/createModuleNameMapping");
3
3
  const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritized;
4
4
 
5
5
  /**
@@ -21,7 +21,7 @@ module.exports = function({
21
21
  workspace, dependencies, taskUtil, options: {projectName, bundleDefinition, bundleOptions}
22
22
  }) {
23
23
  let combo = new ReaderCollectionPrioritized({
24
- name: `libraryBundler - prioritize workspace over dependencies: ${projectName}`,
24
+ name: `generateBundle - prioritize workspace over dependencies: ${projectName}`,
25
25
  readers: [workspace, dependencies]
26
26
  });
27
27
 
@@ -82,34 +82,16 @@ module.exports = function({
82
82
  }
83
83
 
84
84
  return combo.byGlob("/resources/**/*.{js,json,xml,html,properties,library,js.map}").then((resources) => {
85
- const moduleNameMapping = {};
85
+ const options = {bundleDefinition, bundleOptions};
86
86
  if (!optimize && taskUtil) {
87
- // For "unoptimized" bundles, the non-debug files have already been filtered out above.
88
- // Now we need to create a mapping from the debug-variant resource path to the respective module name,
89
- // which is basically the non-debug resource path, minus the "/resources/"" prefix.
90
- // This mapping overwrites internal logic of the LocatorResourcePool which would otherwise determine
91
- // the module name from the resource path, which would contain "-dbg" in this case. That would be
92
- // incorrect since debug-variants should still keep the original module name.
93
- for (let i = resources.length - 1; i >= 0; i--) {
94
- const resourcePath = resources[i].getPath();
95
- if (taskUtil.getTag(resourcePath, taskUtil.STANDARD_TAGS.IsDebugVariant)) {
96
- const nonDbgPath = ModuleName.getNonDebugName(resourcePath);
97
- if (!nonDbgPath) {
98
- throw new Error(`Failed to resolve non-debug name for ${resourcePath}`);
99
- }
100
- moduleNameMapping[resourcePath] = nonDbgPath.slice("/resources/".length);
101
- }
102
- }
87
+ options.moduleNameMapping = createModuleNameMapping({resources, taskUtil});
103
88
  }
104
- return moduleBundler({
105
- options: {
106
- bundleDefinition,
107
- bundleOptions,
108
- moduleNameMapping
109
- },
110
- resources
111
- }).then((bundles) => {
112
- return Promise.all(bundles.map(({bundle, sourceMap}) => {
89
+ return moduleBundler({options, resources}).then((bundles) => {
90
+ return Promise.all(bundles.map(({bundle, sourceMap} = {}) => {
91
+ if (!bundle) {
92
+ // Skip empty bundles
93
+ return;
94
+ }
113
95
  if (taskUtil) {
114
96
  taskUtil.setTag(bundle, taskUtil.STANDARD_TAGS.IsBundle);
115
97
  if (sourceMap) {
@@ -2,7 +2,7 @@ const log = require("@ui5/logger").getLogger("builder:tasks:bundlers:generateLib
2
2
  const moduleBundler = require("../../processors/bundlers/moduleBundler");
3
3
  const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritized;
4
4
  const {negateFilters} = require("../../lbt/resources/ResourceFilterList");
5
- const ModuleName = require("../../lbt/utils/ModuleName");
5
+ const createModuleNameMapping = require("./utils/createModuleNameMapping");
6
6
 
7
7
  function getDefaultLibraryPreloadFilters(namespace, excludes) {
8
8
  const filters = [
@@ -311,7 +311,7 @@ module.exports = function({workspace, dependencies, taskUtil, options: {projectN
311
311
  return resource.getPath() === "/resources/ui5loader.js";
312
312
  });
313
313
 
314
- const unoptimizedModuleNameMapping = {};
314
+ let unoptimizedModuleNameMapping;
315
315
  let unoptimizedResources = resources;
316
316
  if (taskUtil) {
317
317
  unoptimizedResources = await new ReaderCollectionPrioritized({
@@ -322,22 +322,10 @@ module.exports = function({workspace, dependencies, taskUtil, options: {projectN
322
322
  return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.HasDebugVariant);
323
323
  }).byGlob("/**/*.{js,json,xml,html,properties,library,js.map}");
324
324
 
325
- // For "unoptimized" bundles, the non-debug files have already been filtered out above.
326
- // Now we need to create a mapping from the debug-variant resource path to the respective module
327
- // name, which is basically the non-debug resource path, minus the "/resources/"" prefix.
328
- // This mapping overwrites internal logic of the LocatorResourcePool which would otherwise determine
329
- // the module name from the resource path, which would contain "-dbg" in this case. That would be
330
- // incorrect since debug-variants should still keep the original module name.
331
- for (let i = unoptimizedResources.length - 1; i >= 0; i--) {
332
- const resourcePath = unoptimizedResources[i].getPath();
333
- if (taskUtil.getTag(resourcePath, taskUtil.STANDARD_TAGS.IsDebugVariant)) {
334
- const nonDbgPath = ModuleName.getNonDebugName(resourcePath);
335
- if (!nonDbgPath) {
336
- throw new Error(`Failed to resolve non-debug name for ${resourcePath}`);
337
- }
338
- unoptimizedModuleNameMapping[resourcePath] = nonDbgPath.slice("/resources/".length);
339
- }
340
- }
325
+ unoptimizedModuleNameMapping = createModuleNameMapping({
326
+ resources: unoptimizedResources,
327
+ taskUtil
328
+ });
341
329
  }
342
330
 
343
331
  let filters;
@@ -1,7 +1,7 @@
1
1
  const log = require("@ui5/logger").getLogger("builder:tasks:bundlers:generateStandaloneAppBundle");
2
2
  const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritized;
3
3
  const moduleBundler = require("../../processors/bundlers/moduleBundler");
4
- const ModuleName = require("../../lbt/utils/ModuleName");
4
+ const createModuleNameMapping = require("./utils/createModuleNameMapping");
5
5
 
6
6
  function getBundleDefinition(config) {
7
7
  const bundleDefinition = {
@@ -101,7 +101,7 @@ module.exports = async function({workspace, dependencies, taskUtil, options: {pr
101
101
  filters = ["jquery.sap.global.js"];
102
102
  }
103
103
 
104
- const unoptimizedModuleNameMapping = {};
104
+ let unoptimizedModuleNameMapping;
105
105
  let unoptimizedResources = resources;
106
106
  if (taskUtil) {
107
107
  unoptimizedResources = await new ReaderCollectionPrioritized({
@@ -112,22 +112,10 @@ module.exports = async function({workspace, dependencies, taskUtil, options: {pr
112
112
  return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.HasDebugVariant);
113
113
  }).byGlob("/resources/**/*.{js,json,xml,html,properties,library,js.map}");
114
114
 
115
- // For "unoptimized" bundles, the non-debug files have already been filtered out above.
116
- // Now we need to create a mapping from the debug-variant resource path to the respective module name,
117
- // which is basically the non-debug resource path, minus the "/resources/"" prefix.
118
- // This mapping overwrites internal logic of the LocatorResourcePool which would otherwise determine
119
- // the module name from the resource path, which would contain "-dbg" in this case. That would be
120
- // incorrect since debug-variants should still keep the original module name.
121
- for (let i = unoptimizedResources.length - 1; i >= 0; i--) {
122
- const resourcePath = unoptimizedResources[i].getPath();
123
- if (taskUtil.getTag(resourcePath, taskUtil.STANDARD_TAGS.IsDebugVariant)) {
124
- const nonDbgPath = ModuleName.getNonDebugName(resourcePath);
125
- if (!nonDbgPath) {
126
- throw new Error(`Failed to resolve non-debug name for ${resourcePath}`);
127
- }
128
- unoptimizedModuleNameMapping[resourcePath] = nonDbgPath.slice("/resources/".length);
129
- }
130
- }
115
+ unoptimizedModuleNameMapping = createModuleNameMapping({
116
+ resources: unoptimizedResources,
117
+ taskUtil
118
+ });
131
119
  }
132
120
 
133
121
  await Promise.all([
@@ -0,0 +1,30 @@
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/builder.tasks.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 resourcePath = resources[i].getPath();
21
+ if (taskUtil.getTag(resourcePath, taskUtil.STANDARD_TAGS.IsDebugVariant)) {
22
+ const nonDbgPath = ModuleName.getNonDebugName(resourcePath);
23
+ if (!nonDbgPath) {
24
+ throw new Error(`Failed to resolve non-debug name for ${resourcePath}`);
25
+ }
26
+ moduleNameMapping[resourcePath] = nonDbgPath.slice("/resources/".length);
27
+ }
28
+ }
29
+ return moduleNameMapping;
30
+ };
@@ -18,7 +18,9 @@ module.exports = async function({workspace, taskUtil, options: {pattern, omitSou
18
18
  const resources = await workspace.byGlob(pattern);
19
19
  const processedResources = await minifier({
20
20
  resources,
21
- addSourceMappingUrl: !omitSourceMapResources
21
+ options: {
22
+ addSourceMappingUrl: !omitSourceMapResources
23
+ }
22
24
  });
23
25
 
24
26
  return Promise.all(processedResources.map(async ({resource, dbgResource, sourceMapResource}) => {
@@ -38,7 +38,7 @@ class LibraryBuilder extends AbstractBuilder {
38
38
  workspace: resourceCollections.workspace,
39
39
  options: {
40
40
  version: project.version,
41
- pattern: "/**/*.{js,json,library,less,theme,html}"
41
+ pattern: "/**/*.{js,json,library,css,less,theme,html}"
42
42
  }
43
43
  });
44
44
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/builder",
3
- "version": "3.0.0-alpha.2",
3
+ "version": "3.0.0-alpha.3",
4
4
  "description": "UI5 Tooling - Builder",
5
5
  "author": {
6
6
  "name": "SAP SE",