我正在尝试使用我的VSCODDE肝脏服务器:https://github.com/ritwickdey/vscode-live-server进行开发,而不必运行a(parceljs是我的最爱,因为它具有热加载功能,但是它在Reasonml上有问题)。 >
这几乎可以用,但是bucketscript编译器期望节点模块位于路径上,并且看来捆绑器找到了它们,但是如果这样做的话不是这样:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8>
<link rel=stylesheet href="./style.css">
<title>Web Data Client</title>
<script src="../src/client/App.bs.js" type=module></script>
</head>
<body>
<div id="index"></div>
</body>
</html>
这是我得到的错误:
ncaught TypeError: Failed to resolve module specifier "react". Relative references must start with either "/", "./", or "../".
这是自BSB在此创建
以来所期望的import * as $$Array from "./../../node_modules/bs-platform/lib/es6/array.js";
import * as Block from "./../../node_modules/bs-platform/lib/es6/block.js";
import * as Curry from "./../../node_modules/bs-platform/lib/es6/curry.js";
import * as React from "react";
import * as Glamor from "./../../node_modules/bs-glamor/src/glamor.js";
import * as Js_exn from "./../../node_modules/bs-platform/lib/es6/js_exn.js";
import * as Js_dict from "./../../node_modules/bs-platform/lib/es6/js_dict.js";
import * as Js_json from "./../../node_modules/bs-platform/lib/es6/js_json.js";
import * as ReactDOMRe from "./../../node_modules/reason-react/src/ReactDOMRe.js";
import * as Caml_option from "./../../node_modules/bs-platform/lib/es6/caml_option.js";
import * as ReasonReact from "./../../node_modules/reason-react/src/ReasonReact.js";
import * as Editor$Webdataclient from "./Editor.bs.js";
import * as Loader$Webdataclient from "./Loader.bs.js";
import * as Mutations$Webdataclient from "./Mutations.bs.js";
现在,如果导入是从../node-modules/*文件夹中进行的,我想所有的操作都可以
// This is the configuration file used by BuckleScript's build system bsb.
// Its documentation lives here: http://bucklescript.github.io/bucklescript/docson/#build-schema.json
{
"name": "webdataclient",
"version": "0.1.0",
"sources": [
{
"dir": "src",
"subdirs": true
}
],
"package-specs": {
"module": "es6-global",
"in-source": true
},
"suffix": ".bs.js",
"namespace": true,
"reason": {
"react-jsx": 2
},
"refmt": 3,
"ppx-flags": [
"graphql_ppx/ppx"
],
"bs-dependencies": [
"reason-react",
"bs-fetch",
"bs-glamor"
]
}
答案 0 :(得分:0)
看起来BuckleScript不能使用es6-global
导入外部JavaScript模块,包括React。 The relevant GitHub issue is here。
问题是BuckleScript当前无法知道"react"
应该解析到的JavaScript文件的路径。 BuckleScript知道其编译模块的路径,因此它们可以正常工作。但是它对外部设备一无所知,因此它按原样输出它们的路径。