Skip to content

Commit

Permalink
fix(core): move generator should work if there are comments in tsconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 committed Dec 16, 2022
1 parent 578ecb6 commit 4618d0b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/workspace/package.json
Expand Up @@ -82,6 +82,7 @@
"fs-extra": "^10.1.0",
"glob": "7.1.4",
"ignore": "^5.0.4",
"jsonc-parser": "3.2.0",
"minimatch": "3.0.5",
"npm-run-path": "^4.0.1",
"open": "^8.4.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/workspace/src/generators/move/lib/update-imports.ts
Expand Up @@ -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.
Expand All @@ -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)
Expand Down

0 comments on commit 4618d0b

Please sign in to comment.