rescript-lang / rescript-lang/rescript
ESM default imports when using @scope
Open
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 7.5k
- Forks
- 485
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 55
Description
module Mod1 = {
type t
@module("mod1") external t: t = "default"
@send @scope("x") external fn: (t, int) => unit = "fn"
let fn = fn(t, _)
}
module Mod2 = {
@module("mod2") @scope(("default", "x")) external fn: int => unit = "fn"
let fn = fn
}
Using @scope results in a namespace import instead of a default import:
import Mod1 from "mod1";
import * as Mod2 from "mod2";
This shouldn't effect modern tree shakers, but I've noticed tooling, like linters, can be less effective.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Playground example and compare the generated imports for Mod1 and Mod2 when @scope is used. Trace the compiler path that handles scoped module imports, then verify that the affected default-import cases preserve default imports rather than emitting namespace imports.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, ocaml
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100