@ui5/builder 2.11.0 → 3.0.0-alpha.0

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,29 @@
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.0...HEAD).
5
+ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.0...HEAD).
6
+
7
+ <a name="v3.0.0-alpha.0"></a>
8
+ ## [v3.0.0-alpha.0] - 2021-12-14
9
+ ### Bug Fixes
10
+ - **Bundler:** Sort raw modules by default [`0e11b69`](https://github.com/SAP/ui5-builder/commit/0e11b6965a1d2e63a96e9b738e38975b5ac755bc)
11
+
12
+
13
+ <a name="v2.11.2"></a>
14
+ ## [v2.11.2] - 2021-11-17
15
+ ### Bug Fixes
16
+ - **Builder:** Emit warning on bundleInfo name without extension [`ed0da12`](https://github.com/SAP/ui5-builder/commit/ed0da123ac084d126a28f0f34d9740c310d91902)
17
+ - **manifestCreator:** Trim whitespace/new-lines for sap.app/title [`019cfd7`](https://github.com/SAP/ui5-builder/commit/019cfd7031a2bd63ce93801ad027413151a3b060)
18
+
19
+
20
+ <a name="v2.11.1"></a>
21
+ ## [v2.11.1] - 2021-10-19
22
+ ### Bug Fixes
23
+ - Minification excludes for application projects [`7f6fd68`](https://github.com/SAP/ui5-builder/commit/7f6fd68e1aed9131896723f1231816287eaf2fce)
24
+
6
25
 
7
26
  <a name="v2.11.0"></a>
8
- ## [v2.11.0] - 2021-10-13
27
+ ## [v2.11.0] - 2021-10-19
9
28
  ### Bug Fixes
10
29
  - **manifestCreator:** supportedThemes should only list relevant themes [`01f3859`](https://github.com/SAP/ui5-builder/commit/01f3859070b6955b9824b0949e633c6d40244633)
11
30
 
@@ -620,6 +639,9 @@ to load the custom bundle file instead.
620
639
  - Add ability to configure component preloads and custom bundles [`2241e5f`](https://github.com/SAP/ui5-builder/commit/2241e5ff98fd95f1f80cc74959655ae7a9c660e7)
621
640
 
622
641
 
642
+ [v3.0.0-alpha.0]: https://github.com/SAP/ui5-builder/compare/v2.11.2...v3.0.0-alpha.0
643
+ [v2.11.2]: https://github.com/SAP/ui5-builder/compare/v2.11.1...v2.11.2
644
+ [v2.11.1]: https://github.com/SAP/ui5-builder/compare/v2.11.0...v2.11.1
623
645
  [v2.11.0]: https://github.com/SAP/ui5-builder/compare/v2.10.0...v2.11.0
624
646
  [v2.10.0]: https://github.com/SAP/ui5-builder/compare/v2.9.5...v2.10.0
625
647
  [v2.9.5]: https://github.com/SAP/ui5-builder/compare/v2.9.4...v2.9.5
@@ -1,5 +1,7 @@
1
1
  const ResourceTagCollection = require("@ui5/fs").ResourceTagCollection;
2
2
 
3
+ // Note: When adding standard tags, always update the public documentation in TaskUtil
4
+ // (Type "module:@ui5/builder.tasks.TaskUtil~StandardBuildTags")
3
5
  const STANDARD_TAGS = Object.freeze({
4
6
  OmitFromBuildResult: "ui5:OmitFromBuildResult",
5
7
  IsBundle: "ui5:IsBundle"
@@ -2,6 +2,7 @@
2
2
  // for consistency of write calls, we generally allow template literals
3
3
  "use strict";
4
4
 
5
+ const path = require("path");
5
6
  const terser = require("terser");
6
7
  const {pd} = require("pretty-data");
7
8
  const {parseJS, Syntax} = require("../utils/parseUtils");
@@ -486,6 +487,11 @@ class BundleBuilder {
486
487
  if (!section.name) {
487
488
  throw new Error(`A 'bundleInfo' section is missing the mandatory 'name' property.` );
488
489
  }
490
+ if (!path.extname(section.name)) {
491
+ log.warn(`bundleInfo section name '${section.name}' is missing a file extension. ` +
492
+ `The info might not work as expected. ` +
493
+ `The name must match the bundle filename (incl. extension such as '.js')`);
494
+ }
489
495
  this.outW.write(`"${section.name}":[${section.modules.map(makeStringLiteral).join(",")}]`);
490
496
  });
491
497
  this.outW.writeln();
@@ -289,7 +289,7 @@ class BundleResolver {
289
289
 
290
290
  return collectModulesForSection(section).
291
291
  then( (modules) => {
292
- if ( section.mode == SectionType.Raw && section.sort ) {
292
+ if ( section.mode == SectionType.Raw && section.sort !== false ) {
293
293
  // sort the modules in topological order
294
294
  return topologicalSort(pool, modules).then( (modules) => {
295
295
  log.verbose(" resolved modules (sorted): %s", modules);
@@ -237,7 +237,7 @@ async function createManifest(libraryResource, libBundle, descriptorVersion, _in
237
237
  if ( library.getDocumentation() ) {
238
238
  let desc = library.getDocumentation();
239
239
  // remove all tags
240
- desc = desc.replace(/\\s+/g, " ").replace(/<\/?[a-zA-Z][a-zA-Z0-9_$.]*(\s[^>]*)>/g, "");
240
+ desc = desc.replace(/\s+/g, " ").replace(/<\/?[a-zA-Z][a-zA-Z0-9_$.]*(\s[^>]*)>/g, "");
241
241
  // extract summary (first sentence)
242
242
  const m = /^([\w\W]+?[.;!?])[^a-zA-Z0-9_$]/.exec(desc);
243
243
  return m ? m[1] : desc;
@@ -20,6 +20,8 @@ class TaskUtil {
20
20
  * @typedef {object} module:@ui5/builder.tasks.TaskUtil~StandardBuildTags
21
21
  * @property {string} OmitFromBuildResult
22
22
  * Setting this tag to true for a resource will prevent it from being written to the build target
23
+ * @property {string} IsBundle
24
+ * This tag identifies resources that contain (i.e. bundle) multiple other resources
23
25
  */
24
26
 
25
27
  /**
@@ -54,8 +54,12 @@ module.exports = async function({
54
54
  */
55
55
  let availableLibraries;
56
56
  if (pAvailableLibraries) {
57
- availableLibraries = (await pAvailableLibraries).map((resource) => {
58
- return resource.getPath().replace(/[^/]*\.library/i, "");
57
+ availableLibraries = [];
58
+ (await pAvailableLibraries).forEach((resource) => {
59
+ const library = path.dirname(resource.getPath());
60
+ if (!availableLibraries.includes(library)) {
61
+ availableLibraries.push(library);
62
+ }
59
63
  });
60
64
  }
61
65
  let availableThemes;
@@ -280,59 +280,59 @@ module.exports = function({workspace, dependencies, taskUtil, options: {projectN
280
280
  return combo.byGlob("/**/*.{js,json,xml,html,properties,library}").then((resources) => {
281
281
  // Find all libraries and create a library-preload.js bundle
282
282
 
283
- let p;
283
+ let p = Promise.resolve();
284
284
 
285
- // Create sap-ui-core.js
286
- // TODO: move to config of actual core project
285
+ // Create core bundles for older versions (<1.97.0) which don't define bundle configuration in the ui5.yaml
286
+ // See: https://github.com/SAP/openui5/commit/ff127fd2d009162ea43ad312dec99d759ebc23a0
287
287
  if (projectName === "sap.ui.core") {
288
- // Filter out sap-ui-core.js from further uglification/replacement processors
289
- // to prevent them from overwriting it
290
- resources = resources.filter((resource) => {
291
- return resource.getPath() !== "/resources/sap-ui-core.js";
292
- });
293
-
294
- const isEvo = resources.find((resource) => {
295
- return resource.getPath() === "/resources/ui5loader.js";
296
- });
297
- let filters;
298
- if (isEvo) {
299
- filters = ["ui5loader-autoconfig.js"];
300
- } else {
301
- filters = ["jquery.sap.global.js"];
302
- }
303
-
304
- p = Promise.all([
305
- moduleBundler({
306
- options: getModuleBundlerOptions({name: "sap-ui-core.js", filters, preload: true}),
307
- resources
308
- }),
309
- moduleBundler({
310
- options: getModuleBundlerOptions({name: "sap-ui-core-dbg.js", filters, preload: false}),
311
- resources
312
- }),
313
- moduleBundler({
314
- options: getModuleBundlerOptions({
315
- name: "sap-ui-core-nojQuery.js", filters, preload: true, provided: true
288
+ const coreProject = resources[0]._project;
289
+ const coreSpecVersion = coreProject && coreProject.specVersion;
290
+ // Instead of checking the sap.ui.core library version, the specVersion is checked against all versions
291
+ // that have been defined for sap.ui.core before the bundle configuration has been introduced.
292
+ // This is mainly to have an easier check without version parsing or using semver.
293
+ // If no project/specVersion is available, the bundles should also be created to not break potential
294
+ // existing use cases without a properly formed/formatted project tree.
295
+ if (!coreSpecVersion || ["0.1", "1.1", "2.0"].includes(coreSpecVersion)) {
296
+ const isEvo = resources.find((resource) => {
297
+ return resource.getPath() === "/resources/ui5loader.js";
298
+ });
299
+ let filters;
300
+ if (isEvo) {
301
+ filters = ["ui5loader-autoconfig.js"];
302
+ } else {
303
+ filters = ["jquery.sap.global.js"];
304
+ }
305
+ p = Promise.all([
306
+ moduleBundler({
307
+ options: getModuleBundlerOptions({name: "sap-ui-core.js", filters, preload: true}),
308
+ resources
316
309
  }),
317
- resources
318
- }),
319
- moduleBundler({
320
- options: getModuleBundlerOptions({
321
- name: "sap-ui-core-nojQuery-dbg.js", filters, preload: false, provided: true
310
+ moduleBundler({
311
+ options: getModuleBundlerOptions({name: "sap-ui-core-dbg.js", filters, preload: false}),
312
+ resources
322
313
  }),
323
- resources
324
- }),
325
- ]).then((results) => {
326
- const bundles = Array.prototype.concat.apply([], results);
327
- return Promise.all(bundles.map((bundle) => {
328
- if (taskUtil) {
329
- taskUtil.setTag(bundle, taskUtil.STANDARD_TAGS.IsBundle);
330
- }
331
- return workspace.write(bundle);
332
- }));
333
- });
334
- } else {
335
- p = Promise.resolve();
314
+ moduleBundler({
315
+ options: getModuleBundlerOptions({
316
+ name: "sap-ui-core-nojQuery.js", filters, preload: true, provided: true
317
+ }),
318
+ resources
319
+ }),
320
+ moduleBundler({
321
+ options: getModuleBundlerOptions({
322
+ name: "sap-ui-core-nojQuery-dbg.js", filters, preload: false, provided: true
323
+ }),
324
+ resources
325
+ }),
326
+ ]).then((results) => {
327
+ const bundles = Array.prototype.concat.apply([], results);
328
+ return Promise.all(bundles.map((bundle) => {
329
+ if (taskUtil) {
330
+ taskUtil.setTag(bundle, taskUtil.STANDARD_TAGS.IsBundle);
331
+ }
332
+ return workspace.write(bundle);
333
+ }));
334
+ });
335
+ }
336
336
  }
337
337
 
338
338
  return p.then(() => {
@@ -18,7 +18,7 @@ module.exports = function({workspace, options: {pattern, version}}) {
18
18
  return stringReplacer({
19
19
  resources: allResources,
20
20
  options: {
21
- pattern: "${version}",
21
+ pattern: /\$\{(?:project\.)?version\}/g,
22
22
  replacement: version
23
23
  }
24
24
  });
@@ -143,7 +143,9 @@ class ApplicationBuilder extends AbstractBuilder {
143
143
  const minificationExcludes = project.builder && project.builder.minification &&
144
144
  project.builder.minification.excludes;
145
145
  if (minificationExcludes) {
146
- this.enhancePatternWithExcludes(minificationPattern, minificationExcludes, "/");
146
+ // TODO 3.0: namespaces should become mandatory, see existing check above
147
+ const patternPrefix = project.metadata.namespace ? "/resources/" : "/";
148
+ this.enhancePatternWithExcludes(minificationPattern, minificationExcludes, patternPrefix);
147
149
  }
148
150
  }
149
151
  this.addTask("createDebugFiles", async () => {
@@ -176,7 +176,7 @@ class LibraryBuilder extends AbstractBuilder {
176
176
  dependencies: resourceCollections.dependencies,
177
177
  options: {
178
178
  projectName: project.metadata.name,
179
- librariesPattern: !taskUtil.isRootProject() ? "/resources/**/*.library" : undefined,
179
+ librariesPattern: !taskUtil.isRootProject() ? "/resources/**/(*.library|library.js)" : undefined,
180
180
  themesPattern: !taskUtil.isRootProject() ? "/resources/sap/ui/core/themes/*" : undefined,
181
181
  inputPattern
182
182
  }
@@ -29,7 +29,7 @@ class ThemeLibraryBuilder extends AbstractBuilder {
29
29
  dependencies: resourceCollections.dependencies,
30
30
  options: {
31
31
  projectName: project.metadata.name,
32
- librariesPattern: !taskUtil.isRootProject() ? "/resources/**/*.library" : undefined,
32
+ librariesPattern: !taskUtil.isRootProject() ? "/resources/**/(*.library|library.js)" : undefined,
33
33
  themesPattern: !taskUtil.isRootProject() ? "/resources/sap/ui/core/themes/*" : undefined,
34
34
  inputPattern: "/resources/**/themes/*/library.source.less"
35
35
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/builder",
3
- "version": "2.11.0",
3
+ "version": "3.0.0-alpha.0",
4
4
  "description": "UI5 Tooling - Builder",
5
5
  "author": {
6
6
  "name": "SAP SE",
@@ -104,8 +104,8 @@
104
104
  "url": "git@github.com:SAP/ui5-builder.git"
105
105
  },
106
106
  "dependencies": {
107
- "@ui5/fs": "^2.0.6",
108
- "@ui5/logger": "^2.0.1",
107
+ "@ui5/fs": "^3.0.0-alpha.0",
108
+ "@ui5/logger": "^3.0.0-alpha.0",
109
109
  "cheerio": "1.0.0-rc.9",
110
110
  "escape-unicode": "^0.2.0",
111
111
  "escope": "^3.6.0",
@@ -120,7 +120,7 @@
120
120
  "replacestream": "^4.0.3",
121
121
  "rimraf": "^3.0.2",
122
122
  "semver": "^7.3.5",
123
- "terser": "^5.9.0",
123
+ "terser": "^5.10.0",
124
124
  "xml2js": "^0.4.23",
125
125
  "yazl": "^2.5.1"
126
126
  },
@@ -134,7 +134,7 @@
134
134
  "docdash": "^1.2.0",
135
135
  "eslint": "^7.32.0",
136
136
  "eslint-config-google": "^0.14.0",
137
- "eslint-plugin-jsdoc": "^36.1.1",
137
+ "eslint-plugin-jsdoc": "^37.2.0",
138
138
  "extract-zip": "^2.0.1",
139
139
  "mock-require": "^3.0.3",
140
140
  "nyc": "^15.1.0",