@ui5/builder 2.11.4 → 3.0.0-alpha.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 (38) hide show
  1. package/CHANGELOG.md +52 -9
  2. package/index.js +4 -16
  3. package/jsdoc.json +0 -1
  4. package/lib/builder/BuildContext.js +17 -0
  5. package/lib/builder/ProjectBuildContext.js +9 -7
  6. package/lib/builder/builder.js +1 -2
  7. package/lib/lbt/analyzer/JSModuleAnalyzer.js +18 -3
  8. package/lib/lbt/analyzer/XMLTemplateAnalyzer.js +2 -1
  9. package/lib/lbt/bundle/AutoSplitter.js +10 -24
  10. package/lib/lbt/bundle/Builder.js +363 -134
  11. package/lib/lbt/bundle/BundleWriter.js +17 -0
  12. package/lib/lbt/bundle/Resolver.js +1 -1
  13. package/lib/lbt/resources/LocatorResource.js +9 -7
  14. package/lib/lbt/resources/LocatorResourcePool.js +8 -4
  15. package/lib/lbt/resources/Resource.js +7 -0
  16. package/lib/lbt/resources/ResourceCollector.js +33 -15
  17. package/lib/lbt/utils/parseUtils.js +1 -1
  18. package/lib/processors/bundlers/moduleBundler.js +39 -14
  19. package/lib/processors/minifier.js +89 -0
  20. package/lib/processors/resourceListCreator.js +2 -16
  21. package/lib/tasks/TaskUtil.js +9 -9
  22. package/lib/tasks/bundlers/generateBundle.js +92 -6
  23. package/lib/tasks/bundlers/generateComponentPreload.js +20 -6
  24. package/lib/tasks/bundlers/generateLibraryPreload.js +77 -10
  25. package/lib/tasks/bundlers/generateStandaloneAppBundle.js +58 -12
  26. package/lib/tasks/generateResourcesJson.js +14 -8
  27. package/lib/tasks/minify.js +39 -0
  28. package/lib/tasks/replaceVersion.js +1 -1
  29. package/lib/tasks/taskRepository.js +6 -2
  30. package/lib/types/application/ApplicationBuilder.js +22 -31
  31. package/lib/types/library/LibraryBuilder.js +23 -29
  32. package/lib/types/themeLibrary/ThemeLibraryBuilder.js +1 -0
  33. package/package.json +15 -13
  34. package/lib/processors/debugFileCreator.js +0 -52
  35. package/lib/processors/resourceCopier.js +0 -24
  36. package/lib/processors/uglifier.js +0 -45
  37. package/lib/tasks/createDebugFiles.js +0 -30
  38. package/lib/tasks/uglify.js +0 -33
package/CHANGELOG.md CHANGED
@@ -2,18 +2,60 @@
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/v2.11.4...HEAD).
5
+ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.2...HEAD).
6
6
 
7
- <a name="v2.11.4"></a>
8
- ## [v2.11.4] - 2022-02-21
7
+ <a name="v3.0.0-alpha.2"></a>
8
+ ## [v3.0.0-alpha.2] - 2022-02-21
9
9
  ### Bug Fixes
