Skip to content

Commit 0ebe59c

Browse files
authored
fix(js): handle resolution from within node_module in the sync generator (#29412)
closed #29411 <!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> The resolve function from ts.System returning the full path, and so including the workspaceRoot that is also append by the FsTree ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> Resolution within node_modules are correctly followed ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #29411
1 parent 2db82dd commit 0ebe59c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

packages/js/src/generators/typescript-sync/typescript-sync.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,20 @@ export async function syncGenerator(tree: Tree): Promise<SyncGeneratorResult> {
114114
const tsSysFromTree: ts.System = {
115115
...ts.sys,
116116
fileExists(path) {
117-
return tsconfigExists(tree, tsconfigInfoCaches, path);
117+
// Given ts.System.resolve resolve full path for tsconfig within node_modules
118+
// We need to remove the workspace root to ensure we don't have double workspace root within the Tree
119+
const correctPath = path.startsWith(tree.root)
120+
? relative(tree.root, path)
121+
: path;
122+
return tsconfigExists(tree, tsconfigInfoCaches, correctPath);
118123
},
119124
readFile(path) {
120-
return readRawTsconfigContents(tree, tsconfigInfoCaches, path);
125+
// Given ts.System.resolve resolve full path for tsconfig within node_modules
126+
// We need to remove the workspace root to ensure we don't have double workspace root within the Tree
127+
const correctPath = path.startsWith(tree.root)
128+
? relative(tree.root, path)
129+
: path;
130+
return readRawTsconfigContents(tree, tsconfigInfoCaches, correctPath);
121131
},
122132
};
123133

0 commit comments

Comments
 (0)