小编Nse*_*ens的帖子

每个组件汇总 + Typescript 输出 JS 文件

我正在使用 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)

typescript rollupjs

5
推荐指数
1
解决办法
1603
查看次数

将 Azure Function 发布为 NuGet 包(或从外部程序集加载函数)

我正在考虑将可重用的 Azure Functions 作为 NuGet 包发布,以便在其他项目中轻松使用它。这样我就可以在其他项目中引用NuGet包。这样我就可以动态地组合一组要部署到 Azure Function 服务的 Azure Functions。

目前这可能吗?或者,函数是否可以在外部程序集中定义,并由 Azure Function 主机“拾取”?

我知道使用 Azure WebJobs 可以做到这一点,但我还没有找到使用 Azure Functions 实现相同结果的方法。

.net c# azure azure-webjobs azure-functions

2
推荐指数
1
解决办法
1423
查看次数

Reactjs(功能组件)使用OR语句进行条件渲染

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但找不到我要找的东西。

javascript jsx reactjs

2
推荐指数
1
解决办法
169
查看次数