-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[INTERNAL] Refactor code to create moduleNameMapping
- Loading branch information
Showing
6 changed files
with
56 additions
and
82 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const ModuleName = require("../../../lbt/utils/ModuleName"); | ||
|
||
/** | ||
* For "unoptimized" bundles, the non-debug files have already been filtered out above. | ||
* Now we need to create a mapping from the debug-variant resource path to the respective module | ||
* name, which is basically the non-debug resource path, minus the "/resources/"" prefix. | ||
* This mapping overwrites internal logic of the LocatorResourcePool which would otherwise determine | ||
* the module name from the resource path, which would contain "-dbg" in this case. That would be | ||
* incorrect since debug-variants should still keep the original module name. | ||
* | ||
* @private | ||
* @param {object} parameters Parameters | ||
* @param {module:@ui5/fs.Resource[]} parameters.resources List of resources | ||
* @param {module:@ui5/builder.tasks.TaskUtil|object} parameters.taskUtil TaskUtil | ||
* @returns {object} Module name mapping | ||
*/ | ||
module.exports = function({resources, taskUtil}) { | ||
const moduleNameMapping = {}; | ||
for (let i = resources.length - 1; i >= 0; i--) { | ||
const resourcePath = resources[i].getPath(); | ||
if (taskUtil.getTag(resourcePath, taskUtil.STANDARD_TAGS.IsDebugVariant)) { | ||
const nonDbgPath = ModuleName.getNonDebugName(resourcePath); | ||
if (!nonDbgPath) { | ||
throw new Error(`Failed to resolve non-debug name for ${resourcePath}`); | ||
} | ||
moduleNameMapping[resourcePath] = nonDbgPath.slice("/resources/".length); | ||
} | ||
} | ||
return moduleNameMapping; | ||
}; |
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