镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

cli for reanalyze #1108

Open
Open

Description

@tx46

for us non-vs code users, please give us a way to invoke the analyzer from a cli! :(

Activity

  1. fhammerschmidt commented on Jul 18, 2025

    @fhammerschmidt
    Member

    It's part of rescript-tools

    npm install --save-dev @rescript/tools
    npx rescript-tools reanalyze --help
    
  2. tx46 commented on Jul 18, 2025

    @tx46
    Author

    how do i get it to actually do something? i'm running it from the same dir that rescript.json/package.json is in

    ❯ npx rescript-tools reanalyze -all -config -debug
    
      Warning: can't find source dirs: lib/bs/.sourcedirs.json
      Types for cross-references will not be found.
    
    File References
    
    
      Termination Analysis Stats
      Files:0
      Recursive Blocks:0
      Functions:0
      Infinite Loops:0
      Hygiene Errors:0
      Cache Hits:0/0
    
      Analysis reported 0 issues
    
  3. fhammerschmidt commented on Jul 18, 2025

    @fhammerschmidt
    Member

    you need to build your project first in order to generate a lib/bs/.sourcedirs.json

  4. tx46 commented on Jul 18, 2025

    @tx46
    Author

    i'm building, but it's not generated. using rescript 12 beta1

  5. nojaf commented on Jul 18, 2025

    @nojaf
    Contributor

    And you might need some stuff in your rescript.json? Can't remember, will take a look at my setup once back at my desk.

  6. fhammerschmidt commented on Jul 18, 2025

    @fhammerschmidt
    Member
  7. tx46 commented on Jul 18, 2025

    @tx46
    Author
    ❯ npx rescript-tools reanalyze -config -all -debug
    
      Scanning lib/bs/src/Main.cmt Source:src/Main.res
    

    after rescript legacy build the sourcedirs file was generated. but i can't get it to do more than above. i also tried putting the reanalyze section in rescript.json. no difference

  8. tx46 commented on Jul 18, 2025

    @tx46
    Author

    is rescript v12 not supported or something? it literally doesn't do anything except output the above

  9. fhammerschmidt commented on Jul 18, 2025

    @fhammerschmidt
    Member

    right, the current published tools version is 9 months old
    at the very least we need to publish a new tools version first

    or is anything else missing @zth ?

  10. nojaf commented on Jul 18, 2025

    @nojaf
    Contributor

    Rescript-tools is part of the rescript npm package since v12. If you installed it separately that will be an incompatible version.

  11. tx46 commented on Jul 19, 2025

    @tx46
    Author

    Rescript-tools is part of the rescript npm package since v12. If you installed it separately that will be an incompatible version.

    all of this is kind of confusing. how do i actually run reanalyze for rescript v12?

  12. tx46 commented on Jul 19, 2025

    @tx46
    Author

    i actually think i got it working now by doing npx rescript legacy build and then npx rescript-tools reanalyze -all which seems to generate expected output more or less. it doesn't work without npx rescript legacy build though (because rewatch isn't generating .sourcedirs.json)

    also i'm getting tons of "argument unsused" for optional arguments in functions where i actually DO use the argument, is this expected?

  13. tx46 commented on Jul 19, 2025

    @tx46
    Author

    also this:

      toMins might raise Division_by_zero (Duration.res:22:42) and is not annotated with @raises(Division_by_zero)
    

    for:

    let toMillis = (d: t): float => d
    let toMins = (d: t): float => d->toMillis / 60_000.0
    

    is there a manual on how to work with reanalyze? i'm sure it'll be helpful i just need to understand what's going on (also sorry for turning this into some general question thread)

  14. nojaf commented on Jul 19, 2025

    @nojaf
    Contributor

    Okay, I'm able to confirm that our new build system does not support reanalyze.
    I had to use rescript legacy build to get reanalyze working. Will create an issue for that shortly.

    As for config I have:

    // rescript.json
      "reanalyze": {
        "analysis": ["dce"],
        "suppress": ["src/TailwindColors.res", "src/Scenes/Design.res"]
      },
    

    And I invoke it via npx rescript-tools reanalyze -json.

    Since v12, you do not need to install https://www.npmjs.com/package/@rescript/tools
    The binary is bundled as part of https://www.npmjs.com/package/rescript

  15. nojaf commented on Jul 19, 2025

    @nojaf
    Contributor

    Okay, turns out you need to pass --create-sourcedirs to your npx rescript build for rewatch to generate the lib/bs/.sourcedirs.json file in v12.

  16. tx46 commented on Jul 19, 2025

    @tx46
    Author

    thanks, but npx rescript build --create-sourcedirs creates an empty .sourcedirs.json:

    {"dirs":[],"generated":[],"pkgs":[]}

    while npx rescript legacy build actually populates it

  17. tx46 commented on Jul 19, 2025

    @tx46
    Author

    is there a way to turn off exception analysis warnings for panic calls? they don't make sense to me

    also: why am i getting division_by_zero warnings for things such as x / 10? is this a bug in reanalyze?

  18. nojaf commented on Jul 19, 2025

    @nojaf
    Contributor

    thanks, but npx rescript build --create-sourcedirs creates an empty .sourcedirs.json:

    {"dirs":[],"generated":[],"pkgs":[]}

    while npx rescript legacy build actually populates it

    Yes, I noticed that as well. We are working on a fix for that.

    Thanks for your patience 🙏

  19. tx46 commented on Jul 19, 2025

    @tx46
    Author

    thanks, but npx rescript build --create-sourcedirs creates an empty .sourcedirs.json:
    {"dirs":[],"generated":[],"pkgs":[]}
    while npx rescript legacy build actually populates it

    Yes, I noticed that as well. We are working on a fix for that.

    Thanks for your patience 🙏

    no problems, appreciating your feedback. is there an appropriate place to file issues for reanalyze? i think i'm finding a few bugs

  20. nojaf commented on Jul 19, 2025

    @nojaf
    Contributor

    Yeah the main rescript repository would be the right place for that. Much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions