Skip to content

Document module alias are not for re-exports #2972

@zploskey

Description

@zploskey

This is based on a problem reported by user dvisz-inf in the Discord (github @dvisztempacct, I think) who was reporting on behalf of @scull7.

We create 3 bucklescript packages with a dependency relationship pkga -> pkgb -> pkgc.

(* pkgc/src/pkgc.ml *)
let hello name = "Hello " ^ name
(* pkgb/src/pkgb.ml *)
module C = Pkgc
(* pkga/src/demo.ml *)
let () = Js.log (Pkgb.C.hello "World!")

It fails to compile with:

> pkga@0.1.0 build /home/zach/src/bsdeps/pkga
> bsb -make-world

Duplicated package: bs-platform /home/zach/src/bsdeps/pkga/node_modules/bs-platform (chosen) vs /home/zach/src/bsdeps/pkga/node_modules/pkgb/node_modules/pkgc/node_modules/bs-platform in /home/zach/src/bsdeps/pkga/node_modules/pkgb/node_modules/pkgc 
[2/2] Building src/pkgc.mlast.d
[1/1] Building src/pkgc.cmj
Duplicated package: bs-platform /home/zach/src/bsdeps/pkga/node_modules/bs-platform (chosen) vs /home/zach/src/bsdeps/pkga/node_modules/pkgb/node_modules/bs-platform in /home/zach/src/bsdeps/pkga/node_modules/pkgb 
[2/2] Building src/pkgb.mlast.d
[1/1] Building src/pkgb.cmj
[2/2] Building src/demo.mlast.d
[1/1] Building src/demo.cmj
File "/home/zach/src/bsdeps/pkga/src/demo.ml", line 1, characters 17-29:
Error: Unbound value Pkgb.C.hello
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! pkga@0.1.0 build: `bsb -make-world`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the pkga@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Demonstration repo with instructions for commands to reproduce: https://github.com/zploskey/bsdeps
Each package only lists its direct dependency in bsconfig.json and package.json. In my testing adding pkgc to the bsconfig in pkga did not change the outcome.

I tested this on Ubuntu 18.04 x86_64 with w/ JS target (OCaml 4.02.3 + bucklescript) running on Node.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions