Skip to content

Tweak heuristics to find the project root and "build root" #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

IwanKaramazow
Copy link
Contributor

@IwanKaramazow IwanKaramazow commented Nov 19, 2020

The project root means "this is a folder containing node_modules/bs-platform/{platform}/bsc.exe".
This path needs to be correct because it drives the formatter.
The "build root" represents the nearest directory containing a "bsconfig.json" file. "bsconfig.json" can be used to locate build artefacts and diagnostics.

The previous heuristics seemed to fail in the case users where using yarn workspaces.
Yarn workspaces seem to have the following layout:

/root
  /node_modules
  - package.json
  - yarn.lock
  /folder1
    /src
       - MyApp.res
    /node_modules
    - package.json
    - bsconfig.json

The compiler seems to be located in the node_modules under the root and not in the node_modules of folder1.
By searching for bscPartialPath instead of the nearest bsconfig.json, we can correctly determine the root.
However the bsconfig.json indicates the "build root" for the compiler artefacts and diagnostics in folder1.

Fixes #10

@IwanKaramazow IwanKaramazow changed the title Tweak heuristics to find the project root. Tweak heuristics to find the project root and "build root" Nov 19, 2020
@BlueHotDog
Copy link
Contributor

Actually, now looking at the code. my mistake, this seems to behave exactly as expected!

@danwetherald
Copy link

I have checked this branch out, ran a yarn compile, and nothing has changed, is there anything else needed to get this working?

Iwan added 2 commits December 11, 2020 08:10
The project root means "this is a folder containing node_modules/bs-platform/{platform}/bsc.exe".
This path needs to be correct because it drives the formatter.

The previous heuristics seemed to fail in the case users where using yarn workspaces.
Yarn workspaces seem to have the following layout:
```
/root
  /node_modules
  - package.json
  - yarn.lock
  /folder1
    /node_modules
    - package.json
    - bsconfig.json
```

The compiler seems to be located in the `node_modules` under the root and not in the `node_modules` of `folder1`.
By searching for `bscPartialPath` instead of the nearest `bsconfig.json`,
we can correctly determine the root.
the "build root" represents the nearest directory containing a "bsconfig.json" file.
"bsconfig.json" can be used to locate the nearest build artefacts and .compiler.log for diagnostics.
@ryyppy
Copy link
Member

ryyppy commented Jan 6, 2021

I think this PR is obsolete due to #59

@IwanKaramazow
Copy link
Contributor Author

Superseded by #59 and d75c664

@cristianoc cristianoc deleted the tweak-project-root-heuristics branch April 27, 2021 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bs binaries paths are determined wrong in monorepos
4 participants