Skip to content

ESM default imports when using @scope #8335

@CarlOlson

Description

@CarlOlson

Playground: https://rescript-lang.org/try?version=v12.0.0-beta.12&module=esmodule&code=LYewJgrgNgpgBAWXARjgXjgbwFBzgFwE8AHefXOAAVElgAoAiG5BgSjhgA98YAnAOwCGUAgC4C6OAzAwAZoOj4GFSgGcY-MFVUBjEKUac2HbnyEjZ-cXXwAaOAEt++dmgB8cCPwf5JDS8p4sL6WkpY29gD6rNgAvtjYNNDwSGAATJI4eNTgyYw0acZqegaMMvKKDPYMRqzsXDwCwnCW4k6+7p7eHVIBFMEt-GH8cdhAA

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.

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