@nxworker/workspace
Version:
Nx plugin providing generators for managing workspace files, including the move-file generator for safely moving files between projects while updating all imports
24 lines (23 loc) • 1.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "updateMovedFileImportsIfNeeded", {
enumerable: true,
get: function() {
return updateMovedFileImportsIfNeeded;
}
});
const _updaterelativeimportsinmovedfile = require("./update-relative-imports-in-moved-file");
const _updaterelativeimportstoaliasinmovedfile = require("./update-relative-imports-to-alias-in-moved-file");
function updateMovedFileImportsIfNeeded(tree, ctx, cachedTreeExistsFn) {
const { isSameProject, normalizedSource, normalizedTarget, sourceProject, sourceImportPath } = ctx;
if (isSameProject) {
// For same-project moves, update relative imports to maintain correct paths
(0, _updaterelativeimportsinmovedfile.updateRelativeImportsInMovedFile)(tree, normalizedSource, normalizedTarget);
} else if (sourceImportPath) {
// For cross-project moves, convert relative imports to the source project to alias imports
(0, _updaterelativeimportstoaliasinmovedfile.updateRelativeImportsToAliasInMovedFile)(tree, normalizedSource, normalizedTarget, sourceProject, sourceImportPath, cachedTreeExistsFn);
}
}
//# sourceMappingURL=update-moved-file-imports-if-needed.js.map