Skip to content

Commit 017b905

Browse files
handle isomorphic-ws building (#164)
1 parent f70903a commit 017b905

3 files changed

Lines changed: 62 additions & 7 deletions

File tree

esbuild.cjs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,13 @@ const nodeClientEsmBuild = esbuild.build({
8383
bundle: true,
8484
format: "esm",
8585
outfile: "dist/esm/node.js",
86+
// Handle dynamic requires (WS)
87+
banner: {
88+
js: `import { createRequire } from 'module'; const require = createRequire(import.meta.url);`,
89+
},
8690
platform: "node",
87-
external: externalModules,
91+
// These has to be optional deps, due to being native and only working in certain envs
92+
external: externalModules.concat("bufferutil", "utf-8-validate"),
8893
});
8994

9095
/**
@@ -107,8 +112,13 @@ const sdkEsmBuild = esbuild.build({
107112
format: "esm",
108113
define,
109114
platform: "node",
115+
// Handle dynamic requires (WS)
116+
banner: {
117+
js: `import { createRequire } from 'module'; const require = createRequire(import.meta.url);`,
118+
},
110119
outfile: "dist/esm/index.js",
111-
external: externalModules,
120+
// These has to be optional deps, due to being native and only working in certain envs
121+
external: externalModules.concat("bufferutil", "utf-8-validate"),
112122
});
113123

114124
/**

package-lock.json

Lines changed: 45 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@
8989
"semver": "^6.3.0",
9090
"tslib": "^2.1.0",
9191
"typescript": "^5.7.2",
92-
"why-is-node-running": "^2.3.0"
92+
"why-is-node-running": "^2.3.0",
93+
"isomorphic-ws": "^5.0.0"
9394
},
9495
"dependencies": {
9596
"@hey-api/client-fetch": "^0.7.3",
@@ -102,14 +103,15 @@
102103
"cli-table3": "^0.6.3",
103104
"date-fns": "^4.1.0",
104105
"isbinaryfile": "^5.0.4",
105-
"isomorphic-ws": "^5.0.0",
106106
"ora": "^8.2.0",
107107
"path": "^0.12.7",
108108
"readline": "^1.3.0",
109109
"util": "^0.12.5",
110110
"yargs": "^17.7.2"
111111
},
112112
"optionalDependencies": {
113-
"@sentry/node": "^9.29.0"
113+
"@sentry/node": "^9.29.0",
114+
"bufferutil": "^4.0.0",
115+
"utf-8-validate": "^6.0.0"
114116
}
115117
}

0 commit comments

Comments
 (0)