diff --git a/packages/workspace/src/generators/move/lib/update-imports.ts b/packages/workspace/src/generators/move/lib/update-imports.ts index 0a027347d3..5b4b0c5f28 100644 --- a/packages/workspace/src/generators/move/lib/update-imports.ts +++ b/packages/workspace/src/generators/move/lib/update-imports.ts @@ -102,16 +102,18 @@ export function updateImports( from: mainEntryPointImportPath, to: schema.importPath, }, - ...secondaryEntryPointImportPaths.map((p) => ({ - from: p, - // if the import path doesn't start with the main entry point import path, - // it's a custom import path we don't know how to update the name, we keep - // it as-is, but we'll update the path it points to - to: - schema.importPath && p.startsWith(mainEntryPointImportPath) - ? p.replace(mainEntryPointImportPath, schema.importPath) - : null, - })), + ...(secondaryEntryPointImportPaths + ? secondaryEntryPointImportPaths.map((p) => ({ + from: p, + // if the import path doesn't start with the main entry point import path, + // it's a custom import path we don't know how to update the name, we keep + // it as-is, but we'll update the path it points to + to: + schema.importPath && p.startsWith(mainEntryPointImportPath) + ? p.replace(mainEntryPointImportPath, schema.importPath) + : null, + })) + : []), ]; if ( diff --git a/packages/workspace/src/generators/move/move.spec.ts b/packages/workspace/src/generators/move/move.spec.ts index cdf9f52a60..54713188e9 100644 --- a/packages/workspace/src/generators/move/move.spec.ts +++ b/packages/workspace/src/generators/move/move.spec.ts @@ -129,4 +129,20 @@ describe('move', () => { '../../node_modules/nx/schemas/project-schema.json' ); }); + + it('should work without tsconfig.base.json (https://github.com/nrwl/nx/issues/28349)', async () => { + await libraryGenerator(tree, { + directory: 'my-lib', + }); + tree.delete('tsconfig.base.json'); + + await moveGenerator(tree, { + projectName: 'my-lib', + importPath: '@proj/shared-mylib', + updateImportPath: true, + destination: 'shared/my-lib-new', + }); + + expect(tree.exists('tsconfig.base.json')).toBeFalsy(); + }); });