@ui5/builder 3.5.1 → 4.0.1

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 (32) hide show
  1. package/CHANGELOG.md +47 -3
  2. package/CONTRIBUTING.md +1 -1
  3. package/README.md +6 -6
  4. package/jsdoc.json +7 -2
  5. package/lib/lbt/bundle/Builder.js +155 -113
  6. package/lib/lbt/bundle/ResolvedBundleDefinition.js +11 -17
  7. package/lib/processors/bundlers/moduleBundler.js +19 -8
  8. package/lib/processors/jsdoc/apiIndexGenerator.js +1 -1
  9. package/lib/processors/jsdoc/jsdocGenerator.js +4 -11
  10. package/lib/processors/jsdoc/lib/package.json +3 -0
  11. package/lib/processors/jsdoc/lib/ui5/template/{publish.cjs → publish.js} +1 -1
  12. package/lib/processors/jsdoc/sdkTransformer.js +1 -1
  13. package/lib/processors/manifestEnhancer.js +425 -0
  14. package/lib/processors/minifier.js +5 -1
  15. package/lib/tasks/buildThemes.js +4 -0
  16. package/lib/tasks/bundlers/generateBundle.js +11 -2
  17. package/lib/tasks/bundlers/generateComponentPreload.js +15 -8
  18. package/lib/tasks/bundlers/generateFlexChangesBundle.js +1 -2
  19. package/lib/tasks/bundlers/generateLibraryPreload.js +11 -8
  20. package/lib/tasks/bundlers/generateStandaloneAppBundle.js +40 -21
  21. package/lib/tasks/bundlers/utils/applyDefaultsToBundleDefinition.js +35 -0
  22. package/lib/tasks/enhanceManifest.js +32 -0
  23. package/lib/tasks/generateCachebusterInfo.js +1 -2
  24. package/lib/tasks/generateThemeDesignerResources.js +1 -2
  25. package/lib/tasks/generateVersionInfo.js +3 -1
  26. package/lib/tasks/taskRepository.js +2 -1
  27. package/lib/tasks/transformBootstrapHtml.js +2 -3
  28. package/package.json +20 -21
  29. /package/lib/processors/jsdoc/lib/{createIndexFiles.cjs → createIndexFiles.js} +0 -0
  30. /package/lib/processors/jsdoc/lib/{transformApiJson.cjs → transformApiJson.js} +0 -0
  31. /package/lib/processors/jsdoc/lib/ui5/{plugin.cjs → plugin.js} +0 -0
  32. /package/lib/processors/jsdoc/lib/ui5/template/utils/{versionUtil.cjs → versionUtil.js} +0 -0
@@ -1,6 +1,7 @@
1
1
  import {getLogger} from "@ui5/logger";
2
2
  const log = getLogger("builder:tasks:bundlers:generateLibraryPreload");
3
3
  import moduleBundler from "../../processors/bundlers/moduleBundler.js";
4
+ import {applyDefaultsToBundleDefinition} from "./utils/applyDefaultsToBundleDefinition.js";
4
5
  import {negateFilters} from "../../lbt/resources/ResourceFilterList.js";
5
6
  import createModuleNameMapping from "./utils/createModuleNameMapping.js";
6
7
 
