From f8ee2ffe31423c0654aa91a0e5a84f5e826721ac Mon Sep 17 00:00:00 2001 From: Chester Sim Date: Fri, 6 Dec 2024 13:06:37 +0800 Subject: [PATCH 1/2] refactor(sdk): force browser compatibility --- sdk/bun.lockb | Bin 199916 -> 199916 bytes sdk/package.json | 3 +- sdk/scripts/post-browser-build.js | 67 ++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 sdk/scripts/post-browser-build.js diff --git a/sdk/bun.lockb b/sdk/bun.lockb index 051f6d38cab7a6cc09e6b4587733945109e7083b..302bb6070c0685e044b4e59a506ba63f314f3a42 100755 GIT binary patch delta 161 zcmV;S0ABy>nGEci43I7$(Yit&+c5d1HZT@@PWq5QcW!jEWRY{Q>BB4O-28Dzb~FoGsDsHD6{3ax7!!x9MQ&`-2& zd*Gq?Q{0&IYn;gJF)mvEH= P2A3SI0u{HYlmbL}hrUJ% delta 155 zcmV;M0A&B{nGEci43I7$W`#%WO;oaW=ytK0T54^gxbU+|4xWec5=JL6*HzZyu};!8 z0RWTXFgLSUHnpTct_N8&V|P>E-TeZNBa_ej+R`0KcA+9UQw;CA%RI~ZtxciDjkAoU zdQe{Yh { + console.log(`Running ${environment} environment postbuild script`); + console.log(``); + + isomorphicPackages.forEach((package) => { + const isomorphPath = path.join( + __dirname, + '..', + 'lib', + environment, + 'isomorphic', + package + '.js' + ); + + const targetPath = path.join( + __dirname, + '..', + 'lib', + environment, + 'isomorphic', + `${package}.${BROWSER_ENVIRONMENT}.js` // force all isomorphic packages to be browser compatible + ); + + try { + const content = fs.readFileSync(targetPath, 'utf8'); + fs.writeFileSync(isomorphPath, content); + } catch (error) { + console.error( + `Error processing isomophic package : ${package} :: ${error.message}` + ); + } + + // Delete other environment files for safety + environments.forEach((otherEnvironment) => { + if (otherEnvironment === environment) { + return; + } + + const otherTargetPath = path.join( + __dirname, + '..', + 'lib', + environment, + 'isomorphic', + `${package}.${otherEnvironment}.js` + ); + + if (fs.existsSync(otherTargetPath)) { + fs.unlinkSync(otherTargetPath); + } + }); + }); +}); From c9736af50191a08ff8829bd52690f0a8fc3dd19b Mon Sep 17 00:00:00 2001 From: Chester Sim Date: Fri, 6 Dec 2024 13:54:29 +0800 Subject: [PATCH 2/2] improve postbuild script --- sdk/bun.lockb | Bin 199916 -> 199932 bytes sdk/package.json | 3 +- sdk/scripts/post-browser-build.js | 67 ------------------------------ sdk/scripts/postbuild.js | 15 ++++++- 4 files changed, 15 insertions(+), 70 deletions(-) delete mode 100644 sdk/scripts/post-browser-build.js diff --git a/sdk/bun.lockb b/sdk/bun.lockb index 302bb6070c0685e044b4e59a506ba63f314f3a42..86968313e3fe31a663c7a844e0ec00c4756ad8d3 100755 GIT binary patch delta 18856 zcmeI4d3aUTx&QZGNeG7!2qch!1QO;kkN^pT903891E@Geq9OspAhSRfMH5;lTD8(u z*&0Q`>xdIbHEN}bBPb$@ibm8xueOR>y;^G>+WYzLvkvBZxwd_N&;8whSWmwDyWV%r z?;7`6=j5a7TYh_e%WEe2^Vgg(s%AyixwDsgo;N1R^ICdd?TV5i3lY5`PVSQIc`eY- zb=(rpM)u(}xCimtz&UVhxO(Y~s`*tjt7pugyL>MBjA-V05%jgN;_rad6+bo1*RNf3 zO<~P}=APFHq9!JXB8git4Z?A2>O^eLUZp)$^-XQ13?c zO1IbXPFUq8_(5c~Yx<&dm(C&n8+0uyTVYB%H)3(sJz?BLofF23w6q&d$C?ZC{%aE# zAS=r~Bv%y^$+jb_=&g>oz%uo+rSs=br|6lBmi3!Kzb;%9l6O(Zc=$%*sR_SmF0ore{A9+s)?31i6GZbk95^A|0gO&o7$ru{l;s%ckbE0eD_8*}Z4 z$=yp6eSBk|_{d)atAYtzCHnUJKC`1!#`R8!v&fg;KV-@_e!R>MuqH%fu6-b7mTAo0 zlGm)6Z#LxG&Z(!F#!P!b>SfRt)BI|`?V(wBXclg{CDJUp?SG#wTOLin$v3slY-Q_r zY({47mLVB$m@U_2Zf|McGd8b0YEDeDmC%|bTL*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WD1>oXFoHcC}|y^yM6 z^FJ2i&ole7{JdgXk!b2Dwdxi%8RPY6aboumWf`;LgHBM_c?Yqm!EvPC?k}sXvc4$M z+He-u+0g&l+W1$NnrR0%l7D{#3CH(eZ6w?JQLFl$RyVxADNGJkvIM3xw}WOwnM{dI@xU z)Z9vE)zu6$vkd=vr0$F1=FbhZ1TH+rys7>eGlGgI@@VDXG{UqB=Y#*|2zrdeMd?Tu z)wqJX%SM`cN?P~BXfrIyWaay@<48*$^NwS`*$HM{iZkR{{`aSt$D9? { - console.log(`Running ${environment} environment postbuild script`); - console.log(``); - - isomorphicPackages.forEach((package) => { - const isomorphPath = path.join( - __dirname, - '..', - 'lib', - environment, - 'isomorphic', - package + '.js' - ); - - const targetPath = path.join( - __dirname, - '..', - 'lib', - environment, - 'isomorphic', - `${package}.${BROWSER_ENVIRONMENT}.js` // force all isomorphic packages to be browser compatible - ); - - try { - const content = fs.readFileSync(targetPath, 'utf8'); - fs.writeFileSync(isomorphPath, content); - } catch (error) { - console.error( - `Error processing isomophic package : ${package} :: ${error.message}` - ); - } - - // Delete other environment files for safety - environments.forEach((otherEnvironment) => { - if (otherEnvironment === environment) { - return; - } - - const otherTargetPath = path.join( - __dirname, - '..', - 'lib', - environment, - 'isomorphic', - `${package}.${otherEnvironment}.js` - ); - - if (fs.existsSync(otherTargetPath)) { - fs.unlinkSync(otherTargetPath); - } - }); - }); -}); diff --git a/sdk/scripts/postbuild.js b/sdk/scripts/postbuild.js index d88b29a51..c632f74a7 100644 --- a/sdk/scripts/postbuild.js +++ b/sdk/scripts/postbuild.js @@ -1,9 +1,18 @@ // scripts/postbuild.js const fs = require('fs'); const path = require('path'); +const yargs = require('yargs/yargs'); +const { hideBin } = require('yargs/helpers'); -const isomorphicPackages = ['grpc']; +const forceEnv = yargs(hideBin(process.argv)) + .option('force-env', { + type: 'string', + description: 'Specify environment to force (node or browser)', + choices: ['node', 'browser'] + }) + .argv?.forceEnv; +const isomorphicPackages = ['grpc']; const environments = ['node', 'browser']; environments.forEach((environment) => { @@ -20,13 +29,15 @@ environments.forEach((environment) => { package + '.js' ); + const targetEnv = forceEnv ? forceEnv : environment; + const targetPath = path.join( __dirname, '..', 'lib', environment, 'isomorphic', - `${package}.${environment}.js` + `${package}.${targetEnv}.js` ); try {