问题描述
我想将此文件作为浏览器中的 es 模块获取。 HelloApp.tsx
import React from "react";
import { render } from "react-dom";
function HelloApp(props: any): React.ReactElement {
return <div>Greetings</div>
}
render(
<HelloApp />,document.getElementById("app")
);
我正在运行 npx esbuild ./**/*.tsx --outdir=esbuilt --format=esm
输出:
import React from "react";
import {render} from "react-dom";
function HelloApp(props) {
return /* @__PURE__ */ React.createElement("div",null,"I'm a component");
}
render(/* @__PURE__ */ React.createElement(HelloApp,null),document.getElementById("app"));
浏览器无法使用这些导入。理想情况下,路径类似于 import React from "/scripts/react.js"
你如何告诉 esbuild 编写这样的导入?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)