Skip to content

Commit

Permalink
feat: decrease bundle size (#1010)
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu-dixit authored Dec 18, 2024
1 parent 5bb3ea8 commit feb8222
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/python @angrybayblade @tushar-composio
/js @himanshu-dixit @plxity
/js @himanshu-dixit @plxity @utkarsh-dixit
6 changes: 5 additions & 1 deletion .github/workflows/release_js_sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,19 @@ jobs:
- name: Install packages in js folder
run: pnpm install --frozen-lockfile

- name: Bump version
run: ./bump_version.sh ${{ github.event.inputs.version }}

- name: Set publishing config
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

- name: pnpm build
run: pnpm build

- name: pnpm publish
working-directory: js/dist
run: |
if ${{ github.event.inputs.isRCRelease }}; then
pnpm publish --no-git-checks --tag rc
Expand Down
9 changes: 9 additions & 0 deletions js/TO_DOs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
List of things to do for Composio JS SDK
- [ ] Decrease bundle size more to less than 500 kb.
- [ ] Move away from axios
- [ ] Optimise code from openapi spec
- [ ] Move away from class based to functional based code
- [ ] Add react code library
- [ ] Add support via browserify
- [ ] Add more edge cases
- [ ] Sign JS SDK CLIs
27 changes: 27 additions & 0 deletions js/bump_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# Get the current version from package.dist.json and package.json
current_version=$(grep '"version":' package.dist.json | cut -d'"' -f4)
current_version_pkg=$(grep '"version":' package.json | cut -d'"' -f4)

# Get new version from argument or prompt user
if [ -z "$1" ]; then
echo "Current version in package.dist.json is: $current_version"
echo "Current version in package.json is: $current_version_pkg"
echo "Enter new version:"
read new_version
else
new_version=$1
fi

# Update version in package.dist.json
sed -i.bak "s/\"version\": \"$current_version\"/\"version\": \"$new_version\"/" package.dist.json && rm package.dist.json.bak

# Update version in package.json
sed -i.bak "s/\"version\": \"$current_version_pkg\"/\"version\": \"$new_version\"/" package.json && rm package.json.bak

# Update version in src/constants.js
sed -i.bak "s/COMPOSIO_VERSION = \`$current_version\`/COMPOSIO_VERSION = \`$new_version\`/" src/constants.js && rm src/constants.js.bak

echo "Version updated from $current_version to $new_version in package.dist.json"
echo "Version updated from $current_version_pkg to $new_version in package.json"
19 changes: 19 additions & 0 deletions js/package.dist.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "composio-core",
"version": "0.4.4-beta",
"description": "",
"main": "index.js",
"scripts": {},
"bin": {
"composio-js": "./cli/index",
"composio": "./cli/index"
},
"lint-staged": {},
"keywords": [],
"author": "Utkarsh Dixit <utkarsh@composio.dev>",
"license": "ISC",
"devDependencies": {},
"publishConfig": {
"access": "public"
}
}
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "composio-core",
"version": "0.4.6",
"version": "0.5.0-beta-1",
"description": "",
"main": "dist/index.js",
"scripts": {
Expand Down
12 changes: 3 additions & 9 deletions js/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const generateBundleAndTypeBundles = (file) => {
{
file: `dist/${file}.js`,
format: 'cjs',
sourcemap: true
sourcemap: false
},
],
plugins: [
Expand Down Expand Up @@ -48,7 +48,7 @@ export default [
output: {
file: 'dist/cli/index.js',
format: 'cjs',
sourcemap: true,
sourcemap: false,
},
plugins: [
resolve(), // Resolve node_modules
Expand All @@ -66,11 +66,5 @@ export default [
// List any external dependencies here
]
},
...generateBundleAndTypeBundles('index'),
...generateBundleAndTypeBundles('frameworks/cloudflare'),
...generateBundleAndTypeBundles('frameworks/langchain'),
...generateBundleAndTypeBundles('frameworks/openai'),
...generateBundleAndTypeBundles('frameworks/langgraph'),
...generateBundleAndTypeBundles('frameworks/vercel'),
...generateBundleAndTypeBundles('sdk/index'),
...generateBundleAndTypeBundles('index')
];
4 changes: 2 additions & 2 deletions js/setup_cli.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# cp src/constants.js dist/cli/constants.js
cp src/constants.js dist/constants.js
# mv lib/src/cli/index.js lib/src/cli/index
cat <<EOF > temp_file
#!/usr/bin/env node
$(cat dist/cli/index.js)
Expand All @@ -9,4 +8,5 @@ mv temp_file dist/cli/index

rm dist/cli/index.js


cp package.dist.json dist/package.json
cp README.md dist/README.md

0 comments on commit feb8222

Please sign in to comment.