@ui5/builder
Advanced tools
Comparing version 1.5.2 to 1.5.3
@@ -5,6 +5,12 @@ # Changelog | ||
A list of unreleased changes can be found [here](https://github.com/SAP/ui5-builder/compare/v1.5.2...HEAD). | ||
A list of unreleased changes can be found [here](https://github.com/SAP/ui5-builder/compare/v1.5.3...HEAD). | ||
<a name="v1.5.3"></a> | ||
## [v1.5.3] - 2019-10-11 | ||
### Bug Fixes | ||
- **Bundling:** merge dependency analysis results with raw module infos ([#340](https://github.com/SAP/ui5-builder/issues/340)) [`af4318a`](https://github.com/SAP/ui5-builder/commit/af4318a75d742bbd2e5566d2ffde2bc5a823ef06) | ||
<a name="v1.5.2"></a> | ||
## [v1.5.2] - 2019-10-06 | ||
## [v1.5.2] - 2019-10-09 | ||
### Bug Fixes | ||
@@ -262,2 +268,3 @@ - Improve recognition of main module in case of bundles ([#341](https://github.com/SAP/ui5-builder/issues/341)) [`7a560b4`](https://github.com/SAP/ui5-builder/commit/7a560b4bbc4c862ebded6f9e9f12c2156b1e33d1) | ||
[v1.5.3]: https://github.com/SAP/ui5-builder/compare/v1.5.2...v1.5.3 | ||
[v1.5.2]: https://github.com/SAP/ui5-builder/compare/v1.5.1...v1.5.2 | ||
@@ -264,0 +271,0 @@ [v1.5.1]: https://github.com/SAP/ui5-builder/compare/v1.5.0...v1.5.1 |
@@ -320,3 +320,3 @@ "use strict"; | ||
info.exposedGlobals = Array.from(currentScope.set.keys()); | ||
// console.log(info.name, info.exposedGlobals); | ||
// console.log(info.name, "exposed globals", info.exposedGlobals, "ignoredGlobals", info.ignoredGlobals); | ||
} | ||
@@ -323,0 +323,0 @@ |
@@ -59,4 +59,17 @@ /** | ||
function isMultiModule(moduleInfo) { | ||
return moduleInfo && moduleInfo.subModules.length > 0 && !/(?:^|\/)library.js$/.test(moduleInfo.name); | ||
function checkForDecomposableBundle(resource) { | ||
if ( resource == null | ||
|| resource.info == null | ||
|| resource.info.subModules.length === 0 | ||
|| /(?:^|\/)library.js$/.test(resource.info.name) ) { | ||
return {resource, decomposable: false}; | ||
} | ||
return Promise.all( | ||
resource.info.subModules.map((sub) => pool.findResource(sub).catch(() => false)) | ||
).then((modules) => { | ||
// it might look more natural to expect 'all' embedded modules to exist in the pool, | ||
// but expecting only 'some' module to exist is a more conservative approach | ||
return ({resource, decomposable: modules.some(($) => ($))}); | ||
}); | ||
} | ||
@@ -78,46 +91,51 @@ | ||
done = pool.findResourceWithInfo(resourceName).then( function(resource) { | ||
const dependencyInfo = resource && resource.info; | ||
let promises = []; | ||
done = pool.findResourceWithInfo(resourceName) | ||
.catch( (err) => { | ||
// if the caller provided an error message, log it | ||
if ( msg ) { | ||
log.error(msg); | ||
} | ||
// return undefined | ||
}) | ||
.then( (resource) => checkForDecomposableBundle(resource) ) | ||
.then( ({resource, decomposable}) => { | ||
const dependencyInfo = resource && resource.info; | ||
let promises = []; | ||
if ( isMultiModule(dependencyInfo) ) { | ||
// multi modules are not added, only their pieces (sub modules) | ||
promises = dependencyInfo.subModules.map( (included) => { | ||
return checkAndAddResource(included, depth + 1, | ||
"**** error: missing submodule " + included + ", included by " + resourceName); | ||
}); | ||
} else if ( resource != null ) { | ||
// trace.trace(" checking dependencies of " + resource.name ); | ||
selectedResources[resourceName] = resourceName; | ||
selectedResourcesSequence.push(resourceName); | ||
if ( decomposable ) { | ||
// bundles are not added, only their embedded modules | ||
promises = dependencyInfo.subModules.map( (included) => { | ||
return checkAndAddResource(included, depth + 1, | ||
"**** error: missing submodule " + included + ", included by " + resourceName); | ||
}); | ||
} else if ( resource != null ) { | ||
// trace.trace(" checking dependencies of " + resource.name ); | ||
selectedResources[resourceName] = resourceName; | ||
selectedResourcesSequence.push(resourceName); | ||
// trace.info(" collecting %s", resource.name); | ||
// trace.info(" collecting %s", resource.name); | ||
// add dependencies, if 'resolve' is configured | ||
if ( section.resolve && dependencyInfo ) { | ||
promises = dependencyInfo.dependencies.map( function(required) { | ||
// ignore conditional dependencies if not configured | ||
if ( !section.resolveConditional | ||
&& dependencyInfo.isConditionalDependency(required) ) { | ||
return; | ||
} | ||
// add dependencies, if 'resolve' is configured | ||
if ( section.resolve && dependencyInfo ) { | ||
promises = dependencyInfo.dependencies.map( function(required) { | ||
// ignore conditional dependencies if not configured | ||
if ( !section.resolveConditional | ||
&& dependencyInfo.isConditionalDependency(required) ) { | ||
return; | ||
} | ||
return checkAndAddResource( required, depth + 1, | ||
"**** error: missing module " + required + ", required by " + resourceName); | ||
}); | ||
} | ||
return checkAndAddResource( required, depth + 1, | ||
"**** error: missing module " + required + ", required by " + resourceName); | ||
}); | ||
} | ||
// add renderer, if 'renderer' is configured and if it exists | ||
if ( section.renderer ) { | ||
const rendererModuleName = UI5ClientConstants.getRendererName( resourceName ); | ||
promises.push( checkAndAddResource( rendererModuleName, depth + 1) ); | ||
// add renderer, if 'renderer' is configured and if it exists | ||
if ( section.renderer ) { | ||
const rendererModuleName = UI5ClientConstants.getRendererName( resourceName ); | ||
promises.push( checkAndAddResource( rendererModuleName, depth + 1) ); | ||
} | ||
} | ||
} | ||
return Promise.all( promises.filter( ($) => $ ) ); | ||
}, function(err) { | ||
if ( msg ) { | ||
log.error(msg); | ||
} | ||
}); // what todo after resource has been visited? | ||
return Promise.all( promises.filter( ($) => $ ) ); | ||
}); | ||
@@ -124,0 +142,0 @@ if ( dependencyTracker != null ) { |
@@ -64,31 +64,34 @@ "use strict"; | ||
if ( /\.js$/.test(resource.name) ) { | ||
// console.log("analyzing %s", resource.file); | ||
const code = await resource.buffer(); | ||
info.size = code.length; | ||
const promises = []; | ||
try { | ||
const ast = esprima.parseScript(code.toString(), {comment: true}); | ||
jsAnalyzer.analyze(ast, resource.name, info); | ||
new XMLCompositeAnalyzer(pool).analyze(ast, resource.name, info); | ||
} catch (error) { | ||
log.error("failed to parse or analyze %s:", resource.name, error); | ||
} | ||
if ( rawInfo ) { | ||
// modules for which a raw-info was modelled should not be analyzed | ||
// otherwise, we detect the internal dependencies of sap-viz.js, but can't handle them | ||
// as we don't have access to the individual modules | ||
info.rawModule = true; | ||
// console.log("adding preconfigured dependencies for %s:", resource.name, rawInfo.dependencies); | ||
rawInfo.dependencies.forEach( (dep) => info.addDependency(dep) ); | ||
} else { | ||
// console.log("analyzing %s", resource.file); | ||
const code = await resource.buffer(); | ||
info.size = code.length; | ||
const promises = []; | ||
try { | ||
const ast = esprima.parseScript(code.toString(), {comment: true}); | ||
jsAnalyzer.analyze(ast, resource.name, info); | ||
new XMLCompositeAnalyzer(pool).analyze(ast, resource.name, info); | ||
} catch (error) { | ||
log.error("failed to parse or analyze %s:", resource.name, error); | ||
if ( rawInfo.requiresTopLevelScope ) { | ||
info.requiresTopLevelScope = true; | ||
} | ||
if ( /(?:^|\/)Component\.js/.test(resource.name) ) { | ||
promises.push( | ||
new ComponentAnalyzer(pool).analyze(resource, info), | ||
new SmartTemplateAnalyzer(pool).analyze(resource, info), | ||
new FioriElementsAnalyzer(pool).analyze(resource, info) | ||
); | ||
if ( rawInfo.ignoredGlobals ) { | ||
info.ignoredGlobals = rawInfo.ignoredGlobals; | ||
} | ||
} | ||
if ( /(?:^|\/)Component\.js/.test(resource.name) ) { | ||
promises.push( | ||
new ComponentAnalyzer(pool).analyze(resource, info), | ||
new SmartTemplateAnalyzer(pool).analyze(resource, info), | ||
new FioriElementsAnalyzer(pool).analyze(resource, info) | ||
); | ||
} | ||
await Promise.all(promises); | ||
} | ||
await Promise.all(promises); | ||
// console.log(info); | ||
@@ -95,0 +98,0 @@ } else if ( /\.view.xml$/.test(resource.name) ) { |
@@ -13,2 +13,11 @@ const log = require("@ui5/logger").getLogger("builder:tasks:bundlers:generateLibraryPreload"); | ||
{ | ||
// exclude the content of sap-ui-core by declaring it as 'provided' | ||
mode: "provided", | ||
filters: [ | ||
"ui5loader-autoconfig.js", | ||
"sap/ui/core/Core.js" | ||
], | ||
resolve: true | ||
}, | ||
{ | ||
mode: "preload", | ||
@@ -18,2 +27,5 @@ filters: [ | ||
`!${namespace}/.library`, | ||
`!${namespace}/designtime/`, | ||
`!${namespace}/**/*.designtime.js`, | ||
`!${namespace}/**/*.support.js`, | ||
`!${namespace}/themes/`, | ||
@@ -26,3 +38,2 @@ `!${namespace}/cldr/`, | ||
"sap/ui/base/", | ||
"sap/ui/xml/", | ||
"sap/ui/dom/", | ||
@@ -35,12 +46,17 @@ "sap/ui/events/", | ||
// files are already part of sap-ui-core.js | ||
"!sap/ui/thirdparty/baseuri.js", | ||
"!sap/ui/thirdparty/es6-promise.js", | ||
"!sap/ui/thirdparty/es6-string-methods.js", | ||
"!sap/ui/thirdparty/mdn-object-assign.js", | ||
"!jquery.sap.global.js", | ||
"!ui5loader-autoconfig.js", | ||
"!ui5loader.js", | ||
"!ui5loader-amd.js", | ||
"!sap-ui-*.js" | ||
// include only thirdparty that is very likely to be used | ||
"sap/ui/thirdparty/crossroads.js", | ||
"sap/ui/thirdparty/caja-htmlsanitizer.js", | ||
"sap/ui/thirdparty/hasher.js", | ||
"sap/ui/thirdparty/signals.js", | ||
"sap/ui/thirdparty/jquery-mobile-custom.js", | ||
"sap/ui/thirdparty/jqueryui/jquery-ui-core.js", | ||
"sap/ui/thirdparty/jqueryui/jquery-ui-position.js", | ||
// other excludes (not required for productive scenarios) | ||
"!sap-ui-*.js", | ||
"!sap/ui/core/support/", | ||
"!sap/ui/core/plugin/DeclarativeSupport.js", | ||
"!sap/ui/core/plugin/LessSupport.js" | ||
], | ||
@@ -63,2 +79,5 @@ resolve: false, | ||
`!${namespace}/.library`, | ||
`!${namespace}/designtime/`, | ||
`!${namespace}/**/*.designtime.js`, | ||
`!${namespace}/**/*.support.js`, | ||
`!${namespace}/themes/`, | ||
@@ -240,3 +259,7 @@ `!${namespace}/messagebundle*` | ||
options: { | ||
bundleDefinition: getBundleDefinition(libraryNamespace) | ||
bundleDefinition: getBundleDefinition(libraryNamespace), | ||
bundleOptions: { | ||
optimize: true, | ||
usePredefineCalls: true | ||
} | ||
}, | ||
@@ -243,0 +266,0 @@ resources |
{ | ||
"name": "@ui5/builder", | ||
"version": "1.5.2", | ||
"version": "1.5.3", | ||
"description": "UI5 Tooling - Builder", | ||
@@ -5,0 +5,0 @@ "author": "SAP SE (https://www.sap.com)", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
633656
16731