Skip to content

Conversation

@sampaiodiego
Copy link
Member

@sampaiodiego sampaiodiego commented Sep 24, 2025

Summary by CodeRabbit

  • New Features

    • Automated SDK bundling pipeline producing a minified CommonJS build with sourcemaps.
    • Type declaration files are now generated for the SDK.
  • Chores

    • Package entry points/exports updated to point to the new build output.
    • Added a watch-mode bundling script for local development.
    • Adjusted ignore rules to cover bundle artifacts and improve repo hygiene.
    • Updated a dependency (zod) to a newer patch.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 24, 2025

Warning

Rate limit exceeded

@sampaiodiego has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 10 minutes and 27 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 84d7d64 and dea4c9f.

📒 Files selected for processing (3)
  • README.md (1 hunks)
  • bundle.ts (1 hunks)
  • package.json (1 hunks)

Walkthrough

Introduces a Bun-based bundling workflow for the federation SDK, adds a types-only tsconfig, updates package scripts, adjusts federation-sdk entry points to dist/index.js, updates zod version, and tweaks .gitignore to include a new federation-bundle/ ignore pattern.

Changes

Cohort / File(s) Summary
Build tooling and scripts
bundle.ts, package.json
Adds bundle.ts (Bun-based bundler) to collect externals, build CJS bundle with sourcemap, prune workspace deps and emit a packaged package.json, and run tsc to emit declarations. Updates scripts: tsctsc --noEmit, bundle:sdkbun run bundle.ts, and adds bundle:watch.
Packaging and exports
packages/federation-sdk/package.json
Updates main and exports entries from ./dist/bundle.js to ./dist/index.js; bumps dependencies.zod from ^3.22.4 to ^3.24.1.
TypeScript config for declarations
tsconfig.sdk.types.json
Adds new tsconfig extending base for declaration generation (configures outDir, rootDir, declarationMap, emit settings, includes/excludes).
Git ignore updates
.gitignore
Replaces ignored pattern -link with link, adds federation-bundle/ to ignore list, and inserts a separating blank line.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer
  participant B as bundle.ts
  participant Bun as Bun.build
  participant FS as File System
  participant TSC as tsc (emitDeclarationOnly)

  Dev->>B: Run "bun run bundle.ts"
  B->>FS: Read package.jsons (core, crypto, federation-sdk, room)
  B->>Bun: Build entry: src/index.ts (CJS, minify, sourcemap, externals)
  Bun-->>FS: Write dist artifacts
  B->>FS: Prune workspace deps -> write output package.json
  B->>TSC: Generate .d.ts via tsconfig.sdk.types.json
  TSC-->>FS: Emit declarations
  B-->>Dev: Log "Bundle complete!"
  Note over B,Bun: Bun-based bundling replaces prior esbuild flow
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • ggazzo

Poem

I twitched my whiskers, pressed “bun run” with glee,
Bundles hopped to dist, as tidy as can be.
Decls sprouted crisp, like clover after rain,
Exports point to index—no more bundle pain.
In the burrow of builds, I thump: “Complete!” 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly captures the main change of the pull request, namely adding and implementing a bundle script, and uses standard conventional commit formatting without extraneous detail. It aligns directly with the new bundle.ts file and accompanying script updates, making the primary purpose of the changes clear to reviewers.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov-commenter
Copy link

