bucklescript - 如何使用本地包中的原因模块
问题描述
我正在寻找一种从我的 Reason React 应用程序(名为 ApplicationA)中使用本地包(名为 bs-package)的方法。
bs-package 在 src 文件夹中有一个名为 ModuleA.re 的文件:
let greet_me = (me) => Js.log("Hello, " ++ me ++ "!");
在 ApplicationA 中,我做了:
npm install /path/to/bs-package
在 node_modules bs-package 现在显示为符号链接。
然后在 bsconfig 中将 bs-package 添加到 bs-dependencies
"bs-dependencies": [
"reason-react",
"bs-package",
],
然后在 ApplicationA 中运行 make world
bsb -make-world
现在在我的 Reason React 应用程序中
ModuleA.greet_me("John");
给我
未绑定模块 ModuleA
我错过了什么?
编辑
这是 bs-package 的配置文件
它是用
bsb -init bs-package -theme basic-reson
bsconfig.json
{
"name": "bs-pacakge",
"version": "0.1.0",
"sources": {
"dir" : "src",
"subdirs" : true
},
"package-specs": {
"module": "commonjs",
"in-source": true
},
"suffix": ".bs.js",
"bs-dependencies": [
],
"warnings": {
"error" : "+101"
},
"namespace": true,
"refmt": 3
}
包.json
{
"name": "bs-pacakge",
"version": "0.1.0",
"scripts": {
"build": "bsb -make-world",
"start": "bsb -make-world -w",
"clean": "bsb -clean-world"
},
"keywords": [
"BuckleScript"
],
"author": "",
"license": "MIT",
"devDependencies": {
"bs-platform": "^5.0.6"
}
}
正如建议的那样, bs-package 是命名空间的,所以这应该可以工作
BsPackage.ModuleA.greet_me("name")
但是出现同样的错误
未绑定模块 BsPackage
解决方案
显然这个错误来自我的 bs 平台版本。我刚刚从 6.2.1 版切换到 7.0.1 版,现在一切正常(我在 Windows 上)。
推荐阅读
- ios - 是否可以在 UITextView iOS 中更改选择颜色?
- javascript - 允许减号nodeJS表达式?
- sql - 从没有另一个类似的表中选择行,不满足条件
- kubernetes - 将主机/本地环境变量传递给 Kubectl 'exec' 命令
- r - 防止在缺少日期时连接分开的点
- javascript - Django manifest.json 不加载图标
- javascript - 在 html 页面中嵌入 google drive 视频,以兼容 chrome、firefox 和 IE 的方式
- xml - 如果存在匹配的子元素,则对 XML 子节点进行分组
- r - 通过循环将多条曲线/函数添加到一个ggplot
- java - 从java中的列表json获取值