Skip to content

Commit cbc8bc0

Browse files
committed
Fixed build issues
1 parent 3bb574f commit cbc8bc0

6 files changed

Lines changed: 50 additions & 197 deletions

File tree

crates/bindings-typescript/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"types": "./src/index.ts",
4343
"source": "./src/index.ts",
4444
"development": "./src/index.ts",
45+
"browser": "./dist/index.browser.mjs",
4546
"import": "./dist/index.mjs",
4647
"require": "./dist/index.cjs",
4748
"default": "./dist/index.mjs"

crates/bindings-typescript/tsup.config.ts

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,31 @@ export default defineConfig([
2525
clean: true,
2626
platform: 'neutral',
2727
treeshake: 'smallest',
28+
external: ['undici'],
29+
// env variable used at build time to determine platform-specific code
30+
// see: websocket_decompress_adapter.ts
31+
env: {
32+
BROWSER: 'false',
33+
},
2834
outExtension,
2935
esbuildOptions: commonEsbuildTweaks(),
3036
},
3137

32-
// Browser-flavored root wrapper: dist/browser/index.mjs
38+
// Browser-flavored root wrapper: dist/index.browser.mjs
3339
{
34-
entry: { index: 'src/index.ts' },
40+
entry: { 'index.browser': 'src/index.ts' },
3541
format: ['esm'],
3642
target: 'es2022',
37-
outDir: 'dist/browser',
43+
outDir: 'dist',
3844
dts: false,
3945
sourcemap: true,
4046
clean: true,
4147
platform: 'browser',
4248
treeshake: 'smallest',
49+
external: ['undici'],
50+
env: {
51+
BROWSER: 'true',
52+
},
4353
outExtension,
4454
esbuildOptions: commonEsbuildTweaks(),
4555
},
@@ -55,6 +65,10 @@ export default defineConfig([
5565
clean: true,
5666
platform: 'neutral',
5767
treeshake: 'smallest',
68+
external: ['undici'],
69+
env: {
70+
BROWSER: 'false',
71+
},
5872
outExtension,
5973
esbuildOptions: commonEsbuildTweaks(),
6074
},
@@ -70,6 +84,10 @@ export default defineConfig([
7084
clean: true,
7185
platform: 'browser',
7286
treeshake: 'smallest',
87+
external: ['undici'],
88+
env: {
89+
BROWSER: 'true',
90+
},
7391
outExtension,
7492
esbuildOptions: commonEsbuildTweaks(),
7593
},
@@ -85,6 +103,10 @@ export default defineConfig([
85103
clean: true,
86104
platform: 'neutral', // flip to 'node' if you actually rely on Node builtins
87105
treeshake: 'smallest',
106+
external: ['undici'],
107+
env: {
108+
BROWSER: 'false',
109+
},
88110
outExtension,
89111
esbuildOptions: commonEsbuildTweaks(),
90112
},
@@ -94,9 +116,9 @@ export default defineConfig([
94116
// It is expected that consumers of the library will run their own
95117
// minification as part of their app bundling process.
96118

97-
// Minified browser build: dist/min/index.mjs
119+
// Minified browser build: dist/min/index.browser.mjs
98120
{
99-
entry: { index: 'src/index.ts' },
121+
entry: { 'index.browser': 'src/index.ts' },
100122
format: ['esm'],
101123
target: 'es2022',
102124
outDir: 'dist/min',
@@ -105,6 +127,10 @@ export default defineConfig([
105127
minify: 'terser',
106128
platform: 'browser',
107129
treeshake: 'smallest',
130+
external: ['undici'],
131+
env: {
132+
BROWSER: 'true',
133+
},
108134
outExtension,
109135
esbuildOptions: commonEsbuildTweaks(),
110136
},
@@ -120,6 +146,10 @@ export default defineConfig([
120146
minify: 'terser',
121147
platform: 'browser',
122148
treeshake: 'smallest',
149+
external: ['undici'],
150+
env: {
151+
BROWSER: 'true',
152+
},
123153
outExtension: ({ format }) => ({ js: format === 'cjs' ? '.cjs' : '.mjs' }),
124154
esbuildOptions: commonEsbuildTweaks(),
125155
},

0 commit comments

Comments
 (0)