How to successfully use `reanalyze`?

I trying to setup dce analysis for a project. I have added this to our rescript.json

    "reanalyze": {
      "analysis": ["dce", "exception"],
      "suppress": ["test", "src/libs"]
    }

Rescript’s new build system issues a warning: The field ‘reanalyze’ found in the package config of ‘kaiko-survey-tool’ is not supported by ReScript 12’s new build system.

But running the legacy build system and then reanalyze -dce still prints warnings for suppressed directories:

  ...
  Warning Dead Type
  .../test/ServerSyncPipeline_test.res:112:21-33
  state.value is a record label never used to read a value
  <-- line 112
        type state = {@dead("state.value") value: string}

Is there a way to actually suppress the warnings?

What version of Rescript do you use? This false warning was removed in the latest version if I remember correctly.

@tsnobip

I’m using 12.1.0:

$ rescript --version
rescript 12.1.0

$ rescript          
[1/3] 🧹 Cleaned previous build due to compiler update
[1/3] 🧹 Cleaned 0/0 in 0.26s
[2/3] 🧱 Parsed 896 source files in 1.15s
[3/3] 🤺 Compiled 896 modules in 6.31s

The field 'reanalyze' found in the package config of 'kaiko-survey-tool' is not supported by ReScript 12's new build system.

✨ Finished Compilation in 7.74s

So to use reanalyze I run first rescript-legacy.

Can you try with 12.2.0-rc.1?

@fham

With version 12.2.0-rc.1 the warning in the compilation is gone. Good.

However, it still shows DCE warnings for files under test and src/libs; which I have in the suppress list:

    "reanalyze": {
      "analysis": ["dce", "exception"],
      "suppress": ["test", "src/libs"]
    }

Example:

  Warning Dead Type
  /home/manu/src/kaiko/frontend-reanalyze/src/libs/webapi/MediaTrackConstraints.res:20:3-32
  t.groupId is a record label never used to read a value

This is merely the bindings of the type; so I rather leave it complete, so that the application could use it if needed.

@cristianoc this should work, right?

as a workaround with that version you can annotate whole files with

@@live

at the top to suppress warnings also.

1 Like

Also suppressing in rescript.json works fine, but it seems to only pick it up from the root rescript.json if you have a monorepo layout.

e.g.

  "reanalyze": {
    "suppress": [
      "my-package/text",
      "my-package/src/libs"
    ]
  }
1 Like

12.2.0 is out now btw.

2 Likes