@ui5/builder 4.0.6 → 4.0.7

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,13 @@
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/v4.0.6...HEAD).
5
+ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-builder/compare/v4.0.7...HEAD).
6
+
7
+ <a name="v4.0.7"></a>
8
+ ## [v4.0.7] - 2025-05-18
9
+ ### Bug Fixes
10
+ - **manifestEnhancer:** Only use valid files for supportedLocales ([#1080](https://github.com/SAP/ui5-builder/issues/1080)) [`a6c04d2`](https://github.com/SAP/ui5-builder/commit/a6c04d26ae964566c82e82d1be2ef6a7fd836530)
11
+
6
12
 
7
13
  <a name="v4.0.6"></a>
8
14
  ## [v4.0.6] - 2025-04-29
@@ -951,6 +957,7 @@ to load the custom bundle file instead.
951
957
 
952
958
  ### Features
953
959
  - Add ability to configure component preloads and custom bundles [`2241e5f`](https://github.com/SAP/ui5-builder/commit/2241e5ff98fd95f1f80cc74959655ae7a9c660e7)
960
+ [v4.0.7]: https://github.com/SAP/ui5-builder/compare/v4.0.6...v4.0.7
954
961
  [v4.0.6]: https://github.com/SAP/ui5-builder/compare/v4.0.5...v4.0.6
955
962
  [v4.0.5]: https://github.com/SAP/ui5-builder/compare/v4.0.4...v4.0.5
956
963
  [v4.0.4]: https://github.com/SAP/ui5-builder/compare/v4.0.3...v4.0.4
@@ -7,6 +7,58 @@ const log = getLogger("builder:processors:manifestEnhancer");
7
7
 
8
8
  const APP_DESCRIPTOR_V22 = new Version("1.21.0");
9
9
 
10
+ /*
11
+ * Matches a legacy Java locale string, which is the format used by the UI5 Runtime (ResourceBundle)
12
+ * to load i18n properties files.
13
+ * Special case: "sr_Latn" is also supported, although the BCP47 script part is not supported by the Java locale format.
14
+ *
15
+ * Variants are limited to the format from BCP47, but with underscores instead of hyphens.
16
+ */
17
+ // [ language ] [ region ][ variants ]
18
+ const rLegacyJavaLocale = /^([a-z]{2,3}|sr_Latn)(?:_([A-Z]{2}|\d{3})((?:_[0-9a-zA-Z]{5,8}|_[0-9][0-9a-zA-Z]{3})*)?)?$/;
19
+
20
+ // See https://github.com/SAP/openui5/blob/d7ecf2792788719d35b4eee3085a327d545bab24/src/sap.ui.core/src/sap/base/i18n/LanguageFallback.js#L10
21
+ const sapSupportabilityVariants = ["saptrc", "sappsd", "saprigi"];
22
+
23
+ function getBCP47LocaleFromPropertiesFilename(locale) {
24
+ const match = rLegacyJavaLocale.exec(locale);
25
+ if (!match) {
26
+ return null;
27
+ }
28
+ let [, language, region, variants] = match;
29
+ let script;
30
+
31
+ variants = variants?.slice(1); // Remove leading underscore
32
+
33
+ // Special handling of sr_Latn (see regex above)
34
+ // Note: This needs to be in sync with the runtime logic:
35
+ // https://github.com/SAP/openui5/blob/d7ecf2792788719d35b4eee3085a327d545bab24/src/sap.ui.core/src/sap/base/i18n/LanguageFallback.js#L87
36
+ if (language === "sr_Latn") {
37
+ language = "sr";
38
+ script = "Latn";
39
+ }
40
+
41
+ if (language === "en" && region === "US" && sapSupportabilityVariants.includes(variants)) {
42
+ // Convert to private use section
43
+ // Note: This needs to be in sync with the runtime logic:
44
+ // https://github.com/SAP/openui5/blob/d7ecf2792788719d35b4eee3085a327d545bab24/src/sap.ui.core/src/sap/base/i18n/LanguageFallback.js#L75
45
+ variants = `x-${variants}`;
46
+ }
47
+
48
+ let bcp47Locale = language;
49
+ if (script) {
50
+ bcp47Locale += `-${script}`;
51
+ }
52
+ if (region) {
53
+ bcp47Locale += `-${region}`;
54
+ }
55
+ if (variants) {
56
+ // Convert to BCP47 variant format
57
+ bcp47Locale += `-${variants.replace(/_/g, "-")}`;
58
+ }
59
+ return bcp47Locale;
60
+ }
61
+
10
62
  function isAbsoluteUrl(url) {
11
63
  if (url.startsWith("/")) {
12
64
  return true;
@@ -132,6 +184,8 @@ class ManifestEnhancer {
132
184
 
133
185
  this.isModified = false;
134
186
  this.runInvoked = false;
187
+
188
+ this.supportedLocalesCache = new Map();
135
189
  }
136
190
 
137
191
  markModified() {
@@ -151,7 +205,14 @@ class ManifestEnhancer {
151
205
  }
152
206
  }
153
207
 
154
- async findSupportedLocales(i18nBundleUrl) {
208
+ findSupportedLocales(i18nBundleUrl) {
209
+ if (!this.supportedLocalesCache.has(i18nBundleUrl)) {
210
+ this.supportedLocalesCache.set(i18nBundleUrl, this._findSupportedLocales(i18nBundleUrl));
211
+ }
212
+ return this.supportedLocalesCache.get(i18nBundleUrl);
213
+ }
214
+
215
+ async _findSupportedLocales(i18nBundleUrl) {
155
216
  const i18nBundleName = path.basename(i18nBundleUrl, ".properties");
156
217
  const i18nBundlePrefix = `${i18nBundleName}_`;
157
218
  const i18nBundleDir = path.dirname(i18nBundleUrl);
@@ -165,8 +226,13 @@ class ManifestEnhancer {
165
226
  if (fileNameWithoutExtension === i18nBundleName) {
166
227
  supportedLocales.push("");
167
228
  } else if (fileNameWithoutExtension.startsWith(i18nBundlePrefix)) {
168
- const locale = fileNameWithoutExtension.replace(i18nBundlePrefix, "");
169
- supportedLocales.push(locale);
229
+ const fileNameLocale = fileNameWithoutExtension.replace(i18nBundlePrefix, "");
230
+ const bcp47Locale = getBCP47LocaleFromPropertiesFilename(fileNameLocale);
231
+ if (bcp47Locale) {
232
+ supportedLocales.push(bcp47Locale);
233
+ } else {
234
+ log.warn(`Ignoring unexpected locale in filename '${fileName}' for bundle '${i18nBundleUrl}'`);
235
+ }
170
236
  }
171
237
  });
172
238
  return supportedLocales.sort();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/builder",
3
- "version": "4.0.6",
3
+ "version": "4.0.7",
4
4
  "description": "UI5 Tooling - Builder",
5
5
  "author": {
6
6
  "name": "SAP SE",
@@ -132,8 +132,8 @@
132
132
  "jsdoc": "^4.0.4",
133
133
  "less-openui5": "^0.11.6",
134
134
  "pretty-data": "^0.40.0",
135
- "semver": "^7.7.1",
136
- "terser": "^5.39.0",
135
+ "semver": "^7.7.2",
136
+ "terser": "^5.39.2",
137
137
  "workerpool": "^9.2.0",
138
138
  "xml2js": "^0.6.2"
139
139
  },
@@ -142,17 +142,17 @@
142
142
  "@istanbuljs/esm-loader-hook": "^0.3.0",
143
143
  "@jridgewell/trace-mapping": "^0.3.25",
144
144
  "@ui5/project": "^4.0.4",
145
- "ava": "^6.2.0",
145
+ "ava": "^6.3.0",
146
146
  "chokidar-cli": "^3.0.0",
147
147
  "cross-env": "^7.0.3",
148
148
  "depcheck": "^1.4.7",
149
149
  "docdash": "^2.0.2",
150
- "eslint": "^9.25.1",
150
+ "eslint": "^9.27.0",
151
151
  "eslint-config-google": "^0.14.0",
152
152
  "eslint-plugin-ava": "^15.0.1",
153
- "eslint-plugin-jsdoc": "^50.6.11",
153
+ "eslint-plugin-jsdoc": "^50.6.17",
154
154
  "esmock": "^2.7.0",
155
- "globals": "^16.0.0",
155
+ "globals": "^16.1.0",
156
156
  "line-column": "^1.0.2",
157
157
  "nyc": "^17.1.0",
158
158
  "open-cli": "^8.0.0",