@@ -34,9 +35,9 @@ function getDefaultLibraryPreloadFilters(namespace, excludes) {
34
35
  function getBundleDefinition(namespace, excludes) {
35
36
  // Note: This configuration is only used when no bundle definition in ui5.yaml exists (see "skipBundles" parameter)
36
37
 
37
- // TODO: Remove this hardcoded bundle definition.
38
+ // TODO: Remove this hardcoded bundle definition once support for relevant versions has ended.
38
39
  // sap.ui.core ui5.yaml contains a configuration since UI5 1.103.0 (specVersion 2.4)
39
- // so this is still required to build UI5 versions <= 1.102.0.
40
+ // so this is still required to build UI5 versions <= 1.102.0 (such as 1.84 and 1.96)
40
41
  if (namespace === "sap/ui/core") {
41
42
  return {
42
43
  name: `${namespace}/library-preload.js`,
@@ -164,8 +165,7 @@ function getModuleBundlerOptions(config) {
164
165
  moduleBundlerOptions.bundleOptions = {
165
166
  optimize: config.preload,
166
167
  decorateBootstrapModule: config.preload,
167
- addTryCatchRestartWrapper: config.preload,
168
- usePredefineCalls: config.preload
168
+ addTryCatchRestartWrapper: config.preload
169
169
  };
170
170
 
171
171
  moduleBundlerOptions.bundleDefinition = getSapUiCoreBunDef(config.name, config.filters, config.preload);
@@ -256,12 +256,18 @@ export default async function({workspace, taskUtil, options: {skipBundles = [],
256
256
  }
257
257
  });
258
258
  }
259
-
259
+ const coreVersion = taskUtil?.getProject("sap.ui.core")?.getVersion();
260
+ const allowStringBundling = taskUtil?.getProject().getSpecVersion().lt("4.0");
260
261
  const execModuleBundlerIfNeeded = ({options, resources}) => {
261
262
  if (skipBundles.includes(options.bundleDefinition.name)) {
262
263
  log.verbose(`Skipping generation of bundle ${options.bundleDefinition.name}`);
263
264
  return null;
264
265
  }
266
+ if (coreVersion) {
267
+ options.targetUi5CoreVersion = coreVersion;
268
+ }
269
+ options.bundleDefinition = applyDefaultsToBundleDefinition(options.bundleDefinition, taskUtil);
270
+ options.allowStringBundling = allowStringBundling;
265
271
  return moduleBundler({options, resources});
266
272
  };
267
273
 
@@ -390,7 +396,6 @@ export default async function({workspace, taskUtil, options: {skipBundles = [],
390
396
  bundleDefinition: getBundleDefinition(libraryNamespace, excludes),
391
397
  bundleOptions: {
392
398
  optimize: true,
393
- usePredefineCalls: true,
394
399
  ignoreMissingModules: true
395
400
  }
396
401
  },
@@ -401,7 +406,6 @@ export default async function({workspace, taskUtil, options: {skipBundles = [],
401
406
  bundleDefinition: getDesigntimeBundleDefinition(libraryNamespace),
402
407
  bundleOptions: {
403
408
  optimize: true,
404
- usePredefineCalls: true,
405
409
  ignoreMissingModules: true,
406
410
  skipIfEmpty: true
407
411
  }
@@ -413,7 +417,6 @@ export default async function({workspace, taskUtil, options: {skipBundles = [],
413
417
  bundleDefinition: getSupportFilesBundleDefinition(libraryNamespace),
414
418
  bundleOptions: {
415
419
  optimize: false,
416
- usePredefineCalls: true,
417
420
  ignoreMissingModules: true,
418
421
  skipIfEmpty: true
419
422
  }
@@ -2,6 +2,7 @@ import {getLogger} from "@ui5/logger";
2
2
  const log = getLogger("builder:tasks:bundlers:generateStandaloneAppBundle");
3
3
  import ReaderCollectionPrioritized from "@ui5/fs/ReaderCollectionPrioritized";
4
4
  import moduleBundler from "../../processors/bundlers/moduleBundler.js";
5
+ import {applyDefaultsToBundleDefinition} from "./utils/applyDefaultsToBundleDefinition.js";
5
6
  import createModuleNameMapping from "./utils/createModuleNameMapping.js";
6
7
 
7
8
  function getBundleDefinition(config) {
@@ -83,8 +84,8 @@ function getBundleDefinition(config) {
83
84
  */
84
85
  export default async function({workspace, dependencies, taskUtil, options}) {
85
86
  const {projectName} = options;
86
- // Backward compatibility: "namespace" option got renamed to "projectNamespace"
87
- const namespace = options.projectNamespace || options.namespace;
87
+ const namespace = options.projectNamespace;
88
+ const coreVersion = taskUtil?.getProject("sap.ui.core")?.getVersion();
88
89
 
89
90
  if (!namespace) {
90
91
  log.warn(`Namespace of project ${projectName} is not known. Self contained bundling is currently ` +
@@ -138,31 +139,49 @@ export default async function({workspace, dependencies, taskUtil, options}) {
138
139
  });
139
140
  }
140
141
 
142
+ const allowStringBundling = taskUtil?.getProject().getSpecVersion().lt("4.0");
143
+ const bundleOptions = {
144
+ bundleDefinition: applyDefaultsToBundleDefinition(
145
+ getBundleDefinition({
146
+ name: "sap-ui-custom.js",
147
+ filters,
148
+ namespace,
149
+ preloadSection: true,
150
+ }),
151
+ taskUtil
152
+ ),
153
+ allowStringBundling
154
+ };
155
+
156
+ const bundleDbgOptions = {
157
+ bundleDefinition: applyDefaultsToBundleDefinition(
158
+ getBundleDefinition({
159
+ name: "sap-ui-custom-dbg.js",
160
+ filters,
161
+ namespace,
162
+ }),
163
+ taskUtil
164
+ ),
165
+ bundleOptions: {
166
+ optimize: false,
167
+ },
168
+ moduleNameMapping: unoptimizedModuleNameMapping,
169
+ allowStringBundling
170
+ };
171
+
172
+ if (coreVersion) {
173
+ bundleOptions.targetUi5CoreVersion = coreVersion;
174
+ bundleDbgOptions.targetUi5CoreVersion = coreVersion;
175
+ }
176
+
141
177
  await Promise.all([
142
178
  moduleBundler({
143
179
  resources,
144
- options: {
145
- bundleDefinition: getBundleDefinition({
146
- name: "sap-ui-custom.js",
147
- filters,
148
- namespace,
149
- preloadSection: true
150
- })
151
- }
180
+ options: bundleOptions
152
181
  }),
153
182
  moduleBundler({
154
183
  resources: unoptimizedResources,
155
- options: {
156
- bundleDefinition: getBundleDefinition({
157
- name: "sap-ui-custom-dbg.js",
158
- filters,
159
- namespace
160
- }),
161
- bundleOptions: {
162
- optimize: false
163
- },
164
- moduleNameMapping: unoptimizedModuleNameMapping
165
- }
184
+ options: bundleDbgOptions
166
185
  })
167
186
  ]).then((results) => {
168
187
  const bundles = Array.prototype.concat.apply([], results);
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Applies default values to bundleDefinitions
3
+ *
4
+ * @param {module:@ui5/builder/processors/bundlers/moduleBundler~ModuleBundleDefinition} bundleDefinition Module
5
+ * bundle definition
6
+ * @param {@ui5/project/build/helpers/TaskUtil|object} [taskUtil] TaskUtil
7
+ *
8
+ * @returns {module:@ui5/builder/processors/bundlers/moduleBundler~ModuleBundleDefinition}
9
+ */
10
+ export function applyDefaultsToBundleDefinition(bundleDefinition, taskUtil) {
11
+ bundleDefinition.sections = bundleDefinition?.sections?.map((section) => {
12
+ const defaultValues = {
13
+ resolve: false,
14
+ resolveConditional: false,
15
+ renderer: false,
16
+ sort: true,
17
+ declareRawModules: false,
18
+ };
19
+
20
+ // Since specVersion: 4.0 "require" section starts loading asynchronously.
21
+ // If specVersion cannot be determined, the latest spec is taken into account.
22
+ // This is a breaking change in specVersion: 4.0
23
+ if (section.mode === "require") {
24
+ // Builder.js already treats missing async flag as truthy value and builds asynchronously by default
25
+
26
+ if (taskUtil && taskUtil.getProject().getSpecVersion().lt("4.0")) {
27
+ defaultValues.async = false;
28
+ }
29
+ }
30
+
31
+ return Object.assign(defaultValues, section);
32
+ });
33
+
34
+ return bundleDefinition;
35
+ }
@@ -0,0 +1,32 @@
1
+ import manifestEnhancer from "../processors/manifestEnhancer.js";
2
+ import fsInterface from "@ui5/fs/fsInterface";
3
+
4
+ /* eslint "jsdoc/check-param-names": ["error", {"disableExtraPropertyReporting":true}] */
5
+ /**
6
+ * Task for transforming the manifest.json file.
7
+ * Adds missing information based on the available project resources,
8
+ * for example the locales supported by the present i18n resources.
9
+ *
10
+ * @public
11
+ * @function default
12
+ * @static
13
+ *
14
+ * @param {object} parameters Parameters
15
+ * @param {@ui5/fs/DuplexCollection} parameters.workspace DuplexCollection to read and write files
16
+ * @param {object} parameters.options Options
17
+ * @param {string} parameters.options.projectNamespace Namespace of the application
18
+ * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
19
+ */
20
+ export default async function({workspace, options}) {
21
+ const {projectNamespace} = options;
22
+
23
+ // Note: all "manifest.json" files in the given namespace
24
+ const resources = await workspace.byGlob(`/resources/${projectNamespace}/**/manifest.json`);
25
+
26
+ const processedResources = await manifestEnhancer({
27
+ resources,
28
+ fs: fsInterface(workspace),
29
+ });
30
+
31
+ await Promise.all(processedResources.map((resource) => workspace.write(resource)));
32
+ }
@@ -51,8 +51,7 @@ function getSigner(type) {
51
51
  */
52
52
  export default function({workspace, options}) {
53
53
  const {signatureType} = options;
54
- // Backward compatibility: "namespace" option got renamed to "projectNamespace"
55
- const namespace = options.projectNamespace || options.namespace;
54
+ const namespace = options.projectNamespace;
56
55
 
57
56
  const basePath = `/resources/${namespace}/`;
58
57
  return workspace.byGlob(`/resources/${namespace}/**/*`)
@@ -221,8 +221,7 @@ async function generateCssVariablesLess({workspace, combo, namespace}) {
221
221
  */
222
222
  export default async function({workspace, dependencies, options}) {
223
223
  const {projectName, version} = options;
224
- // Backward compatibility: "namespace" option got renamed to "projectNamespace"
225
- const namespace = options.projectNamespace || options.namespace;
224
+ const namespace = options.projectNamespace;
226
225
 
227
226
  // Skip sap.ui.documentation since it is not intended to be available in SAP Theme Designer to create custom themes
228
227
  if (namespace === "sap/ui/documentation") {
@@ -23,7 +23,9 @@ const MANIFEST_JSON = "manifest.json";
23
23
  * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
24
24
  */
25
25
  export default async ({workspace, dependencies, options: {rootProject, pattern}}) => {
26
- const resources = await dependencies.byGlob(pattern);
26
+ let resources = await dependencies.byGlob(pattern);
27
+
28
+ resources = resources.filter((res) => res.getProject()?.getType() === "library");
27
29
 
28
30
  const libraryInfosPromises = resources.map((dotLibResource) => {
29
31
  const namespace = dotLibResource.getProject().getNamespace();
@@ -17,6 +17,7 @@ const taskInfos = {
17
17
  replaceCopyright: {path: "./replaceCopyright.js"},
18
18
  replaceVersion: {path: "./replaceVersion.js"},
19
19
  replaceBuildtime: {path: "./replaceBuildtime.js"},
20
+ enhanceManifest: {path: "./enhanceManifest.js"},
20
21
  escapeNonAsciiCharacters: {path: "./escapeNonAsciiCharacters.js"},
21
22
  executeJsdocSdkTransformation: {path: "./jsdoc/executeJsdocSdkTransformation.js"},
22
23
  generateApiIndex: {path: "./jsdoc/generateApiIndex.js"},
@@ -98,7 +99,7 @@ export function getRemovedTaskNames() {
98
99
  return ["createDebugFiles", "uglify", "generateManifestBundle"];
99
100
  }
100
101
 
101
- // Using CommonsJS require as importing json files causes an ExperimentalWarning
102
+ // Using CommonsJS require since JSON module imports are still experimental
102
103
  const require = createRequire(import.meta.url);
103
104
  function getVersion(pkg) {
104
105
  return require(`${pkg}/package.json`).version;
@@ -11,13 +11,12 @@ import bootstrapHtmlTransformer from "../processors/bootstrapHtmlTransformer.js"
11
11
  * @param {@ui5/fs/DuplexCollection} parameters.workspace DuplexCollection to read and write files
12
12
  * @param {object} parameters.options Options
13
13
  * @param {string} parameters.options.projectName Project name
14
- * @param {string} [parameters.options.namespace] Project namespace
14
+ * @param {string} [parameters.options.projectNamespace] Project namespace
15
15
  * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
16
16
  */
17
17
  export default async function({workspace, options}) {
18
18
  const {projectName} = options;
19
- // Backward compatibility: "namespace" option got renamed to "projectNamespace"
20
- const namespace = options.projectNamespace || options.namespace;
19
+ const namespace = options.projectNamespace;
21
20
 
22
21
  let indexPath;
23
22
  if (namespace) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/builder",
3
- "version": "3.5.1",
3
+ "version": "4.0.1",
4
4
  "description": "UI5 Tooling - Builder",
5
5
  "author": {
6
6
  "name": "SAP SE",
@@ -26,10 +26,10 @@
26
26
  "./tasks/bundlers/utils/*": null,
27
27
  "./package.json": "./package.json",
28
28
  "./internal/taskRepository": "./lib/tasks/taskRepository.js",
29
- "./internal/jsdoc/template/publish": "./lib/processors/jsdoc/lib/ui5/template/publish.cjs"
29
+ "./internal/jsdoc/template/publish": "./lib/processors/jsdoc/lib/ui5/template/publish.js"
30
30
  },
31
31
  "engines": {
32
- "node": "^16.18.0 || >=18.12.0",
32
+ "node": "^20.11.0 || >=22.0.0",
33
33
  "npm": ">= 8"
34
34
  },
35
35
  "scripts": {
@@ -47,7 +47,7 @@
47
47
  "jsdoc-generate": "jsdoc -c ./jsdoc.json -t $(node -p 'path.dirname(require.resolve(\"docdash\"))') ./lib/ || (echo 'Error during JSDoc generation! Check log.' && exit 1)",
48
48
  "jsdoc-watch": "npm run jsdoc && chokidar \"./lib/**/*.js\" -c \"npm run jsdoc-generate\"",
49
49
  "preversion": "npm test",
50
- "version": "git-chglog --sort semver --next-tag v$npm_package_version -o CHANGELOG.md v3.0.0.. && git add CHANGELOG.md",
50
+ "version": "git-chglog --sort semver --next-tag v$npm_package_version -o CHANGELOG.md v4.0.0.. && git add CHANGELOG.md",
51
51
  "prepublishOnly": "git push --follow-tags",
52
52
  "release-note": "git-chglog --sort semver -c .chglog/release-config.yml v$npm_package_version",
53
53
  "depcheck": "depcheck --ignores @ui5/builder,docdash,@istanbuljs/esm-loader-hook,catharsis --parsers='**/*.js:es6,**/*.cjs:es6'"
@@ -64,9 +64,11 @@
64
64
  "files": [
65
65
  "test/lib/**/*.js"
66
66
  ],
67
- "ignoredByWatcher": [
68
- "test/tmp/**"
69
- ],
67
+ "watchMode": {
68
+ "ignoreChanges": [
69
+ "test/tmp/**"
70
+ ]
71
+ },
70
72
  "nodeArguments": [
71
73
  "--loader=esmock",
72
74
  "--no-warnings"
@@ -120,29 +122,27 @@
120
122
  },
121
123
  "dependencies": {
122
124
  "@jridgewell/sourcemap-codec": "^1.5.0",
123
- "@ui5/fs": "^3.0.5",
124
- "@ui5/logger": "^3.0.0",
125
+ "@ui5/fs": "^4.0.0",
126
+ "@ui5/logger": "^4.0.1",
125
127
  "cheerio": "1.0.0-rc.12",
126
128
  "escape-unicode": "^0.2.0",
127
129
  "escope": "^4.0.0",
128
- "espree": "^9.6.1",
130
+ "espree": "^10.1.0",
129
131
  "graceful-fs": "^4.2.11",
130
132
  "jsdoc": "^4.0.3",
131
133
  "less-openui5": "^0.11.6",
132
134
  "pretty-data": "^0.40.0",
133
- "rimraf": "^5.0.9",
135
+ "rimraf": "^6.0.1",
134
136
  "semver": "^7.6.3",
135
137
  "terser": "^5.31.3",
136
- "workerpool": "^6.5.1",
138
+ "workerpool": "^9.1.3",
137
139
  "xml2js": "^0.6.2"
138
140
  },
139
141
  "devDependencies": {
140
142
  "@istanbuljs/esm-loader-hook": "^0.2.0",
141
143
  "@jridgewell/trace-mapping": "^0.3.25",
142
- "@ui5/project": "^3.9.2",
143
- "ava": "^5.3.1",
144
- "chai": "^4.4.1",
145
- "chai-fs": "^2.0.0",
144
+ "@ui5/project": "^4.0.0",
145
+ "ava": "^6.1.3",
146
146
  "chokidar-cli": "^3.0.0",
147
147
  "cross-env": "^7.0.3",
148
148
  "depcheck": "^1.4.7",
@@ -150,13 +150,12 @@
150
150
  "eslint": "^8.57.0",
151
151
  "eslint-config-google": "^0.14.0",
152
152
  "eslint-plugin-ava": "^14.0.0",
153
- "eslint-plugin-jsdoc": "^46.10.1",
153
+ "eslint-plugin-jsdoc": "^48.8.3",
154
154
  "esmock": "^2.6.7",
155
155
  "line-column": "^1.0.2",
156
- "nyc": "^15.1.0",
157
- "open-cli": "^7.2.0",
158
- "recursive-readdir": "^2.2.3",
159
- "sinon": "^16.1.3",
156
+ "nyc": "^17.0.0",
157
+ "open-cli": "^8.0.0",
158
+ "sinon": "^18.0.0",
160
159
  "tap-xunit": "^2.4.1"
161
160
  }
162
161
  }