10
- - **generateFlexChangesBundle:** Fix minUI5Version check for UI5 v1.100.0+ ([#706](https://github.com/SAP/ui5-builder/issues/706)) [`fb1217a`](https://github.com/SAP/ui5-builder/commit/fb1217ac536c20da81526f82f2ecb03686815942)
10
+ - **XMLTemplateAnalyzer:** Analyze core:require of FragmentDefinition [`af075ed`](https://github.com/SAP/ui5-builder/commit/af075edf784d9f1ba162a34f0bf150dbcbc0f479)
11
+
12
+ ### Features
13
+ - Generate source maps for bundles ([#695](https://github.com/SAP/ui5-builder/issues/695)) [`8a20c42`](https://github.com/SAP/ui5-builder/commit/8a20c4257a1ebe4d613b0595be93cd45d900f580)
14
+ - **replaceVersion/Copyright:** Also process test-resources ([#693](https://github.com/SAP/ui5-builder/issues/693)) [`a0d4bc2`](https://github.com/SAP/ui5-builder/commit/a0d4bc2a80d61e042786207af4bdbda6c3ddfe31)
15
+
16
+
17
+ <a name="v3.0.0-alpha.1"></a>
18
+ ## [v3.0.0-alpha.1] - 2022-01-25
19
+ ### Breaking Changes
20
+ - Require Node.js >= 16.13.2 / npm >= 8 [`dbf6c06`](https://github.com/SAP/ui5-builder/commit/dbf6c0694693070f73e9f96edef90f094d5bf721)
21
+ - **generateResourcesJson:** Make 'dependencies' parameter mandatory [`268dd16`](https://github.com/SAP/ui5-builder/commit/268dd16091c515ec0c922ea23af437d9aa8bf3ea)
22
+ - **moduleBundler:** Always default to `optimize: true` ([#685](https://github.com/SAP/ui5-builder/issues/685)) [`de5837c`](https://github.com/SAP/ui5-builder/commit/de5837c43449ea61deae3b2f02f9973f3fa37992)
23
+
24
+ ### Bug Fixes
25
+ - **Bundler:** Ensure reproducibility for bundles with multiple parts ([#689](https://github.com/SAP/ui5-builder/issues/689)) [`6f4588b`](https://github.com/SAP/ui5-builder/commit/6f4588b3eb687178e557ac4fb36481104f9681a0)
26
+ - **generateResourcesJson:** Don't list resources omitted from build result [`9608c51`](https://github.com/SAP/ui5-builder/commit/9608c5177f86494ba689d2e799b4378fec9ed6fa)
27
+ - **generateResourcesJson:** Analyze debug bundles ([#669](https://github.com/SAP/ui5-builder/issues/669)) [`f27513a`](https://github.com/SAP/ui5-builder/commit/f27513a259b30d39e260790781b6d435b4ab088b)
28
+
29
+ ### Features
30
+ - Support ES2021 language features [`e749b6a`](https://github.com/SAP/ui5-builder/commit/e749b6ae0838f923b27dd0d7d34da2174c433f5f)
31
+ - Add minify task and processor ([#666](https://github.com/SAP/ui5-builder/issues/666)) [`a3af604`](https://github.com/SAP/ui5-builder/commit/a3af604ff0a12fb9241dcd105cf0aec8d718a299)
32
+
33
+ ### BREAKING CHANGE
34
+
35
+ Support for older Node.js and npm releases has been dropped.
36
+ Only Node.js v16.13.2 and npm v8 or higher are supported.
37
+
38
+ The following tasks have been removed:
39
+ - createDebugFiles
40
+ - uglify
41
+
42
+ The following processors have been removed:
43
+ - debugFileCreator
44
+ - resourceCopier
45
+ - uglifier
46
+
47
+ As a replacement, the new 'minify' task and 'minifier' processor can be
48
+ used.
49
+
50
+ Note: The minify task is executed earlier, before the bundling
51
+ process takes place. Existing 'beforeTask' and 'afterTask' configuration of
52
+ custom tasks might need to be adapted to cater for this change.
11
53
 
12
54
 
13
- <a name="v2.11.3"></a>
14
- ## [v2.11.3] - 2021-12-14
55
+ <a name="v3.0.0-alpha.0"></a>
56
+ ## [v3.0.0-alpha.0] - 2021-12-14
15
57
  ### Bug Fixes
16
- - Enable buildThemes for libraries without .library [`7b941a7`](https://github.com/SAP/ui5-builder/commit/7b941a797210463a9fa8ca50753662c5db373aa6)
58
+ - **Bundler:** Sort raw modules by default [`0e11b69`](https://github.com/SAP/ui5-builder/commit/0e11b6965a1d2e63a96e9b738e38975b5ac755bc)
17
59
 
18
60
 
19
61
  <a name="v2.11.2"></a>
@@ -645,8 +687,9 @@ to load the custom bundle file instead.
645
687
  - Add ability to configure component preloads and custom bundles [`2241e5f`](https://github.com/SAP/ui5-builder/commit/2241e5ff98fd95f1f80cc74959655ae7a9c660e7)
646
688
 
647
689
 
648
- [v2.11.4]: https://github.com/SAP/ui5-builder/compare/v2.11.3...v2.11.4
649
- [v2.11.3]: https://github.com/SAP/ui5-builder/compare/v2.11.2...v2.11.3
690
+ [v3.0.0-alpha.2]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.1...v3.0.0-alpha.2
691
+ [v3.0.0-alpha.1]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.0...v3.0.0-alpha.1
692
+ [v3.0.0-alpha.0]: https://github.com/SAP/ui5-builder/compare/v2.11.2...v3.0.0-alpha.0
650
693
  [v2.11.2]: https://github.com/SAP/ui5-builder/compare/v2.11.1...v2.11.2
651
694
  [v2.11.1]: https://github.com/SAP/ui5-builder/compare/v2.11.0...v2.11.1
652
695
  [v2.11.0]: https://github.com/SAP/ui5-builder/compare/v2.10.0...v2.11.0
package/index.js CHANGED
@@ -42,9 +42,9 @@ module.exports = {
42
42
  */
43
43
  bootstrapHtmlTransformer: "./lib/processors/bootstrapHtmlTransformer",
44
44
  /**
45
- * @type {import('./lib/processors/debugFileCreator')}
45
+ * @type {import('./lib/processors/minifier')}
46
46
  */
47
- debugFileCreator: "./lib/processors/debugFileCreator",
47
+ minifier: "./lib/processors/minifier",
48
48
  /**
49
49
  * @type {import('./lib/processors/libraryLessGenerator')}
50
50
  */
@@ -53,10 +53,6 @@ module.exports = {
53
53
  * @type {import('./lib/processors/manifestCreator')}
54
54
  */
55
55
  manifestCreator: "./lib/processors/manifestCreator",
56
- /**
57
- * @type {import('./lib/processors/resourceCopier')}
58
- */
59
- resourceCopier: "./lib/processors/resourceCopier",
60
56
  /**
61
57
  * @type {import('./lib/processors/nonAsciiEscaper')}
62
58
  */
@@ -69,10 +65,6 @@ module.exports = {
69
65
  * @type {import('./lib/processors/themeBuilder')}
70
66
  */
71
67
  themeBuilder: "./lib/processors/themeBuilder",
72
- /**
73
- * @type {import('./lib/processors/uglifier')}
74
- */
75
- uglifier: "./lib/processors/uglifier",
76
68
  /**
77
69
  * @type {import('./lib/processors/versionInfoGenerator')}
78
70
  */
@@ -121,9 +113,9 @@ module.exports = {
121
113
  */
122
114
  buildThemes: "./lib/tasks/buildThemes",
123
115
  /**
124
- * @type {import('./lib/tasks/createDebugFiles')}
116
+ * @type {import('./lib/tasks/minify')}
125
117
  */
126
- createDebugFiles: "./lib/tasks/createDebugFiles",
118
+ minify: "./lib/tasks/minify",
127
119
  /**
128
120
  * @type {import('./lib/tasks/jsdoc/executeJsdocSdkTransformation')}
129
121
  */
@@ -160,10 +152,6 @@ module.exports = {
160
152
  * @type {import('./lib/tasks/transformBootstrapHtml')}
161
153
  */
162
154
  transformBootstrapHtml: "./lib/tasks/transformBootstrapHtml",
163
- /**
164
- * @type {import('./lib/tasks/uglify')}
165
- */
166
- uglify: "./lib/tasks/uglify",
167
155
  /**
168
156
  * @type {import('./lib/tasks/taskRepository')}
169
157
  */
package/jsdoc.json CHANGED
@@ -12,7 +12,6 @@
12
12
  "./jsdoc-plugin"
13
13
  ],
14
14
  "opts": {
15
- "template": "node_modules/docdash/",
16
15
  "encoding": "utf8",
17
16
  "destination": "jsdocs/",
18
17
  "recurse": true,
@@ -1,5 +1,13 @@
1
+ const ResourceTagCollection = require("@ui5/fs").ResourceTagCollection;
1
2
  const ProjectBuildContext = require("./ProjectBuildContext");
2
3
 
4
+ // Note: When adding standard tags, always update the public documentation in TaskUtil
5
+ // (Type "module:@ui5/builder.tasks.TaskUtil~StandardBuildTags")
6
+ const GLOBAL_TAGS = Object.freeze({
7
+ IsDebugVariant: "ui5:IsDebugVariant",
8
+ HasDebugVariant: "ui5:HasDebugVariant",
9
+ });
10
+
3
11
  /**
4
12
  * Context of a build process
5
13
  *
@@ -13,6 +21,10 @@ class BuildContext {
13
21
  }
14
22
  this.rootProject = rootProject;
15
23
  this.projectBuildContexts = [];
24
+
25
+ this._resourceTagCollection = new ResourceTagCollection({
26
+ allowedTags: Object.values(GLOBAL_TAGS)
27
+ });
16
28
  }
17
29
 
18
30
  getRootProject() {
@@ -22,6 +34,7 @@ class BuildContext {
22
34
  createProjectContext({project, resources}) {
23
35
  const projectBuildContext = new ProjectBuildContext({
24
36
  buildContext: this,
37
+ globalTags: GLOBAL_TAGS,
25
38
  project,
26
39
  resources
27
40
  });
@@ -34,6 +47,10 @@ class BuildContext {
34
47
  return ctx.executeCleanupTasks();
35
48
  }));
36
49
  }
50
+
51
+ getResourceTagCollection() {
52
+ return this._resourceTagCollection;
53
+ }
37
54
  }
38
55
 
39
56
  module.exports = BuildContext;
@@ -2,10 +2,10 @@ const ResourceTagCollection = require("@ui5/fs").ResourceTagCollection;
2
2
 
3
3
  // Note: When adding standard tags, always update the public documentation in TaskUtil
4
4
  // (Type "module:@ui5/builder.tasks.TaskUtil~StandardBuildTags")
5
- const STANDARD_TAGS = Object.freeze({
5
+ const STANDARD_TAGS = {
6
6
  OmitFromBuildResult: "ui5:OmitFromBuildResult",
7
- IsBundle: "ui5:IsBundle"
8
- });
7
+ IsBundle: "ui5:IsBundle",
8
+ };
9
9
 
10
10
  /**
11
11
  * Build context of a single project. Always part of an overall
@@ -15,8 +15,8 @@ const STANDARD_TAGS = Object.freeze({
15
15
  * @memberof module:@ui5/builder.builder
16
16
  */
17
17
  class ProjectBuildContext {
18
- constructor({buildContext, project, resources}) {
19
- if (!buildContext || !project || !resources) {
18
+ constructor({buildContext, globalTags, project, resources}) {
19
+ if (!buildContext || !globalTags || !project || !resources) {
20
20
  throw new Error(`One or more mandatory parameters are missing`);
21
21
  }
22
22
  this._buildContext = buildContext;
@@ -26,10 +26,12 @@ class ProjectBuildContext {
26
26
  cleanup: []
27
27
  };
28
28
 
29
- this.STANDARD_TAGS = STANDARD_TAGS;
29
+ this.STANDARD_TAGS = Object.assign({}, STANDARD_TAGS, globalTags);
30
+ Object.freeze(this.STANDARD_TAGS);
30
31
 
31
32
  this._resourceTagCollection = new ResourceTagCollection({
32
- allowedTags: Object.values(this.STANDARD_TAGS)
33
+ allowedTags: Object.values(this.STANDARD_TAGS),
34
+ superCollection: this._buildContext.getResourceTagCollection()
33
35
  });
34
36
  }
35
37
 
@@ -94,8 +94,7 @@ function composeTaskList({dev, selfContained, jsdoc, includedTasks, excludedTask
94
94
  selectedTasks.generateComponentPreload = false;
95
95
  selectedTasks.generateLibraryPreload = false;
96
96
  selectedTasks.generateLibraryManifest = false;
97
- selectedTasks.createDebugFiles = false;
98
- selectedTasks.uglify = false;
97
+ selectedTasks.minify = false;
99
98
  selectedTasks.generateFlexChangesBundle = false;
100
99
  selectedTasks.generateManifestBundle = false;
101
100
  }
@@ -64,6 +64,7 @@ const EnrichedVisitorKeys = (function() {
64
64
  BreakStatement: [],
65
65
  CallExpression: [], // special handling
66
66
  CatchClause: ["param", "body"],
67
+ ChainExpression: [],
67
68
  ClassBody: [],
68
69
  ClassDeclaration: [],
69
70
  ClassExpression: [],
@@ -125,8 +126,10 @@ const EnrichedVisitorKeys = (function() {
125
126
  * All properties in an object pattern are executed.
126
127
  */
127
128
  ObjectPattern: [], // properties
129
+ // PrivateIdentifier: [], // will come with ES2022
128
130
  Program: [],
129
131
  Property: [],
132
+ // PropertyDefinition: [], // will come with ES2022
130
133
  /*
131
134
  * argument of the rest element is always executed under the same condition as the rest element itself
132
135
  */
@@ -134,6 +137,7 @@ const EnrichedVisitorKeys = (function() {
134
137
  ReturnStatement: [],
135
138
  SequenceExpression: [],
136
139
  SpreadElement: [], // the argument of the spread operator always needs to be evaluated - argument
140
+ // StaticBlock: [], // will come with ES2022
137
141
  Super: [],
138
142
  SwitchStatement: [],
139
143
  SwitchCase: ["test", "consequent"], // test and consequent are executed only conditionally
@@ -171,9 +175,11 @@ const EnrichedVisitorKeys = (function() {
171
175
 
172
176
  // merge with 'official' visitor keys
173
177
  Object.keys(VisitorKeys).forEach( (type) => {
174
- // Check if the visitor-key exists in the available Syntax because
175
- // the list of visitor-keys does not match the available Syntax.
176
- if (!Syntax[type]) {
178
+ // Ignore deprecated keys:
179
+ // - ExperimentalSpreadProperty => SpreadElement
180
+ // - ExperimentalRestProperty => RestElement
181
+ // They are about to be removed, see: https://github.com/eslint/eslint-visitor-keys/pull/36
182
+ if (type === "ExperimentalSpreadProperty" || type === "ExperimentalRestProperty") {
177
183
  return;
178
184
  }
179
185
  // Ignore JSX visitor-keys because they aren't used.
@@ -181,6 +187,15 @@ const EnrichedVisitorKeys = (function() {
181
187
  return;
182
188
  }
183
189
 
190
+ // Ignore new ES2022 syntax as we currently use ES2021 (see parseUtils.js)
191
+ if (
192
+ type === "PrivateIdentifier" ||
193
+ type === "PropertyDefinition" ||
194
+ type === "StaticBlock"
195
+ ) {
196
+ return;
197
+ }
198
+
184
199
  const visitorKeys = VisitorKeys[type];
185
200
  const condKeys = TempKeys[type];
186
201
  if ( condKeys === undefined ) {
@@ -231,9 +231,10 @@ class XMLTemplateAnalyzer {
231
231
  // looks like a UI5 library or package name
232
232
  const moduleName = ModuleName.fromUI5LegacyName( (namespace ? namespace + "." : "") + localName );
233
233
 
234
+ this._analyzeCoreRequire(node);
235
+
234
236
  // ignore FragmentDefinition (also skipped by runtime XMLTemplateProcessor)
235
237
  if ( FRAGMENTDEFINITION_MODULE !== moduleName ) {
236
- this._analyzeCoreRequire(node);
237
238
  this.promises.push(this._analyzeModuleDependency(node, moduleName, this.conditional));
238
239
  }
239
240
  }
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- const terser = require("terser");
4
3
  const {pd} = require("pretty-data");
5
4
 
6
5
  const ModuleName = require("../utils/ModuleName");
@@ -8,7 +7,6 @@ const {SectionType} = require("./BundleDefinition");
8
7
  const escapePropertiesFile = require("../utils/escapePropertiesFile");
9
8
  const log = require("@ui5/logger").getLogger("lbt:bundle:AutoSplitter");
10
9
 
11
- const copyrightCommentsPattern = /copyright|\(c\)(?:[0-9]+|\s+[0-9A-za-z])|released under|license|\u00a9/i;
12
10
  const xmlHtmlPrePattern = /<(?:\w+:)?pre\b/;
13
11
 
14
12
  /**
@@ -112,6 +110,7 @@ class AutoSplitter {
112
110
 
113
111
  resolvedModule.sections.forEach( (section) => {
114
112
  let currentSection;
113
+ let sequence;
115
114
  switch ( section.mode ) {
116
115
  case SectionType.Provided:
117
116
  // 'provided' sections are no longer needed in a fully resolved module
@@ -131,16 +130,20 @@ class AutoSplitter {
131
130
  });
132
131
  break;
133
132
  case SectionType.Preload:
133
+ sequence = section.modules.slice();
134
+ // simple version: just sort alphabetically
135
+ sequence.sort();
136
+
134
137
  // NODE_TODO: sort by copyright:
135
- // sequence = section.modules.slice();
136
138
  // jsBuilder.beforeWriteFunctionPreloadSection((List<ModuleName>) sequence);
139
+
137
140
  currentSection = {
138
141
  mode: SectionType.Preload,
139
142
  filters: []
140
143
  };
141
144
  currentSection.name = section.name;
142
145
  currentModule.sections.push( currentSection );
143
- section.modules.forEach( (module) => {
146
+ sequence.forEach( (module) => {
144
147
  const moduleSize = moduleSizes[module];
145
148
  if ( part + 1 < numberOfParts && totalSize + moduleSize / 2 > partSize ) {
146
149
  part++;
@@ -195,26 +198,9 @@ class AutoSplitter {
195
198
  }
196
199
 
197
200
  if ( /\.js$/.test(module) ) {
198
- // console.log("determining compressed size for %s", module);
199
- let fileContent = await resource.buffer();
200
- if ( this.optimize ) {
201
- // console.log("uglify %s start", module);
202
- const result = await terser.minify({
203
- [resource.name]: String(fileContent)
204
- }, {
205
- warnings: false, // TODO configure?
206
- compress: false, // TODO configure?
207
- output: {
208
- comments: copyrightCommentsPattern,
209
- wrap_func_args: false
210
- }
211
- // , outFileName: resource.name
212
- // , outSourceMap: true
213
- });
214
- // console.log("uglify %s end", module);
215
- fileContent = result.code;
216
- }
217
- // trace.debug("analyzed %s:%d%n", module, mw.getTargetLength());
201
+ // No optimize / minify step here as the input should be
202
+ // either already optimized or not, based on the bundle options
203
+ const fileContent = await resource.buffer();
218
204
  return fileContent.length;
219
205
  } else if ( /\.properties$/.test(module) ) {
220
206
  /* NODE-TODO minimize *.properties