Skip to content

Commit

Permalink
Fix isomorphic build
Browse files Browse the repository at this point in the history
  • Loading branch information
lukecaan committed Dec 10, 2024
1 parent 7d610c9 commit 96268d7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 11 deletions.
27 changes: 17 additions & 10 deletions sdk/scripts/postbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
});
});
Expand Down
26 changes: 25 additions & 1 deletion sdk/src/isomorphic/grpc.ts
Original file line number Diff line number Diff line change
@@ -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<typeof Client>): Client;

0 comments on commit 96268d7

Please sign in to comment.