@ui5/builder 3.0.0-alpha.10 → 3.0.0-alpha.12
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 +35 -2
- package/jsdoc.json +2 -2
- package/lib/lbt/UI5ClientConstants.js +7 -8
- package/lib/lbt/analyzer/ComponentAnalyzer.js +10 -10
- package/lib/lbt/analyzer/FioriElementsAnalyzer.js +31 -20
- package/lib/lbt/analyzer/JSModuleAnalyzer.js +107 -65
- package/lib/lbt/analyzer/SmartTemplateAnalyzer.js +31 -20
- package/lib/lbt/analyzer/XMLCompositeAnalyzer.js +35 -25
- package/lib/lbt/analyzer/XMLTemplateAnalyzer.js +19 -17
- package/lib/lbt/analyzer/analyzeLibraryJS.js +22 -6
- package/lib/lbt/bundle/AutoSplitter.js +10 -11
- package/lib/lbt/bundle/Builder.js +30 -33
- package/lib/lbt/bundle/BundleDefinition.js +1 -5
- package/lib/lbt/bundle/BundleWriter.js +1 -2
- package/lib/lbt/bundle/ResolvedBundleDefinition.js +6 -7
- package/lib/lbt/bundle/Resolver.js +9 -10
- package/lib/lbt/calls/SapUiDefine.js +16 -11
- package/lib/lbt/graph/dependencyGraph.js +3 -4
- package/lib/lbt/graph/dominatorTree.js +3 -3
- package/lib/lbt/graph/topologicalSort.js +3 -3
- package/lib/lbt/resources/LibraryFileAnalyzer.js +5 -8
- package/lib/lbt/resources/LocatorResource.js +2 -2
- package/lib/lbt/resources/LocatorResourcePool.js +3 -3
- package/lib/lbt/resources/ModuleInfo.js +1 -2
- package/lib/lbt/resources/Resource.js +3 -4
- package/lib/lbt/resources/ResourceCollector.js +7 -8
- package/lib/lbt/resources/ResourceFilterList.js +38 -40
- package/lib/lbt/resources/ResourceInfo.js +1 -1
- package/lib/lbt/resources/ResourceInfoList.js +2 -2
- package/lib/lbt/resources/ResourcePool.js +15 -21
- package/lib/lbt/utils/ASTUtils.js +58 -44
- package/lib/lbt/utils/JSTokenizer.js +4 -4
- package/lib/lbt/utils/ModuleName.js +10 -20
- package/lib/lbt/utils/escapePropertiesFile.js +3 -3
- package/lib/lbt/utils/parseUtils.js +4 -10
- package/lib/processors/bootstrapHtmlTransformer.js +15 -7
- package/lib/processors/bundlers/flexChangesBundler.js +16 -8
- package/lib/processors/bundlers/manifestBundler.js +19 -10
- package/lib/processors/bundlers/moduleBundler.js +26 -15
- package/lib/processors/jsdoc/apiIndexGenerator.js +16 -9
- package/lib/processors/jsdoc/jsdocGenerator.js +31 -17
- package/lib/processors/jsdoc/lib/{createIndexFiles.js → createIndexFiles.cjs} +0 -0
- package/lib/processors/jsdoc/lib/{transformApiJson.js → transformApiJson.cjs} +58 -2
- package/lib/processors/jsdoc/lib/ui5/{plugin.js → plugin.cjs} +306 -119
- package/lib/processors/jsdoc/lib/ui5/template/{publish.js → publish.cjs} +1 -1
- package/lib/processors/jsdoc/lib/ui5/template/utils/{versionUtil.js → versionUtil.cjs} +0 -0
- package/lib/processors/jsdoc/sdkTransformer.js +18 -11
- package/lib/processors/libraryLessGenerator.js +28 -16
- package/lib/processors/manifestCreator.js +14 -13
- package/lib/processors/minifier.js +21 -15
- package/lib/processors/nonAsciiEscaper.js +16 -6
- package/lib/processors/resourceListCreator.js +13 -13
- package/lib/processors/stringReplacer.js +13 -6
- package/lib/processors/themeBuilder.js +30 -22
- package/lib/processors/versionInfoGenerator.js +33 -23
- package/lib/tasks/buildThemes.js +17 -10
- package/lib/tasks/bundlers/generateBundle.js +23 -12
- package/lib/tasks/bundlers/generateComponentPreload.js +18 -10
- package/lib/tasks/bundlers/generateFlexChangesBundle.js +16 -8
- package/lib/tasks/bundlers/generateLibraryPreload.js +22 -12
- package/lib/tasks/bundlers/generateManifestBundle.js +15 -6
- package/lib/tasks/bundlers/generateStandaloneAppBundle.js +21 -13
- package/lib/tasks/bundlers/utils/createModuleNameMapping.js +6 -6
- package/lib/tasks/escapeNonAsciiCharacters.js +12 -5
- package/lib/tasks/generateCachebusterInfo.js +16 -8
- package/lib/tasks/generateLibraryManifest.js +14 -8
- package/lib/tasks/generateResourcesJson.js +15 -9
- package/lib/tasks/generateThemeDesignerResources.js +19 -9
- package/lib/tasks/generateVersionInfo.js +12 -5
- package/lib/tasks/jsdoc/executeJsdocSdkTransformation.js +17 -9
- package/lib/tasks/jsdoc/generateApiIndex.js +16 -10
- package/lib/tasks/jsdoc/generateJsdoc.js +131 -119
- package/lib/tasks/minify.js +13 -6
- package/lib/tasks/replaceBuildtime.js +12 -5
- package/lib/tasks/replaceCopyright.js +12 -5
- package/lib/tasks/replaceVersion.js +12 -5
- package/lib/tasks/taskRepository.js +24 -29
- package/lib/tasks/transformBootstrapHtml.js +6 -5
- package/package.json +30 -15
- package/index.js +0 -173
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import {Syntax} from "../utils/parseUtils.js";
|
|
3
|
+
import SapUiDefine from "../calls/SapUiDefine.js";
|
|
4
|
+
import {getValue, isMethodCall, getStringValue} from "../utils/ASTUtils.js";
|
|
5
|
+
import {fromUI5LegacyName} from "../utils/ModuleName.js";
|
|
6
|
+
import logger from "@ui5/logger";
|
|
7
|
+
const log = logger.getLogger("lbt:analyzer:XMLCompositeAnalyzer");
|
|
8
8
|
|
|
9
9
|
const CALL_DEFINE = ["define"];
|
|
10
10
|
const CALL_SAP_UI_DEFINE = ["sap", "ui", "define"];
|
|
@@ -19,18 +19,30 @@ class XMLCompositeAnalyzer {
|
|
|
19
19
|
const XMLC = defineCall.findImportName("sap/ui/core/XMLComposite.js");
|
|
20
20
|
// console.log("local name for XMLComposite: %s", XMLC);
|
|
21
21
|
if ( XMLC && defineCall.factory ) {
|
|
22
|
-
defineCall.factory.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
if (defineCall.factory.type === Syntax.ArrowFunctionExpression &&
|
|
23
|
+
defineCall.factory.expression === true) {
|
|
24
|
+
fragmentName = this._checkForXMLCClassDefinition(XMLC, defineCall.factory.body);
|
|
25
|
+
} else {
|
|
26
|
+
defineCall.factory.body.body.forEach((stmt) => {
|
|
27
|
+
if (stmt.type === Syntax.VariableDeclaration) {
|
|
28
|
+
stmt.declarations.forEach((decl) => {
|
|
29
|
+
fragmentName = this._checkForXMLCClassDefinition(XMLC, decl.init) || fragmentName;
|
|
30
|
+
});
|
|
31
|
+
} else if (
|
|
32
|
+
stmt.type === Syntax.ReturnStatement &&
|
|
33
|
+
( stmt?.argument?.type === Syntax.CallExpression && stmt.argument.arguments?.length > 1 &&
|
|
34
|
+
stmt.argument.arguments[1].type === Syntax.ObjectExpression)) {
|
|
35
|
+
fragmentName =
|
|
36
|
+
this._checkForXMLCClassDefinition(XMLC, stmt.argument) || fragmentName;
|
|
37
|
+
} else if (stmt.type === Syntax.ExpressionStatement &&
|
|
38
|
+
stmt.expression.type === Syntax.AssignmentExpression) {
|
|
39
|
+
fragmentName =
|
|
40
|
+
this._checkForXMLCClassDefinition(XMLC, stmt.expression.right) || fragmentName;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if (fragmentName) {
|
|
45
|
+
const fragmentModule = fromUI5LegacyName(fragmentName, ".control.xml");
|
|
34
46
|
log.verbose("fragment control: add dependency to template fragment %s", fragmentModule);
|
|
35
47
|
info.addDependency(fragmentModule);
|
|
36
48
|
}
|
|
@@ -42,8 +54,9 @@ class XMLCompositeAnalyzer {
|
|
|
42
54
|
let fragmentName;
|
|
43
55
|
if ( isMethodCall(stmt, [XMLC, "extend"]) ) {
|
|
44
56
|
// log.verbose(stmt);
|
|
45
|
-
|
|
46
|
-
|
|
57
|
+
const value = getStringValue(stmt.arguments[0]);
|
|
58
|
+
if ( stmt.arguments.length > 0 && value ) {
|
|
59
|
+
fragmentName = value;
|
|
47
60
|
}
|
|
48
61
|
if ( stmt.arguments.length > 1 && stmt.arguments[1].type === Syntax.ObjectExpression ) {
|
|
49
62
|
fragmentName = this._analyzeXMLCClassDefinition(stmt.arguments[1]) || fragmentName;
|
|
@@ -54,12 +67,9 @@ class XMLCompositeAnalyzer {
|
|
|
54
67
|
|
|
55
68
|
_analyzeXMLCClassDefinition(clazz) {
|
|
56
69
|
// log.verbose(clazz);
|
|
57
|
-
|
|
58
|
-
if ( isString(fragmentName) ) {
|
|
59
|
-
return fragmentName.value;
|
|
60
|
-
}
|
|
70
|
+
return getStringValue(getValue(clazz, ["fragment"]));
|
|
61
71
|
}
|
|
62
72
|
}
|
|
63
73
|
|
|
64
74
|
|
|
65
|
-
|
|
75
|
+
export default XMLCompositeAnalyzer;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import xml2js from "xml2js";
|
|
3
|
+
import {fromUI5LegacyName, fromRequireJSName} from "../utils/ModuleName.js";
|
|
4
|
+
import JSTokenizer from "../utils/JSTokenizer.js";
|
|
5
|
+
import logger from "@ui5/logger";
|
|
6
|
+
const log = logger.getLogger("lbt:analyzer:XMLTemplateAnalyzer");
|
|
7
|
+
|
|
8
|
+
// ---------------------------------------------------------------------------------------------------------
|
|
2
9
|
|
|
3
10
|
/*
|
|
4
11
|
* TODOS
|
|
@@ -10,11 +17,6 @@
|
|
|
10
17
|
* - move UI5 specific constants to UI5ClientConstants?
|
|
11
18
|
*/
|
|
12
19
|
|
|
13
|
-
const xml2js = require("xml2js");
|
|
14
|
-
const ModuleName = require("../utils/ModuleName");
|
|
15
|
-
const JSTokenizer = require("../utils/JSTokenizer");
|
|
16
|
-
const log = require("@ui5/logger").getLogger("lbt:analyzer:XMLTemplateAnalyzer");
|
|
17
|
-
|
|
18
20
|
// ---------------------------------------------------------------------------------------------------------
|
|
19
21
|
|
|
20
22
|
const XHTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
@@ -195,12 +197,12 @@ class XMLTemplateAnalyzer {
|
|
|
195
197
|
|
|
196
198
|
const controllerName = getAttribute(node, XMLVIEW_CONTROLLERNAME_ATTRIBUTE);
|
|
197
199
|
if ( controllerName ) {
|
|
198
|
-
this._addDependency(
|
|
200
|
+
this._addDependency( fromUI5LegacyName(controllerName, ".controller.js"), this.conditional );
|
|
199
201
|
}
|
|
200
202
|
|
|
201
203
|
const resourceBundleName = getAttribute(node, XMLVIEW_RESBUNDLENAME_ATTRIBUTE);
|
|
202
204
|
if ( resourceBundleName ) {
|
|
203
|
-
const resourceBundleModuleName =
|
|
205
|
+
const resourceBundleModuleName = fromUI5LegacyName(resourceBundleName, ".properties");
|
|
204
206
|
log.verbose("found dependency to resource bundle %s", resourceBundleModuleName);
|
|
205
207
|
// TODO locale dependent dependencies: this._addDependency(resourceBundleModuleName);
|
|
206
208
|
this._addDependency( resourceBundleModuleName, this.conditional );
|
|
@@ -229,7 +231,7 @@ class XMLTemplateAnalyzer {
|
|
|
229
231
|
|
|
230
232
|
} else if ( PATTERN_LIBRARY_NAMESPACES.test(namespace) ) {
|
|
231
233
|
// looks like a UI5 library or package name
|
|
232
|
-
const moduleName =
|
|
234
|
+
const moduleName = fromUI5LegacyName( (namespace ? namespace + "." : "") + localName );
|
|
233
235
|
|
|
234
236
|
this._analyzeCoreRequire(node);
|
|
235
237
|
|
|
@@ -283,7 +285,7 @@ class XMLTemplateAnalyzer {
|
|
|
283
285
|
Object.keys(requireContext).forEach((key) => {
|
|
284
286
|
const requireJsName = requireContext[key];
|
|
285
287
|
if ( requireJsName && typeof requireJsName === "string" ) {
|
|
286
|
-
this._addDependency(
|
|
288
|
+
this._addDependency(fromRequireJSName(requireJsName), this.conditional);
|
|
287
289
|
} else {
|
|
288
290
|
log.error(`Ignoring core:require: '${key}' refers to invalid module name '${requireJsName}'`);
|
|
289
291
|
}
|
|
@@ -307,7 +309,7 @@ class XMLTemplateAnalyzer {
|
|
|
307
309
|
const componentName = getAttribute(node, COMPONENTCONTAINER_COMPONENTNAME_ATTRIBUTE);
|
|
308
310
|
if ( componentName ) {
|
|
309
311
|
const componentModuleName =
|
|
310
|
-
|
|
312
|
+
fromUI5LegacyName( componentName, "/Component.js" );
|
|
311
313
|
this._addDependency(componentModuleName, conditional);
|
|
312
314
|
}
|
|
313
315
|
// TODO what about component.json? handle it transitively via Component.js?
|
|
@@ -316,35 +318,35 @@ class XMLTemplateAnalyzer {
|
|
|
316
318
|
const type = getAttribute(node, FRAGMENT_TYPE_ATTRIBUTE);
|
|
317
319
|
if ( fragmentName && type ) {
|
|
318
320
|
const fragmentModuleName =
|
|
319
|
-
|
|
321
|
+
fromUI5LegacyName( fragmentName, this._getFragmentExtension(type) );
|
|
320
322
|
// console.log("child fragment detected %s", fragmentModuleName);
|
|
321
323
|
this._addDependency(fragmentModuleName, conditional);
|
|
322
324
|
}
|
|
323
325
|
} else if ( moduleName === HTMLVIEW_MODULE ) {
|
|
324
326
|
const viewName = getAttribute(node, ANYVIEW_VIEWNAME_ATTRIBUTE);
|
|
325
327
|
if ( viewName ) {
|
|
326
|
-
const childViewModuleName =
|
|
328
|
+
const childViewModuleName = fromUI5LegacyName( viewName, ".view.html" );
|
|
327
329
|
// console.log("child view detected %s", childViewModuleName);
|
|
328
330
|
this._addDependency(childViewModuleName, conditional);
|
|
329
331
|
}
|
|
330
332
|
} else if ( moduleName === JSVIEW_MODULE ) {
|
|
331
333
|
const viewName = getAttribute(node, ANYVIEW_VIEWNAME_ATTRIBUTE);
|
|
332
334
|
if ( viewName ) {
|
|
333
|
-
const childViewModuleName =
|
|
335
|
+
const childViewModuleName = fromUI5LegacyName( viewName, ".view.js" );
|
|
334
336
|
// console.log("child view detected %s", childViewModuleName);
|
|
335
337
|
this._addDependency(childViewModuleName, conditional);
|
|
336
338
|
}
|
|
337
339
|
} else if ( moduleName === JSONVIEW_MODULE ) {
|
|
338
340
|
const viewName = getAttribute(node, ANYVIEW_VIEWNAME_ATTRIBUTE);
|
|
339
341
|
if ( viewName ) {
|
|
340
|
-
const childViewModuleName =
|
|
342
|
+
const childViewModuleName = fromUI5LegacyName( viewName, ".view.json" );
|
|
341
343
|
// console.log("child view detected %s", childViewModuleName);
|
|
342
344
|
this._addDependency(childViewModuleName, conditional);
|
|
343
345
|
}
|
|
344
346
|
} else if ( moduleName === XMLVIEW_MODULE ) {
|
|
345
347
|
const viewName = getAttribute(node, ANYVIEW_VIEWNAME_ATTRIBUTE);
|
|
346
348
|
if ( viewName ) {
|
|
347
|
-
const childViewModuleName =
|
|
349
|
+
const childViewModuleName = fromUI5LegacyName( viewName, ".view.xml" );
|
|
348
350
|
// console.log("child view detected %s", childViewModuleName);
|
|
349
351
|
this._addDependency(childViewModuleName, conditional);
|
|
350
352
|
}
|
|
@@ -361,4 +363,4 @@ class XMLTemplateAnalyzer {
|
|
|
361
363
|
}
|
|
362
364
|
|
|
363
365
|
|
|
364
|
-
|
|
366
|
+
export default XMLTemplateAnalyzer;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
|
|
2
|
+
import {parseJS, Syntax, VisitorKeys} from "../utils/parseUtils.js";
|
|
3
|
+
import {getPropertyKey, isMethodCall, isIdentifier, getStringArray} from "../utils/ASTUtils.js";
|
|
4
|
+
import logger from "@ui5/logger";
|
|
5
|
+
const log = logger.getLogger("lbt:analyzer:LibraryJS");
|
|
4
6
|
|
|
5
7
|
const CALL__SAP_UI_GETCORE = ["sap", "ui", "getCore"];
|
|
6
8
|
|
|
@@ -25,8 +27,14 @@ async function analyze(resource) {
|
|
|
25
27
|
node.arguments.length === 1 &&
|
|
26
28
|
node.arguments[0].type === Syntax.ObjectExpression ) {
|
|
27
29
|
node.arguments[0].properties.forEach( (prop) => {
|
|
30
|
+
if (prop.type === Syntax.SpreadElement) {
|
|
31
|
+
// SpreadElements are currently not supported
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
28
35
|
const key = getPropertyKey(prop);
|
|
29
36
|
const value = prop.value;
|
|
37
|
+
|
|
30
38
|
if ( key === "noLibraryCSS" &&
|
|
31
39
|
(value.type === Syntax.Literal && typeof value.value === "boolean") ) {
|
|
32
40
|
libInfo.noLibraryCSS = value.value;
|
|
@@ -38,6 +46,14 @@ async function analyze(resource) {
|
|
|
38
46
|
libInfo.controls = getStringArray(value, true);
|
|
39
47
|
} else if ( key === "elements" && value.type == Syntax.ArrayExpression ) {
|
|
40
48
|
libInfo.elements = getStringArray(value, true);
|
|
49
|
+
} else if ( ["designtime", "dependencies", "extensions", "name", "version"].includes(key) ) {
|
|
50
|
+
// do nothing, for all other supported properties
|
|
51
|
+
} else {
|
|
52
|
+
log.error(
|
|
53
|
+
"Unexpected property '" + key +
|
|
54
|
+
"' or wrong type for '" + key +
|
|
55
|
+
"' in sap.ui.getCore().initLibrary call in '" + resource.getPath() + "'"
|
|
56
|
+
);
|
|
41
57
|
}
|
|
42
58
|
});
|
|
43
59
|
|
|
@@ -81,12 +97,12 @@ async function analyze(resource) {
|
|
|
81
97
|
*
|
|
82
98
|
* Note: only the first initLibrary() call that is found with a DFS on the AST, will be evaluated.
|
|
83
99
|
*
|
|
84
|
-
* @param {
|
|
100
|
+
* @param {@ui5/fs/Resource} resource library.js resource whose content should be analyzed
|
|
85
101
|
* @returns {Promise<object>} A Promise on the extract info object
|
|
86
102
|
*/
|
|
87
|
-
|
|
103
|
+
export default function(resource) {
|
|
88
104
|
if ( resource == null ) {
|
|
89
105
|
return Promise.resolve({});
|
|
90
106
|
}
|
|
91
107
|
return analyze(resource);
|
|
92
|
-
}
|
|
108
|
+
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const log =
|
|
2
|
+
import {pd} from "pretty-data";
|
|
3
|
+
import {toRequireJSName} from "../utils/ModuleName.js";
|
|
4
|
+
import {SectionType} from "./BundleDefinition.js";
|
|
5
|
+
import escapePropertiesFile from "../utils/escapePropertiesFile.js";
|
|
6
|
+
import logger from "@ui5/logger";
|
|
7
|
+
const log = logger.getLogger("lbt:bundle:AutoSplitter");
|
|
9
8
|
|
|
10
9
|
const xmlHtmlPrePattern = /<(?:\w+:)?pre\b/;
|
|
11
10
|
|
|
@@ -72,7 +71,7 @@ class AutoSplitter {
|
|
|
72
71
|
break;
|
|
73
72
|
case SectionType.Require:
|
|
74
73
|
section.modules.forEach( (module) => {
|
|
75
|
-
totalSize += "sap.ui.requireSync('');".length +
|
|
74
|
+
totalSize += "sap.ui.requireSync('');".length + toRequireJSName(module).length;
|
|
76
75
|
});
|
|
77
76
|
break;
|
|
78
77
|
default:
|
|
@@ -90,7 +89,7 @@ class AutoSplitter {
|
|
|
90
89
|
const splittedModules = [];
|
|
91
90
|
let moduleNameWithPart = moduleDef.name;
|
|
92
91
|
if ( !/__part__/.test(moduleNameWithPart) ) {
|
|
93
|
-
moduleNameWithPart =
|
|
92
|
+
moduleNameWithPart = toRequireJSName(moduleNameWithPart) + "-__part__.js";
|
|
94
93
|
}
|
|
95
94
|
// vars = Object.create(null);
|
|
96
95
|
|
|
@@ -177,7 +176,7 @@ class AutoSplitter {
|
|
|
177
176
|
currentModule.sections.push( currentSection );
|
|
178
177
|
section.modules.forEach( (module) => {
|
|
179
178
|
currentSection.filters.push( module );
|
|
180
|
-
totalSize += 21 +
|
|
179
|
+
totalSize += 21 + toRequireJSName(module).length;
|
|
181
180
|
});
|
|
182
181
|
break;
|
|
183
182
|
default:
|
|
@@ -257,4 +256,4 @@ class AutoSplitter {
|
|
|
257
256
|
} */
|
|
258
257
|
}
|
|
259
258
|
|
|
260
|
-
|
|
259
|
+
export default AutoSplitter;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/* eslint quotes: ["error", "double", { "allowTemplateLiterals": true }] */
|
|
2
2
|
// for consistency of write calls, we generally allow template literals
|
|
3
|
-
"use strict";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import {pd} from "pretty-data";
|
|
6
|
+
import {parseJS, Syntax} from "../utils/parseUtils.js";
|
|
7
|
+
import {encode as encodeMappings, decode as decodeMappings} from "@jridgewell/sourcemap-codec";
|
|
8
|
+
import {isMethodCall} from "../utils/ASTUtils.js";
|
|
9
|
+
import {toUI5LegacyName, toRequireJSName} from "../utils/ModuleName.js";
|
|
10
|
+
import {
|
|
11
|
+
MODULE__UI5LOADER, MODULE__UI5LOADER_AUTOCONFIG,
|
|
12
|
+
MODULE__JQUERY_SAP_GLOBAL, MODULE__SAP_UI_CORE_CORE} from "../UI5ClientConstants.js";
|
|
13
|
+
import escapePropertiesFile from "../utils/escapePropertiesFile.js";
|
|
14
|
+
import BundleResolver from "./Resolver.js";
|
|
15
|
+
import BundleSplitter from "./AutoSplitter.js";
|
|
16
|
+
import {SectionType} from "./BundleDefinition.js";
|
|
17
|
+
import BundleWriter from "./BundleWriter.js";
|
|
18
|
+
import logger from "@ui5/logger";
|
|
19
|
+
const log = logger.getLogger("lbt:bundle:Builder");
|
|
20
20
|
|
|
21
21
|
const sourceMappingUrlPattern = /\/\/# sourceMappingURL=(.+)\s*$/;
|
|
22
22
|
const httpPattern = /^https?:\/\//i;
|
|
@@ -63,14 +63,14 @@ const EVOBundleFormat = {
|
|
|
63
63
|
},
|
|
64
64
|
|
|
65
65
|
requireSync(moduleName) {
|
|
66
|
-
return `sap.ui.requireSync("${
|
|
66
|
+
return `sap.ui.requireSync("${toRequireJSName(moduleName)}");\n`;
|
|
67
67
|
},
|
|
68
68
|
|
|
69
69
|
shouldDecorate(resolvedModule) {
|
|
70
|
-
return resolvedModule.executes(
|
|
71
|
-
resolvedModule.executes(
|
|
72
|
-
resolvedModule.executes(
|
|
73
|
-
resolvedModule.executes(
|
|
70
|
+
return resolvedModule.executes(MODULE__UI5LOADER) ||
|
|
71
|
+
resolvedModule.executes(MODULE__UI5LOADER_AUTOCONFIG) ||
|
|
72
|
+
resolvedModule.executes(MODULE__JQUERY_SAP_GLOBAL) ||
|
|
73
|
+
resolvedModule.executes(MODULE__SAP_UI_CORE_CORE);
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
76
|
|
|
@@ -232,11 +232,11 @@ class BundleBuilder {
|
|
|
232
232
|
/* NODE-TODO, moduleName is not defined
|
|
233
233
|
It should contain the name of the module which is currently build (1st parameter of _createBundle).
|
|
234
234
|
But when the ui5loader is present, declareRawModules should be forced to false anyhow.
|
|
235
|
-
this.outW.writeln("jQuery.sap.declare('",
|
|
235
|
+
this.outW.writeln("jQuery.sap.declare('", toUI5LegacyName(moduleName), "');");
|
|
236
236
|
*/
|
|
237
237
|
this.missingRawDeclarations.forEach( (module) => {
|
|
238
238
|
// 2nd parameter set to 'false': do not create namespaces - they nevertheless would come too late
|
|
239
|
-
this.outW.writeln(`jQuery.sap.declare('${
|
|
239
|
+
this.outW.writeln(`jQuery.sap.declare('${toUI5LegacyName(module)}', false);`);
|
|
240
240
|
});
|
|
241
241
|
this.missingRawDeclarations = [];
|
|
242
242
|
}
|
|
@@ -258,7 +258,7 @@ class BundleBuilder {
|
|
|
258
258
|
if ( section.declareRawModules ) {
|
|
259
259
|
this.missingRawDeclarations.push(moduleName);
|
|
260
260
|
}
|
|
261
|
-
if ( moduleName ===
|
|
261
|
+
if ( moduleName === MODULE__JQUERY_SAP_GLOBAL ) {
|
|
262
262
|
this.jqglobalAvailable = true;
|
|
263
263
|
}
|
|
264
264
|
} else {
|
|
@@ -413,7 +413,7 @@ class BundleBuilder {
|
|
|
413
413
|
*
|
|
414
414
|
* @param {string} moduleName module name
|
|
415
415
|
* @param {ModuleInfo} info
|
|
416
|
-
* @param {
|
|
416
|
+
* @param {@ui5/fs/Resource} resource
|
|
417
417
|
* @returns {Promise<boolean>}
|
|
418
418
|
*/
|
|
419
419
|
async writePreloadModule(moduleName, info, resource) {
|
|
@@ -648,8 +648,8 @@ async function rewriteDefine({moduleName, moduleContent, moduleSourceMap}) {
|
|
|
648
648
|
|
|
649
649
|
// Inject module name if missing
|
|
650
650
|
if ( defineCall.arguments.length == 0 ||
|
|
651
|
-
defineCall.arguments[0].type
|
|
652
|
-
let value = `"${
|
|
651
|
+
![Syntax.Literal, Syntax.TemplateLiteral].includes(defineCall.arguments[0].type)) {
|
|
652
|
+
let value = `"${toRequireJSName(moduleName)}"`;
|
|
653
653
|
let index;
|
|
654
654
|
|
|
655
655
|
if (defineCall.arguments.length == 0) {
|
|
@@ -773,10 +773,7 @@ function createTransientSourceMap({moduleName, moduleContent, includeContent = f
|
|
|
773
773
|
return sourceMap;
|
|
774
774
|
}
|
|
775
775
|
|
|
776
|
-
|
|
776
|
+
export default BundleBuilder;
|
|
777
777
|
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
if (process.env.NODE_ENV === "test") {
|
|
781
|
-
module.exports.__localFunctions__ = {rewriteDefine, createTransientSourceMap};
|
|
782
|
-
}
|
|
778
|
+
export const __localFunctions__ = (process.env.NODE_ENV === "test") ?
|
|
779
|
+
{rewriteDefine, createTransientSourceMap} : undefined;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const SectionType = {
|
|
1
|
+
export const SectionType = {
|
|
4
2
|
/**
|
|
5
3
|
* The modules are assumed to exist already in the loading environment.
|
|
6
4
|
*/
|
|
@@ -31,5 +29,3 @@ const SectionType = {
|
|
|
31
29
|
*/
|
|
32
30
|
Require: "require"
|
|
33
31
|
};
|
|
34
|
-
|
|
35
|
-
module.exports.SectionType = SectionType;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import {MODULE__JQUERY_SAP_GLOBAL, MODULE__SAP_UI_CORE_CORE} from "../UI5ClientConstants.js";
|
|
3
|
+
import ModuleInfo from "../resources/ModuleInfo.js";
|
|
4
|
+
import {SectionType} from "./BundleDefinition.js";
|
|
6
5
|
|
|
7
6
|
class ResolvedBundleDefinition {
|
|
8
7
|
constructor( bundleDefinition /* , vars*/) {
|
|
@@ -18,7 +17,7 @@ class ResolvedBundleDefinition {
|
|
|
18
17
|
return this.sections.some(
|
|
19
18
|
(section) =>
|
|
20
19
|
(section.mode === SectionType.Raw || section.mode === SectionType.Require) &&
|
|
21
|
-
section.modules.some((module) => module ===
|
|
20
|
+
section.modules.some((module) => module === MODULE__SAP_UI_CORE_CORE)
|
|
22
21
|
);
|
|
23
22
|
}
|
|
24
23
|
|
|
@@ -26,7 +25,7 @@ class ResolvedBundleDefinition {
|
|
|
26
25
|
return this.sections.some(
|
|
27
26
|
(section) =>
|
|
28
27
|
section.mode === SectionType.Raw &&
|
|
29
|
-
section.modules.some((module) => module ===
|
|
28
|
+
section.modules.some((module) => module === MODULE__JQUERY_SAP_GLOBAL)
|
|
30
29
|
);
|
|
31
30
|
}
|
|
32
31
|
|
|
@@ -108,4 +107,4 @@ class ResolvedSection {
|
|
|
108
107
|
}
|
|
109
108
|
}
|
|
110
109
|
|
|
111
|
-
|
|
110
|
+
export default ResolvedBundleDefinition;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Takes a bundle definition and resolves it against the given pool.
|
|
3
3
|
*/
|
|
4
|
-
"use strict";
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const log =
|
|
5
|
+
import topologicalSort from "../graph/topologicalSort.js";
|
|
6
|
+
import {getRendererName} from "../UI5ClientConstants.js";
|
|
7
|
+
import ResourceFilterList from "../resources/ResourceFilterList.js";
|
|
8
|
+
import {SectionType} from "./BundleDefinition.js";
|
|
9
|
+
import ResolvedBundleDefinition from "./ResolvedBundleDefinition.js";
|
|
10
|
+
import logger from "@ui5/logger";
|
|
11
|
+
const log = logger.getLogger("lbt:bundle:Resolver");
|
|
13
12
|
|
|
14
13
|
let dependencyTracker;
|
|
15
14
|
|
|
@@ -144,7 +143,7 @@ class BundleResolver {
|
|
|
144
143
|
|
|
145
144
|
// add renderer, if 'renderer' is configured and if it exists
|
|
146
145
|
if ( section.renderer ) {
|
|
147
|
-
const rendererModuleName =
|
|
146
|
+
const rendererModuleName = getRendererName( resourceName );
|
|
148
147
|
promises.push( checkAndAddResource( rendererModuleName, depth + 1) );
|
|
149
148
|
}
|
|
150
149
|
}
|
|
@@ -324,5 +323,5 @@ class BundleResolver {
|
|
|
324
323
|
}
|
|
325
324
|
|
|
326
325
|
|
|
327
|
-
|
|
326
|
+
export default BundleResolver;
|
|
328
327
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import {Syntax} from "../utils/parseUtils.js";
|
|
3
|
+
import {resolveRelativeRequireJSName} from "../utils/ModuleName.js";
|
|
4
|
+
import {isBoolean, getStringValue} from "../utils/ASTUtils.js";
|
|
6
5
|
|
|
7
6
|
class SapUiDefineCall {
|
|
8
7
|
constructor(node, moduleName) {
|
|
@@ -11,6 +10,7 @@ class SapUiDefineCall {
|
|
|
11
10
|
this.dependencyArray = null;
|
|
12
11
|
this.factory = null;
|
|
13
12
|
this.exportAsGlobal = false;
|
|
13
|
+
this.paramNames = null;
|
|
14
14
|
|
|
15
15
|
const args = node.arguments;
|
|
16
16
|
if ( args == null ) {
|
|
@@ -27,28 +27,33 @@ class SapUiDefineCall {
|
|
|
27
27
|
let i = 0;
|
|
28
28
|
let params;
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
const name = getStringValue(args[i]);
|
|
31
|
+
if ( i < args.length && name ) {
|
|
31
32
|
// assert(String)
|
|
32
|
-
this.name =
|
|
33
|
+
this.name = name;
|
|
34
|
+
i++;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
if ( i < args.length && args[i].type === Syntax.ArrayExpression ) {
|
|
36
38
|
this.dependencyArray = args[i++];
|
|
37
39
|
this.dependencies = this.dependencyArray.elements.map( (elem) => {
|
|
38
|
-
|
|
40
|
+
const value = getStringValue(elem);
|
|
41
|
+
if ( !value ) {
|
|
39
42
|
throw new TypeError();
|
|
40
43
|
}
|
|
41
|
-
return
|
|
44
|
+
return resolveRelativeRequireJSName(this.name, value);
|
|
42
45
|
});
|
|
43
46
|
this.dependencyInsertionIdx = this.dependencyArray.elements.length;
|
|
44
47
|
}
|
|
45
48
|
|
|
46
|
-
if ( i < args.length &&
|
|
49
|
+
if ( i < args.length && (
|
|
50
|
+
args[i].type === Syntax.FunctionExpression || args[i].type === Syntax.ArrowFunctionExpression)
|
|
51
|
+
) {
|
|
47
52
|
this.factory = args[i++];
|
|
48
53
|
params = this.factory.params;
|
|
49
54
|
this.paramNames = params.map( (param) => {
|
|
50
55
|
if ( param.type !== Syntax.Identifier ) {
|
|
51
|
-
|
|
56
|
+
return null;
|
|
52
57
|
}
|
|
53
58
|
return param.name;
|
|
54
59
|
});
|
|
@@ -88,4 +93,4 @@ class SapUiDefineCall {
|
|
|
88
93
|
}
|
|
89
94
|
}
|
|
90
95
|
|
|
91
|
-
|
|
96
|
+
export default SapUiDefineCall;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const log = require("@ui5/logger").getLogger("lbt:graph:dependencyGraph");
|
|
1
|
+
import logger from "@ui5/logger";
|
|
2
|
+
const log = logger.getLogger("lbt:graph:dependencyGraph");
|
|
4
3
|
|
|
5
4
|
class Node {
|
|
6
5
|
constructor(name) {
|
|
@@ -64,7 +63,7 @@ async function createDependencyGraph(pool, roots, options) {
|
|
|
64
63
|
});
|
|
65
64
|
}
|
|
66
65
|
|
|
67
|
-
|
|
66
|
+
export default createDependencyGraph;
|
|
68
67
|
|
|
69
68
|
// TODO introduce class Graph
|
|
70
69
|
// TODO remove n0 here, only introduce it in dominator tree (using the Graph API)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import logger from "@ui5/logger";
|
|
2
|
+
const log = logger.getLogger("lbt:graph:dominatorTree");
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Creates a dependency graph starting from the given set of root modules.
|
|
@@ -16,7 +17,6 @@
|
|
|
16
17
|
* @private
|
|
17
18
|
*/
|
|
18
19
|
function calculateDominatorTree({n0, nodes}) {
|
|
19
|
-
const log = require("@ui5/logger").getLogger("lbt:graph:dominatorTree");
|
|
20
20
|
// initialize set of dominators for each node
|
|
21
21
|
for ( const n of nodes.values() ) {
|
|
22
22
|
if ( n === n0 ) {
|
|
@@ -113,4 +113,4 @@ function calculateDominatorTree({n0, nodes}) {
|
|
|
113
113
|
return n0;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
export default calculateDominatorTree;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
|
|
3
|
-
|
|
2
|
+
import logger from "@ui5/logger";
|
|
3
|
+
const log = logger.getLogger("lbt:graph:topologicalSort");
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Represents a module and its dependencies in a dependency graph.
|
|
@@ -186,4 +186,4 @@ function topologicalSort(pool, moduleNames) {
|
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
|
|
189
|
+
export default topologicalSort;
|