File tree 4 files changed +44
-0
lines changed
4 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 133
133
"@commitlint/config-conventional" : " ^18.4.3" ,
134
134
"@emoji-mart/data" : " ^1.1.2" ,
135
135
"@emoji-mart/react" : " ^1.1.1" ,
136
+ "@fal-works/esbuild-plugin-global-externals" : " ^2.1.2" ,
136
137
"@ladle/react" : " ^0.16.0" ,
137
138
"@playwright/test" : " ^1.42.1" ,
138
139
"@semantic-release/changelog" : " ^6.0.2" ,
Original file line number Diff line number Diff line change 3
3
import { dirname , resolve } from 'node:path' ;
4
4
import { fileURLToPath } from 'node:url' ;
5
5
import * as esbuild from 'esbuild' ;
6
+ import { globalExternals } from '@fal-works/esbuild-plugin-global-externals' ;
6
7
7
8
// import.meta.dirname is not available before Node 20
8
9
const __dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
@@ -44,6 +45,27 @@ const browserBundleConfig = {
44
45
bundle : true ,
45
46
format : 'iife' ,
46
47
external : [ 'react' , 'react-dom' , 'stream-chat' ] ,
48
+ plugins : [
49
+ globalExternals ( {
50
+ react : {
51
+ varName : 'React' ,
52
+ type : 'cjs' ,
53
+ } ,
54
+ 'react/jsx-runtime' : {
55
+ varName : 'React' ,
56
+ type : 'cjs' ,
57
+ } ,
58
+ 'react-dom' : {
59
+ varName : 'ReactDOM' ,
60
+ type : 'cjs' ,
61
+ } ,
62
+ 'stream-chat' : {
63
+ varName : 'StreamChat' ,
64
+ type : 'cjs' ,
65
+ } ,
66
+ } ) ,
67
+ ] ,
68
+ globalName : 'StreamChatReact' ,
47
69
outfile : resolve ( outDir , 'browser.full-bundle.js' ) ,
48
70
sourcemap : 'linked' ,
49
71
} ;
Original file line number Diff line number Diff line change @@ -6,3 +6,19 @@ export * from './i18n';
6
6
export * from './utils' ;
7
7
export { getChannel } from './utils/getChannel' ;
8
8
export * from './components/Emojis' ;
9
+
10
+ declare global {
11
+ interface Window {
12
+ Channel : typeof import ( 'stream-chat' ) . Channel ;
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
+ ICAL : any ;
15
+ logChatPromiseExecution : typeof import ( 'stream-chat' ) . logChatPromiseExecution ;
16
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
+ StreamChat : typeof import ( 'stream-chat' ) & { StreamChat : any } ;
18
+ }
19
+ }
20
+
21
+ window . StreamChat . StreamChat = window . StreamChat ;
22
+ window . StreamChat . logChatPromiseExecution = window . logChatPromiseExecution ;
23
+ window . StreamChat . Channel = window . Channel ;
24
+ window . ICAL = window . ICAL || { } ;
Original file line number Diff line number Diff line change 1424
1424
minimatch "^3.0.4"
1425
1425
strip-json-comments "^3.1.1"
1426
1426
1427
+ "@fal-works/esbuild-plugin-global-externals@^2.1.2":
1428
+ version "2.1.2"
1429
+ resolved "https://registry.yarnpkg.com/@fal-works/esbuild-plugin-global-externals/-/esbuild-plugin-global-externals-2.1.2.tgz#c05ed35ad82df8e6ac616c68b92c2282bd083ba4"
1430
+ integrity sha512-cEee/Z+I12mZcFJshKcCqC8tuX5hG3s+d+9nZ3LabqKF1vKdF41B92pJVCBggjAGORAeOzyyDDKrZwIkLffeOQ==
1431
+
1427
1432
"@gar/promisify@^1.1.3":
1428
1433
version "1.1.3"
1429
1434
resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.3.tgz#555193ab2e3bb3b6adc3d551c9c030d9e860daf6"
You can’t perform that action at this time.
0 commit comments