Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 67 additions & 2 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async function main() {
`${JSON.stringify(packageJson, null, 2)}\n`,
);

await $`tsc --emitDeclarationOnly -p tsconfig.sdk.types.json`;
await $`bun run rollup -c`;

console.log('Bundle complete!');
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"dependencies": {
"dotenv": "^16.5.0",
"reflect-metadata": "^0.2.2",
"rollup-plugin-dts": "^6.2.3",
"tsyringe": "^4.10.0",
"tweetnacl": "^1.0.3"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ export * from './url';

export { makeUnsignedRequest } from './utils/makeRequest';

export type { FetchResponse } from './utils/fetch';
export type { FetchResponse, MultipartResult } from './utils/fetch';

export { fetch } from './utils/fetch';
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import type { FetchResponse, SigningKey } from '@rocket.chat/federation-core';
import type {
FetchResponse,
MultipartResult,
SigningKey,
} from '@rocket.chat/federation-core';
import {
EncryptionValidAlgorithm,
authorizationHeaders,
Expand Down Expand Up @@ -187,7 +191,7 @@ export class FederationRequestService {
targetServer: string,
endpoint: string,
queryParams?: Record<string, string>,
) {
): Promise<MultipartResult> {
const response = await this.makeSignedRequest({
method,
domain: targetServer,
Expand Down
82 changes: 82 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import dts from 'rollup-plugin-dts';

// Defina o ponto de entrada (entry point) do seu pacote
const input = './packages/federation-sdk/dist/index.d.ts';

// Função para determinar se um módulo deve ser tratado como externo
const isExternal = (id) => {
// Módulos Node.js nativos
if (
id.startsWith('node:') ||
[
'http',
'https',
'dns',
'events',
'net',
'stream',
'tls',
'worker_threads',
].includes(id)
) {
return true;
}

// Dependências de terceiros
if (
[
'zod',
'mongodb',
'tsyringe',
'pino',
'pino-std-serializers',
'sonic-boom',
'tweetnacl',
].includes(id)
) {
return true;
}
Comment on lines +25 to +38
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 | 🟡 Minor

Add reflect-metadata to the external dependencies list.

The package.json includes reflect-metadata as a dependency, but it's missing from the external list. This could lead to bundling issues.

Apply this diff:

 	if (
 		[
 			'zod',
 			'mongodb',
 			'tsyringe',
 			'pino',
 			'pino-std-serializers',
 			'sonic-boom',
 			'tweetnacl',
+			'reflect-metadata',
 		].includes(id)
 	) {
📝 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
// Dependências de terceiros
if (
[
'zod',
'mongodb',
'tsyringe',
'pino',
'pino-std-serializers',
'sonic-boom',
'tweetnacl',
].includes(id)
) {
return true;
}
// Dependências de terceiros
if (
[
'zod',
'mongodb',
'tsyringe',
'pino',
'pino-std-serializers',
'sonic-boom',
'tweetnacl',
'reflect-metadata',
].includes(id)
) {
return true;
}
🤖 Prompt for AI Agents
In rollup.config.js around lines 25 to 38, the external dependencies array is
missing "reflect-metadata" which is declared in package.json and should not be
bundled; add 'reflect-metadata' to the array of module ids checked by includes
(alongside 'zod','mongodb', etc.) so Rollup treats it as external and avoids
bundling it into the output.


// Pacotes internos do monorepo - devem ser incluídos no bundle
if (id.startsWith('@rocket.chat/') || id.startsWith('packages/')) {
return false;
}

// Imports relativos - devem ser incluídos no bundle
if (id.startsWith('.')) {
return false;
}

if (id.startsWith('/')) {
return false;
}

// Por padrão, trata como externo
return true;
};

export default [
// Configuração para o arquivo JS (você pode continuar usando esbuild, se preferir)
// ...

// Configuração para o arquivo DTS (definição de tipos)
{
input,
output: {
file: './federation-bundle/dist/index.d.ts',
format: 'es', // Formato de saída para os tipos
},
plugins: [
dts({
includeExternal: [
'@rocket.chat/federation-core',
'@rocket.chat/federation-room',
'@rocket.chat/federation-crypto',
],
respectExternal: true,
}),
],
// Use a função isExternal para determinar quais módulos são externos
external: isExternal,
},
];
6 changes: 5 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@
"cache": false
}
},
"globalDependencies": ["tsconfig.json"]
"globalDependencies": [
"tsconfig.json",
"tsconfig.sdk.types.json",
"tsconfig.base.json"
]
}