From 61ad9c3d21f56563d95bb5653cf1c7fad0190977 Mon Sep 17 00:00:00 2001 From: Jason Jean Date: Thu, 2 Nov 2023 12:54:30 -0400 Subject: [PATCH] =?UTF-8?q?fix(js):=20handle=20empty=20objects=20for=20mig?= =?UTF-8?q?ration=20to=20remove=20deprecated=20buil=E2=80=A6=20(#19996)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../remove-deprecated-build-options.spec.ts | 11 +++++++++++ .../update-17-0-0/remove-deprecated-build-options.ts | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/js/src/migrations/update-17-0-0/remove-deprecated-build-options.spec.ts b/packages/js/src/migrations/update-17-0-0/remove-deprecated-build-options.spec.ts index f5f0127ef8..b0def14c4b 100644 --- a/packages/js/src/migrations/update-17-0-0/remove-deprecated-build-options.spec.ts +++ b/packages/js/src/migrations/update-17-0-0/remove-deprecated-build-options.spec.ts @@ -53,6 +53,17 @@ describe('remove-deprecated-build-options', () => { await expect(migration(tree)).resolves.not.toThrow(); }); + it('should work if a target is an empty object', async () => { + addProjectConfiguration(tree, 'proj', { + root: 'proj', + targets: { + build: {}, + }, + }); + + await expect(migration(tree)).resolves.not.toThrow(); + }); + it('should not update community executors', async () => { addProjectConfiguration(tree, 'proj', { root: 'proj', diff --git a/packages/js/src/migrations/update-17-0-0/remove-deprecated-build-options.ts b/packages/js/src/migrations/update-17-0-0/remove-deprecated-build-options.ts index 46a2e3d3cf..7a834a1a9a 100644 --- a/packages/js/src/migrations/update-17-0-0/remove-deprecated-build-options.ts +++ b/packages/js/src/migrations/update-17-0-0/remove-deprecated-build-options.ts @@ -19,7 +19,8 @@ export default async function (tree: Tree) { for (const target of Object.values(projectConfig.targets)) { if ( - target.executor.startsWith('@nx/') && + target.executor?.startsWith('@nx/') && + target.options && ('buildableProjectDepsInPackageJsonType' in target.options || 'updateBuildableProjectDepsInPackageJson' in target.options) ) {