From 1ba2c213fe2c5c5c289fe02977fb4407beebda08 Mon Sep 17 00:00:00 2001 From: Nir Gazit Date: Mon, 6 May 2024 17:05:03 +0200 Subject: [PATCH] fix(chromadb): use rollup --- .../instrumentation-chromadb/package.json | 2 +- .../instrumentation-chromadb/rollup.config.js | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 packages/instrumentation-chromadb/rollup.config.js diff --git a/packages/instrumentation-chromadb/package.json b/packages/instrumentation-chromadb/package.json index c668868c..1cf2a715 100644 --- a/packages/instrumentation-chromadb/package.json +++ b/packages/instrumentation-chromadb/package.json @@ -6,7 +6,7 @@ "types": "dist/src/index.d.ts", "repository": "traceloop/openllmetry-js", "scripts": { - "build": "tsc --build tsconfig.json", + "build": "rollup -c", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", "test": "ts-mocha -p tsconfig.json 'tests/**/*.test.ts' --timeout 20000" diff --git a/packages/instrumentation-chromadb/rollup.config.js b/packages/instrumentation-chromadb/rollup.config.js new file mode 100644 index 00000000..691c0ca5 --- /dev/null +++ b/packages/instrumentation-chromadb/rollup.config.js @@ -0,0 +1,37 @@ +const dts = require("rollup-plugin-dts"); +const typescript = require("@rollup/plugin-typescript"); +const json = require("@rollup/plugin-json"); + +// eslint-disable-next-line @typescript-eslint/no-var-requires +const name = require("./package.json").main.replace(/\.js$/, ""); + +const bundle = (config) => ({ + ...config, + input: "src/index.ts", + external: (id) => !/^[./]/.test(id), +}); + +exports.default = [ + bundle({ + plugins: [typescript.default(), json.default()], + output: [ + { + file: `${name}.js`, + format: "cjs", + sourcemap: true, + }, + { + file: `${name}.mjs`, + format: "es", + sourcemap: true, + }, + ], + }), + bundle({ + plugins: [dts.default()], + output: { + file: `${name}.d.ts`, + format: "es", + }, + }), +];