Skip to content

bsconfig.json missing package-specs causes module resolution errors #9

@justin808

Description

@justin808

Issue

The package ships with only ReScript source files (.res, .resi) but no compiled JavaScript output (.bs.js files). The bsconfig.json is missing the package-specs configuration needed to generate compiled files.

Environment

  • Package version: 1.4.0
  • Build tool: Rspack 1.5.8 / Webpack 5
  • ReScript: 11.1.4

Problem

When trying to use this package in a project, imports fail with:

Module not found: Can't resolve '@glennsl/rescript-json-combinators/src/Json.bs.js'

This happens because:

  1. The ReScript compiler generates imports like: import * as Json from "@glennsl/rescript-json-combinators/src/Json.bs.js"
  2. But the package only includes .res files in the published npm package
  3. The package's bsconfig.json doesn't include package-specs, so .bs.js files aren't generated

Current bsconfig.json

{
  "name": "@glennsl/rescript-json-combinators",
  "namespace": "JsonCombinators",
  "sources": [
    "src",
    {
      "dir": "examples",
      "type": "dev"
    }
  ]
}

Proposed Fix

Add package-specs and suffix to bsconfig.json:

{
  "name": "@glennsl/rescript-json-combinators",
  "namespace": "JsonCombinators",
  "sources": ["src"],
  "package-specs": [
    {
      "module": "esmodule",
      "in-source": true
    }
  ],
  "suffix": ".bs.js"
}

Also remove the examples directory reference since it doesn't exist in the published package.

Workaround

Currently using patch-package to apply this fix:

# patches/@glennsl+rescript-json-combinators+1.4.0.patch

Questions

  1. Is the intent to ship only source files and have consumers compile them?
  2. If so, should this be documented in the README?
  3. Or is this an oversight in the build/publish configuration?

Impact

This makes it difficult to use the package with modern bundlers (Webpack, Rspack, Vite) without manual patching.

References

  • Similar issue pattern in other ReScript packages
  • Standard practice is to either ship compiled files OR document the in-source build requirement

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions