bloodyowl / rescript-test

A lightweight test framework for ReScript
https://bloodyowl.github.io/rescript-test/
MIT License
78 stars 9 forks source link

Fails to detect suffix if suffix is defined in package-specs #3

Closed johnridesabike closed 3 years ago

johnridesabike commented 3 years ago

rescript-test tries to read the suffix at the top level of bsconfig.json like this:

{
  "suffix": ".mjs"
}

However, this is also a valid bsconfig.json:

{
  "package-specs": [
    {
      "in-source": false,
      "module": "es6",
      "suffix": ".mjs"
    },
    {
      "in-source": false,
      "module": "commonjs",
      "suffix": ".js"
    }
  ]
}

The suffix can be defined differently in each package-specs entry.

I wonder if the suffix should be an option explicitly passed to rescript-test?

bloodyowl commented 3 years ago

That's right, I forgot about this possibility.

Out of curiosity, why do you use both? And which one do you use for testing?

I'm wondering if we can still try to make a guess from configuration.

johnridesabike commented 3 years ago

I usually don't use both, but out of habit (and copy/pasting) I tend to put the suffix field in the package-specs even if I'm just using one.

One use case for using both is publishing JS that's compatible with both kinds of environments.

Although, it probably doesn't make sense to test both versions of the same code either way. IIRC, you can have both a top-level, default suffix that can be overwritten by individual package-specs. Maybe that could be the recommendation?

bloodyowl commented 3 years ago

Inferring it from the extensions of the resolved files you pass now.