From 96268d70c4e7cb7e4c34c1faa5378bee7a89baa6 Mon Sep 17 00:00:00 2001 From: Luke Steyn Date: Tue, 10 Dec 2024 14:53:54 +1000 Subject: [PATCH] Fix isomorphic build --- sdk/scripts/postbuild.js | 27 +++++++++++++++++---------- sdk/src/isomorphic/grpc.ts | 26 +++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/sdk/scripts/postbuild.js b/sdk/scripts/postbuild.js index c632f74a7..7a6c9e29e 100644 --- a/sdk/scripts/postbuild.js +++ b/sdk/scripts/postbuild.js @@ -55,17 +55,24 @@ environments.forEach((environment) => { return; } - const otherTargetPath = path.join( - __dirname, - '..', - 'lib', - environment, - 'isomorphic', - `${package}.${otherEnvironment}.js` - ); + const otherTargetFiles = [ + `${package}.${otherEnvironment}.js`, + `${package}.${otherEnvironment}.d.ts`, + ]; + + for (const otherTargetFile of otherTargetFiles) { + const otherTargetPath = path.join( + __dirname, + '..', + 'lib', + environment, + 'isomorphic', + otherTargetFile + ); - if (fs.existsSync(otherTargetPath)) { - fs.unlinkSync(otherTargetPath); + if (fs.existsSync(otherTargetPath)) { + fs.unlinkSync(otherTargetPath); + } } }); }); diff --git a/sdk/src/isomorphic/grpc.ts b/sdk/src/isomorphic/grpc.ts index b1ccf629a..a4fb2b7a5 100644 --- a/sdk/src/isomorphic/grpc.ts +++ b/sdk/src/isomorphic/grpc.ts @@ -1 +1,25 @@ -export * from './grpc.node'; +/** + * DO NOT DO A STRAIGHT EXPORT FROM grpc.node.ts + * + * You will break the isomorphic build if you import anything from the bad packages except for the types (using "import type"). + */ + +import type Client from '@triton-one/yellowstone-grpc'; +import type { + SubscribeRequest, + SubscribeUpdate, + CommitmentLevel, +} from '@triton-one/yellowstone-grpc'; +import type { ClientDuplexStream, ChannelOptions } from '@grpc/grpc-js'; + +export { + ClientDuplexStream, + ChannelOptions, + SubscribeRequest, + SubscribeUpdate, + CommitmentLevel, + Client, +}; + +// Declare the function type without implementation +export declare function createClient(...args: ConstructorParameters): Client; \ No newline at end of file