Skip to content

Commit

Permalink
test(melange): incorrect path when public lib depends on private lib
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro committed Apr 27, 2023
1 parent 59a64b2 commit 23dc067
Showing 1 changed file with 89 additions and 0 deletions.
89 changes: 89 additions & 0 deletions test/blackbox-tests/test-cases/melange/private-lib-dep.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
Melange public library depends on private library

$ cat > dune-project <<EOF
> (lang dune 3.8)
> (package (name foo))
> (using melange 0.1)
> EOF
$ mkdir -p priv
$ cat > priv/dune <<EOF
> (library
> (name priv)
> (package foo)
> (modes melange))
> EOF
$ cat > priv/priv.ml <<EOF
> let x = "private"
> EOF
$ mkdir -p lib
$ cat > lib/dune <<EOF
> (library
> (public_name foo)
> (modes melange)
> (libraries priv))
> EOF
$ cat > lib/foo.ml <<EOF
> let x = "public lib uses " ^ Priv.x
> EOF
$ cat > dune <<EOF
> (melange.emit
> (target output)
> (libraries foo)
> (emit_stdlib false))
> EOF
$ cat > entry.ml <<EOF
> let () = Js.log Foo.x
> EOF
$ dune build @melange --display=short
melc priv/.priv.objs/melange/priv.{cmi,cmj,cmt}
melc lib/.foo.objs/melange/foo.{cmi,cmj,cmt}
melc output/priv/priv.js
melc .output.mobjs/melange/melange__Entry.{cmi,cmj,cmt}
melc output/node_modules/foo/foo.js
melc output/entry.js
$ node _build/default/output/entry.js
node:internal/modules/cjs/loader:1078
throw err;
^
Error: Cannot find module 'priv/priv.js'
Require stack:
- $TESTCASE_ROOT/_build/default/output/node_modules/foo/foo.js
- $TESTCASE_ROOT/_build/default/output/entry.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
at Module._load (node:internal/modules/cjs/loader:920:27)
at Module.require (node:internal/modules/cjs/loader:1141:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object.<anonymous> ($TESTCASE_ROOT/_build/default/output/node_modules/foo/foo.js:4:12)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Module.require (node:internal/modules/cjs/loader:1141:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'$TESTCASE_ROOT/_build/default/output/node_modules/foo/foo.js',
'$TESTCASE_ROOT/_build/default/output/entry.js'
]
}
Node.js v18.15.0
[1]
$ cat _build/default/output/node_modules/foo/foo.js
// Generated by Melange
'use strict';
var Priv = require("priv/priv.js");
var x = "public lib uses " + Priv.x;
exports.x = x;
/* No side effect */

0 comments on commit 23dc067

Please sign in to comment.