# openai-langchain **Repository Path**: githubgay/openai-langchain ## Basic Information - **Project Name**: openai-langchain - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-01-19 - **Last Updated**: 2024-01-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 使用 1. package.json配置 ``` "main": "./dist/index.js" : rollup.config.js 使用,commonjs 模式打包文件 "module": "./dist/index.esm.js": rollup.config.js 使用,es module 模式打包文件 "umd": "./dist/index.umd.js": rollup.config.js 使用,umd 模式打包文件 "types": "./dist/types/index.d.ts": 类型声明文件入口 ``` 2. 新增以下 npm script: - `"clean:dist": "rimraf dist"` : 清空 dist 目录。 - `"build:types": "npm run clean:dist && tsc -b ./tsconfig.types.json"` : 编译 TypeScript 类型声明文件。 - `"build": "npm run build:types && rollup -c"`:打包,包括 TypeScript 类型声明文件和库文件。 - `"test": "node test/test.js"`: 执行测试文件。 - `"pretest": "npm run build"`:test 前置命令,执行 npm run test 前会限制性该命令。 ## 搭建 Rollup + TypeScript 工程 1. 初始化typescript项目 ``` npm init -y tsc --init ``` 2. 依赖项配置 - Rollup 相关 - rollup - @rollup/plugin-node-resolve:解析第三方库依赖(即 node_module 内的依赖) - @rollup/plugin-commonjs:识别 commonjs 格式依赖 - rollup-plugin-terser:(可选)代码压缩 - TypeScript 相关 - typescript - rollup-plugin-typescript2:编译 TypeScript - babel 相关 - @rollup/plugin-babel:rollup babel 插件 - @babel/preset-env:babel 预设 - @babel/plugin-transform-runtime:转义代码 - 编译配置 - rollup.config.js: rolup 配置文件 打包后的输出文件模式有 commonjs,es module,umd 等。 - tsconfig.json 及类型编译配置 tsconfig.types.json - 这里我们将 TypeScript 配置分为两个配置文件:tsconfig.json(通用配置,rollup typescript 插件使用)和 tsconfig.types.json(编译 typescript 类型声明文件使用) - babel.config.js:babel 配置