我正在使用 React、TypeScript 和 Rollup 创建一个可重用的组件库。
将此库捆绑到单个输出文件中index.js效果很好。但是,没有.js为我的各个组件生成输出文件。
但是,我正在努力确保我可以在我的 TypeScript 项目中使用特定的导入。
例如:import { ComponentA } from "my-components/lib/ComponentA;
这将确保我的其他组件在之后捆绑我的项目时不包括在内。
所以我的问题是:如何配置 Rollup 以便将所有组件也输出到单独的组件输出文件中?
我的文件结构如下:
src
? index.ts
??components
? index.ts
??ComponentA
? index.ts
? ComponentA.tsx
??ComponentB
index.ts
ComponentB.tsx
Run Code Online (Sandbox Code Playgroud)
我的汇总配置是:
import commonjs from "@rollup/plugin-commonjs";
import resolve from "@rollup/plugin-node-resolve";
import external from "rollup-plugin-peer-deps-external";
import typescript from "rollup-plugin-typescript2";
export default {
input: "src/index.ts",
output: [
{
file: pkg.main,
format: "cjs",
exports: "named",
sourcemap: true
},
{
file: pkg.module, …Run Code Online (Sandbox Code Playgroud) 我正在考虑将可重用的 Azure Functions 作为 NuGet 包发布,以便在其他项目中轻松使用它。这样我就可以在其他项目中引用NuGet包。这样我就可以动态地组合一组要部署到 Azure Function 服务的 Azure Functions。
目前这可能吗?或者,函数是否可以在外部程序集中定义,并由 Azure Function 主机“拾取”?
我知道使用 Azure WebJobs 可以做到这一点,但我还没有找到使用 Azure Functions 实现相同结果的方法。
const App = () =>{
const condition1 = true
const condition2 = false
return (
<div>
{condition1 || condition2 && <h1>condition met</h1>}
</div>
)
}
Run Code Online (Sandbox Code Playgroud)
上面的代码只关心条件2,条件1被忽略。有没有办法在我的 jsx 中使用 OR 运算符?我也尝试浏览此https://reactjs.org/docs/conditional-rendering.html但找不到我要找的东西。