You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, if I create two ML modules in separate files,
$ cat src/test.ml
let hi _ = print_endline "Hello"
$ cat src/test_sub.ml
let sup _ = print_endline "Sup"
$ cat src/blah.js
const Test = require('./test.bs')
const Sub = require('./test_sub.bs')
Test.hi()
Sub.sup()
$ node src/blah.js
Hello
Sup
… but if I inline one of those into another, parent module …
$ cat src/test2.ml
let hi _ = print_endline "Hello"
$ cat src/blah2.js
const Test = require('./test2.bs')
const Sub = Test.Sub
console.log("Test.hi:", typeof Test.hi)
console.log("Sub.sup:", typeof Sub.sup)
console.log("Sub:", typeof Sub)
console.log("Sub (JSON):")
console.log(Sub)
$ node src/blah2.js
Test.hi: function
Sub.sup: undefined
Sub: object
Sub (JSON):
[ [Function: sup] ]
Is that … an array of functions? What!?
Coming from ML, where submodules are very often used to break down APIs, in exactly the same way as is done in JavaScript — Jest.Runner.Only over here, require('mocha').reporters.Base over there.
I can fake this by basically manually constructing my entire ‘to be exported’ API in a special file which then becomes the "main" for npm; but I really think it's preferable for BuckleScript to, with minimum effort, publicize exactly the API that one's ML interfaces already expose … no?
I hope this feedback is useful! I found this behaviour very surprising.
The text was updated successfully, but these errors were encountered:
hi @ELLIOTTCABLE Yes, this is an known prioritized issue. There are some technical challenges to change the current runtime representation of submodules, once we finish upgrading to the new compiler, we will revisit the issue.
I really can't comprehend BuckleScript's design-choices re: submodules, here. I mean, the module-system is so dang important to a ML ...
Anyway. Consider this pending <rescript-lang/rescript-compiler#2948>, I guess.
Currently, if I create two ML modules in separate files,
… but if I inline one of those into another, parent module …
Is that … an array of functions? What!?
Coming from ML, where submodules are very often used to break down APIs, in exactly the same way as is done in JavaScript —
Jest.Runner.Only
over here,require('mocha').reporters.Base
over there.I can fake this by basically manually constructing my entire ‘to be exported’ API in a special file which then becomes the
"main"
for npm; but I really think it's preferable for BuckleScript to, with minimum effort, publicize exactly the API that one's ML interfaces already expose … no?I hope this feedback is useful! I found this behaviour very surprising.
The text was updated successfully, but these errors were encountered: