Skip to content

Commit 525bcca

Browse files
CammisulijaysooFrozenPandaz
authored
fix(core): replace posix.relative with relative for path resolution (#30783)
<!-- 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 --> Whenever using the new Typescript style repos (using package.json instead of project.json for typescript projects), we get incorrect paths when using `resolveImportWithRequire` on Windows. Currently when trying to find a path, we end up with a path similar to `../C:\\dev\\nx\\file.ts` which is incorrect. ## Expected Behavior Changing `posix.relative` to just relative, allows us to get the proper path on Windows like so: `.\\file.ts` ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes # Co-authored-by: Jack Hsu <jack.hsu@gmail.com> Co-authored-by: Jason Jean <jasonjean1993@gmail.com>
1 parent 6176d3a commit 525bcca

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/nx/src/plugins/js/project-graph/build-dependencies/target-project-locator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ export class TargetProjectLocator {
397397
normalizedImportExpr: string,
398398
filePath: string
399399
) {
400-
return posix.relative(
400+
return relative(
401401
workspaceRoot,
402402
require.resolve(normalizedImportExpr, {
403403
paths: [dirname(filePath)],

0 commit comments

Comments
 (0)