-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Add ability to configure component preloads and custom bundles
- lbt: Ignore missing manifest.json errors - moduleBundler: Add parameter for custom bundle options - Use /resources as base for all bundle globs
- Loading branch information
Showing
81 changed files
with
949 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const moduleBundler = require("../../processors/bundlers/moduleBundler"); | ||
const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritized; | ||
|
||
/** | ||
* Generates a bundle based on the given bundle definition | ||
* | ||
* @module builder/tasks/bundlers/generateBundle | ||
* @param {Object} parameters Parameters | ||
* @param {DuplexCollection} parameters.workspace DuplexCollection to read and write files | ||
* @param {Collection} parameters.dependencies Collection to read dependency files | ||
* @param {Object} parameters.options Options | ||
* @param {string} parameters.options.projectName Project name | ||
* @param {Object} parameters.options.bundleDefintion Module bundle definition | ||
* @param {Object} parameters.options.bundleOptions Module bundle options | ||
* @returns {Promise} Promise resolving with undefined once data has been written | ||
*/ | ||
module.exports = function({workspace, dependencies, options}) { | ||
const combo = new ReaderCollectionPrioritized({ | ||
name: `libraryBundler - prioritize workspace over dependencies: ${options.projectName}`, | ||
readers: [workspace, dependencies] | ||
}); | ||
|
||
return combo.byGlob("/resources/**/*.{js,json,xml,html,properties,library}").then((resources) => { | ||
return moduleBundler({ | ||
options: { | ||
bundleDefinition: options.bundleDefinition, | ||
bundleOptions: options.bundleOptions | ||
}, | ||
resources | ||
}).then((bundles) => { | ||
bundles.forEach((bundle) => { | ||
workspace.write(bundle); | ||
}); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
const path = require("path"); | ||
const moduleBundler = require("../../processors/bundlers/moduleBundler"); | ||
const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritized; | ||
|
||
/** | ||
* Task to for application bundling. | ||
* | ||
* @module builder/tasks/bundlers/generateComponentPreload | ||
* @param {Object} parameters Parameters | ||
* @param {DuplexCollection} parameters.workspace DuplexCollection to read and write files | ||
* @param {AbstractReader} parameters.dependencies Reader or Collection to read dependency files | ||
* @param {Object} parameters.options Options | ||
* @param {string} parameters.options.projectName Project name | ||
* @param {Array} parameters.options.paths Array of paths (or glob patterns) for component files | ||
* @param {Array} parameters.options.namespaces Array of component namespaces | ||
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written | ||
*/ | ||
module.exports = function({workspace, dependencies, options}) { | ||
const combo = new ReaderCollectionPrioritized({ | ||
name: `generateComponentPreload - prioritize workspace over dependencies: ${options.projectName}`, | ||
readers: [workspace, dependencies] | ||
}); | ||
|
||
return combo.byGlob("/resources/**/*.{js,json,xml,html,properties,library}") | ||
.then(async (resources) => { | ||
let namespaces = []; | ||
if (options.paths) { | ||
namespaces = await Promise.all(options.paths.map(async (componentPath) => { | ||
const components = await combo.byGlob("/resources/" + componentPath); | ||
return components.map((component) => { | ||
console.log(component.getPath()); | ||
console.log(path.dirname(component.getPath())); | ||
return path.dirname(component.getPath()).replace(/^\/resources\//i, ""); | ||
}); | ||
})); | ||
} | ||
if (options.namespaces) { | ||
namespaces.push(...options.namespaces); | ||
} | ||
|
||
namespaces = Array.prototype.concat.apply([], namespaces); | ||
if (!namespaces || !namespaces.length) { | ||
throw new Error("generateComponentPreload: No component namespace(s) " + | ||
`found for project: ${options.projectName}`); | ||
} | ||
|
||
return Promise.all(namespaces.map((namespace) => { | ||
var filters = [ | ||
`${namespace}/`, | ||
`!${namespace}/test/`, | ||
`!${namespace}/*.html` | ||
]; | ||
|
||
// Exclude other namespaces | ||
namespaces.forEach((ns) => { | ||
if (ns !== namespace && ns.indexOf(namespace) === 0) { | ||
filters.push(`!${ns}/`); | ||
} | ||
}); | ||
|
||
return moduleBundler({ | ||
resources, | ||
options: { | ||
bundleDefinition: { | ||
name: `${namespace}/Component-preload.js`, | ||
defaultFileTypes: [".js", ".fragment.xml", ".view.xml", ".properties", ".json"], | ||
sections: [ | ||
{ | ||
mode: "preload", | ||
filters: filters, | ||
resolve: false, | ||
resolveConditional: false, | ||
renderer: false | ||
} | ||
] | ||
} | ||
} | ||
}); | ||
})); | ||
}) | ||
.then((processedResources) => { | ||
return Promise.all(processedResources.map((resource) => { | ||
return workspace.write(resource[0]); | ||
})); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.