From be284826a38aa24e3858b2581f254fcc34598555 Mon Sep 17 00:00:00 2001 From: Colum Ferry Date: Fri, 16 Dec 2022 10:48:11 +0000 Subject: [PATCH] fix(core): move generator should work if there are comments in tsconfig #13740 --- packages/workspace/src/generators/move/lib/update-imports.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/workspace/src/generators/move/lib/update-imports.ts b/packages/workspace/src/generators/move/lib/update-imports.ts index eb935048ef0825..d66cfbdd4d6126 100644 --- a/packages/workspace/src/generators/move/lib/update-imports.ts +++ b/packages/workspace/src/generators/move/lib/update-imports.ts @@ -17,6 +17,7 @@ import { findNodes } from 'nx/src/utils/typescript'; import { NormalizedSchema } from '../schema'; import { normalizeSlashes } from './utils'; import { relative } from 'path'; +import { parse } from 'jsonc-parser'; /** * Updates all the imports in the workspace and modifies the tsconfig appropriately. @@ -42,7 +43,7 @@ export function updateImports( let tsConfig: any; let fromPath: string; if (tree.exists(tsConfigPath)) { - tsConfig = JSON.parse(tree.read(tsConfigPath).toString('utf-8')); + tsConfig = parse(tree.read(tsConfigPath).toString('utf-8')); fromPath = Object.keys(tsConfig.compilerOptions.paths).find((path) => tsConfig.compilerOptions.paths[path].some((x) => x.startsWith(project.sourceRoot)