codecov-commenter commented Sep 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.07%. Comparing base (d0aa61e) to head (dea4c9f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #219   +/-   ##
=======================================
  Coverage   81.07%   81.07%           
=======================================
  Files          63       63           
  Lines        4719     4719           
=======================================
  Hits         3826     3826           
  Misses        893      893           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
package.json (2)

31-31: Update Bun version to latest stable release.

The current packageManager specifies "bun@1.1.10", but the latest stable release is v1.2.22. Version 1.2.21 includes significant improvements like MySQL/SQLite support, YAML parsing, reduced memory usage, and bug fixes addressing 69 issues.

Apply this diff to update to the latest version:

-"packageManager": "bun@1.1.10",
+"packageManager": "bun@1.2.22",

54-54: Consider extracting bundle:watch configuration.

The bundle:watch command is quite long with many inline options. Consider moving the configuration to a dedicated config file or script for better maintainability.

Create a bundle.config.js or add a bun.config.js file:

export default {
  entrypoints: ['./packages/federation-sdk/src/index.ts'],
  outdir: './federation-bundle/dist',
  target: 'node',
  format: 'cjs',
  external: [
    'pino', 'mongodb', 'zod', 'pino-pretty', 
    '@rocket.chat/emitter', 'reflect-metadata', 
    'tsyringe', 'tweetnacl'
  ],
  production: true,
  sourcemap: 'inline',
  watch: true
};

Then update the script:

-"bundle:watch": "bun build --watch ./packages/federation-sdk/src/index.ts --outdir ./federation-bundle/dist --target node --format=cjs -e pino -e mongodb -e zod -e pino-pretty -e @rocket.chat/emitter -e reflect-metadata -e tsyringe -e tweetnacl --production --sourcemap=inline"
+"bundle:watch": "bun build --config bun.config.js"
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d0aa61e and ae52adb.

📒 Files selected for processing (5)
  • .gitignore (1 hunks)
  • bundle.ts (1 hunks)
  • package.json (1 hunks)
  • packages/federation-sdk/package.json (1 hunks)
  • tsconfig.sdk.types.json (1 hunks)
🔇 Additional comments (5)
.gitignore (2)

187-187: LGTM! Appropriate ignore pattern for bundle output.

The federation-bundle/ ignore pattern aligns with the latest Bun v1.2.22 bundling capabilities and matches the AI summary indicating this supports the new bundling workflow that outputs under federation-bundle/.


185-185: Ignore suggestion to change “-link” to “link”; .gitignore already lists link and no -link patterns exist.

Likely an incorrect or invalid review comment.

package.json (2)

52-52: LGTM! Simplified TypeScript compilation.

The change from bunx tsc to tsc --noEmit is more straightforward for type checking without generating output files, which aligns with the new bundle-focused workflow.


53-53: bundle.ts presence verified The file exists with the expected build logic, so the bundle:sdk script is valid.

packages/federation-sdk/package.json (1)

5-5: No action needed: build emits dist/index.js as expected – TypeScript’s outDir: "./dist" and src/index.ts ensure dist/index.js is generated; no bundle.js references remain.

Comment on lines 7 to 45
function getAllDependencies() {
const packages = ['core', 'crypto', 'federation-sdk', 'room'];

const allDependencies = new Set<string>();

for (const pkg of packages) {
const packageJson = require(`./packages/${pkg}/package.json`);

const dependencies = packageJson.dependencies
? Object.keys(packageJson.dependencies)
: [];

for (const dep of dependencies) {
allDependencies.add(dep);
}
}

return Array.from(allDependencies);
}

async function main() {
await $`rm -rf ${outputDir}/dist`;
await $`mkdir -p ${outputDir}/dist`;

const dependencies = getAllDependencies();

await Bun.build({
entrypoints: [`${inputDir}/src/index.ts`],
outdir: `${outputDir}/dist`,
target: 'node',
format: 'cjs',
external: dependencies,
env: 'disable',
define: {
'process.env.NODE_ENV': '"production"',
},
minify: true,
sourcemap: true,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix require usage under Bun’s ESM runtime

Line 13: executing this file via bun run bundle.ts treats it as ESM, so require is undefined and the script aborts before bundling. Swap to Bun’s file API and make the helper async so JSON loading works under Bun.

-// get dependencies from all packages
-function getAllDependencies() {
+// get dependencies from all packages
+async function getAllDependencies() {
 	const packages = ['core', 'crypto', 'federation-sdk', 'room'];
 
 	const allDependencies = new Set<string>();
 
 	for (const pkg of packages) {
-		const packageJson = require(`./packages/${pkg}/package.json`);
+		const packageJson = JSON.parse(
+			await Bun.file(`./packages/${pkg}/package.json`).text(),
+		);
 
 		const dependencies = packageJson.dependencies
 			? Object.keys(packageJson.dependencies)
 			: [];
 
 		for (const dep of dependencies) {
 			allDependencies.add(dep);
 		}
 	}
 
 	return Array.from(allDependencies);
 }
 
 async function main() {
 	await $`rm -rf ${outputDir}/dist`;
 	await $`mkdir -p ${outputDir}/dist`;
 
-	const dependencies = getAllDependencies();
+	const dependencies = await getAllDependencies();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function getAllDependencies() {
const packages = ['core', 'crypto', 'federation-sdk', 'room'];
const allDependencies = new Set<string>();
for (const pkg of packages) {
const packageJson = require(`./packages/${pkg}/package.json`);
const dependencies = packageJson.dependencies
? Object.keys(packageJson.dependencies)
: [];
for (const dep of dependencies) {
allDependencies.add(dep);
}
}
return Array.from(allDependencies);
}
async function main() {
await $`rm -rf ${outputDir}/dist`;
await $`mkdir -p ${outputDir}/dist`;
const dependencies = getAllDependencies();
await Bun.build({
entrypoints: [`${inputDir}/src/index.ts`],
outdir: `${outputDir}/dist`,
target: 'node',
format: 'cjs',
external: dependencies,
env: 'disable',
define: {
'process.env.NODE_ENV': '"production"',
},
minify: true,
sourcemap: true,
});
// get dependencies from all packages
async function getAllDependencies() {
const packages = ['core', 'crypto', 'federation-sdk', 'room'];
const allDependencies = new Set<string>();
for (const pkg of packages) {
const packageJson = JSON.parse(
await Bun.file(`./packages/${pkg}/package.json`).text(),
);
const dependencies = packageJson.dependencies
? Object.keys(packageJson.dependencies)
: [];
for (const dep of dependencies) {
allDependencies.add(dep);
}
}
return Array.from(allDependencies);
}
async function main() {
await $`rm -rf ${outputDir}/dist`;
await $`mkdir -p ${outputDir}/dist`;
const dependencies = await getAllDependencies();
await Bun.build({
entrypoints: [`${inputDir}/src/index.ts`],
outdir: `${outputDir}/dist`,
target: 'node',
format: 'cjs',
external: dependencies,
env: 'disable',
define: {
'process.env.NODE_ENV': '"production"',
},
minify: true,
sourcemap: true,
});
}
🤖 Prompt for AI Agents
In bundle.ts around lines 7 to 45, the helper uses require() which fails under
Bun's ESM runtime; make getAllDependencies async and replace require calls with
Bun.file(...).text() followed by JSON.parse (or Bun.file(...).json() if
available), iterate packageJson.dependencies the same way, and return the
dependency array; update main to await getAllDependencies() so bundling runs
with the resolved external list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants