From c08b0d34bc88525ccfc272569452d59a67d0755d Mon Sep 17 00:00:00 2001 From: Garrett Graves Date: Tue, 9 Jul 2024 15:32:49 -0700 Subject: [PATCH] split out browser bundling --- package.json | 1 + scripts/bundle.sh | 7 +++++-- tsconfig.browser.json | 11 +++++++++++ tsconfig.json | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 tsconfig.browser.json diff --git a/package.json b/package.json index 46a8251..61cf739 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "types": "dist/index.d.ts", "scripts": { "build": "tsc -p tsconfig.json", + "build:browser": "tsc -p tsconfig.browser.json", "test": "tsx --test test/*" }, "repository": { diff --git a/scripts/bundle.sh b/scripts/bundle.sh index 6d8be4c..305da6e 100755 --- a/scripts/bundle.sh +++ b/scripts/bundle.sh @@ -1,8 +1,11 @@ #!/bin/bash -npm run build +# NOTE: This script is used to bundle the recorder.js file for the browser. +# It is highly experimental and may not work as expected. Use at your own risk. -browserify dist/recorder/recorder.js -o dist/browser/bundle.js +npm run build:browser + +browserify dist/browser/tsc/recorder.js -o dist/browser/bundle.js # Use sed to insert the new string after the line containing the search string sed -i '' "/exports.BrowserbaseCodeGenerator = BrowserbaseCodeGenerator;/a\\ diff --git a/tsconfig.browser.json b/tsconfig.browser.json new file mode 100644 index 0000000..2ad52b1 --- /dev/null +++ b/tsconfig.browser.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "outDir": "dist/browser/tsc", + "declaration": true, + "lib": ["ESNext", "DOM"], + "module": "NodeNext", + "target": "es2016", + "moduleResolution": "NodeNext" + }, + "include": ["src/recorder/recorder.ts"] +} diff --git a/tsconfig.json b/tsconfig.json index a405fef..9f711e7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,7 @@ "declaration": true, "lib": ["ESNext", "DOM"], "module": "NodeNext", - "target": "es2016", + "target": "ESNext", "moduleResolution": "NodeNext" }, "include": ["src/**/*.ts"]